Skip to content

Commit b17ed5c

Browse files
committed
Reimplement GEOS search to find dylib files on MacOS
1 parent f9c9dab commit b17ed5c

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

packages/basemap/setup.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,14 @@ def get_geos_install_prefix():
3737
candidates = [os.path.expanduser("~/local"), os.path.expanduser("~"),
3838
"/usr/local", "/usr", "/opt/local", "/opt", "/sw"]
3939

40+
# Prepare filename pattern to find the GEOS library.
41+
extensions = {"win32": "dll", "cygwin": "dll", "darwin": "dylib"}
42+
libext = extensions.get(sys.platform, "so*")
43+
libname = "*geos_c*.{0}".format(libext)
44+
libdirs = ["bin", "lib", "lib/x86_64-linux-gnu", "lib64"]
45+
4046
for prefix in candidates:
4147
libfiles = []
42-
libdirs = ["bin", "lib", "lib/x86_64-linux-gnu", "lib64"]
43-
libext = "dll" if os.name == "nt" else "so"
44-
libcode = "{0}geos_c".format("" if os.name == "nt" else "lib")
45-
libname = "{0}*.{1}*".format(libcode, libext)
4648
for libdir in libdirs:
4749
libfiles.extend(glob.glob(os.path.join(prefix, libdir, libname)))
4850
hfile = os.path.join(prefix, "include", "geos_c.h")
@@ -111,7 +113,7 @@ def run(self):
111113
# `distutils` bug (http://bugs.python.org/issue2437).
112114
library_dirs.append(os.path.join(geos_install_prefix, "bin"))
113115
runtime_library_dirs = []
114-
dlls = glob.glob(os.path.join(geos_install_prefix, "*", "geos_c.dll"))
116+
dlls = glob.glob(os.path.join(geos_install_prefix, "*", "*geos_c.dll"))
115117
if dlls:
116118
data_files.append(("../..", sorted(dlls)))
117119

0 commit comments

Comments
 (0)