Skip to content

Commit 10a40c8

Browse files
fix setup.py to account for pkg-config quirks (#24)
* fix setup.py to account for pkg-config differences * Update setup.py Co-authored-by: James Mitchell <james-d-mitchell@users.noreply.github.com>
1 parent 520c177 commit 10a40c8

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

setup.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,13 @@ def __str__(self):
135135
LIBRARY_PATH = pkgconfig.pkgconfig._query( # pylint: disable=protected-access
136136
"libsemigroups", "--libs-only-L"
137137
)
138+
139+
# The above pkgconfig query can return an empty string (this also happens on
140+
# the command line). This happens, for example, using pkg-config version 1.8.0
141+
# on ArchLinux. CN 27/10/2021
142+
138143
assert (
139-
LIBRARY_PATH[:2] == "-L"
144+
len(LIBRARY_PATH) == 0 or LIBRARY_PATH[:2] == "-L"
140145
), "The first two characters of the library path to the libsemigroups.so etc should be '-L'"
141146

142147
# Try to use pkg-config to add the path to libsemigroups.so etc to
@@ -145,7 +150,12 @@ def __str__(self):
145150
# though the path to libsemigroups.so etc is not in LD_LIBRARY_PATH. This is
146151
# the case, for example, on JDM's computer.
147152

148-
LIBRARY_PATH_NO_L = LIBRARY_PATH[2:]
153+
if len(LIBRARY_PATH) != 0:
154+
LIBRARY_PATH_NO_L = LIBRARY_PATH[2:]
155+
else:
156+
LIBRARY_PATH_NO_L = "/usr/lib"
157+
LIBRARY_PATH = "-L/usr/lib"
158+
149159
if os.path.exists(LIBRARY_PATH_NO_L):
150160
if (
151161
"LD_LIBRARY_PATH" in os.environ

0 commit comments

Comments
 (0)