1 diff --git a/shapely/geos.py b/shapely/geos.py
2 index d5a67d2..19b7ffc 100644
5 @@ -61,127 +61,17 @@ def load_dll(libname, fallbacks=None, mode=DEFAULT_MODE):
6 "Could not find lib {} or load any of its variants {}.".format(
7 libname, fallbacks or []))
11 -if sys.platform.startswith('linux'):
12 - # Test to see if we have a wheel repaired by 'auditwheel' containing its
14 - geos_whl_so = glob.glob(os.path.abspath(os.path.join(os.path.dirname(
15 - __file__), '.libs/libgeos_c-*.so.*')))
16 - if len(geos_whl_so) == 1:
17 - _lgeos = CDLL(geos_whl_so[0])
18 - LOG.debug("Found GEOS DLL: %r, using it.", _lgeos)
19 - elif hasattr(sys, 'frozen'):
20 - geos_pyinstaller_so = glob.glob(os.path.join(sys.prefix, 'libgeos_c-*.so.*'))
21 - if len(geos_pyinstaller_so) == 1:
22 - _lgeos = CDLL(geos_pyinstaller_so[0])
23 - LOG.debug("Found GEOS DLL: %r, using it.", _lgeos)
24 - elif os.getenv('CONDA_PREFIX', ''):
26 - _lgeos = CDLL(os.path.join(sys.prefix, 'lib', 'libgeos_c.so'))
32 - _lgeos = load_dll('geos_c', fallbacks=alt_paths)
33 - # Necessary for environments with only libc.musl
35 - 'libc.musl-x86_64.so.1'
37 - free = load_dll('c', fallbacks=c_alt_paths).free
38 - free.argtypes = [c_void_p]
41 -elif sys.platform == 'darwin':
42 - # Test to see if we have a delocated wheel with a GEOS dylib.
43 - geos_whl_dylib = os.path.abspath(os.path.join(os.path.dirname(
44 - __file__), '.dylibs/libgeos_c.1.dylib'))
46 - if os.path.exists(geos_whl_dylib):
48 - if hasattr(handle, "initGEOS_r"):
49 - LOG.debug("GEOS already loaded")
52 - _lgeos = CDLL(geos_whl_dylib)
53 - LOG.debug("Found GEOS DLL: %r, using it.", _lgeos)
55 - elif os.getenv('CONDA_PREFIX', ''):
57 - _lgeos = CDLL(os.path.join(sys.prefix, 'lib', 'libgeos_c.dylib'))
59 - if hasattr(sys, 'frozen'):
61 - # .app file from py2app
62 - alt_paths = [os.path.join(
63 - os.environ['RESOURCEPATH'], '..', 'Frameworks',
66 - # binary from pyinstaller
68 - os.path.join(sys.executable, 'libgeos_c.dylib')]
69 - if hasattr(sys, '_MEIPASS'):
71 - os.path.join(sys._MEIPASS, 'libgeos_c.1.dylib'))
74 - # The Framework build from Kyng Chaos
75 - "/Library/Frameworks/GEOS.framework/Versions/Current/GEOS",
77 - '/opt/local/lib/libgeos_c.dylib',
79 - '/usr/local/lib/libgeos_c.dylib',
81 - _lgeos = load_dll('geos_c', fallbacks=alt_paths)
83 - # ctypes.CDLL(None) internally calls dlopen(NULL), and as the dlopen
84 - # manpage says, "If filename is NULL, then the returned handle is for the
85 - # main program". This way we can let the linker do the work to figure out
86 - # which libc Python is actually using.
87 - free = CDLL(None).free
88 - free.argtypes = [c_void_p]
91 -elif sys.platform == 'win32':
92 - if os.getenv('CONDA_PREFIX', ''):
94 - _lgeos = CDLL(os.path.join(sys.prefix, 'Library', 'bin', 'geos_c.dll'))
97 - egg_dlls = os.path.abspath(
98 - os.path.join(os.path.dirname(__file__), 'DLLs'))
99 - if hasattr(sys, '_MEIPASS'):
100 - wininst_dlls = sys._MEIPASS
101 - elif hasattr(sys, "frozen"):
102 - wininst_dlls = os.path.normpath(
103 - os.path.abspath(sys.executable + '../../DLLS'))
105 - wininst_dlls = os.path.abspath(os.__file__ + "../../../DLLs")
106 - original_path = os.environ['PATH']
107 - os.environ['PATH'] = "%s;%s;%s" % \
108 - (egg_dlls, wininst_dlls, original_path)
109 - _lgeos = load_dll("geos_c.dll")
110 - except (ImportError, WindowsError, OSError):
115 - cdll.msvcrt.free(m)
116 - except WindowsError:
117 - # XXX: See http://trac.gispython.org/projects/PCL/ticket/149
120 -elif sys.platform == 'sunos5':
121 - _lgeos = load_dll('geos_c', fallbacks=['libgeos_c.so.1', 'libgeos_c.so'])
122 - free = CDLL('libc.so.1').free
123 - free.argtypes = [c_void_p]
124 - free.restype = None
125 -else: # other *nix systems
126 - _lgeos = load_dll('geos_c', fallbacks=['libgeos_c.so.1', 'libgeos_c.so'])
127 - free = load_dll('c', fallbacks=['libc.so.6']).free
128 - free.argtypes = [c_void_p]
129 - free.restype = None
130 +_lgeos = CDLL('@libgeos_c@')
131 +if sys.platform == 'darwin':
132 + # ctypes.CDLL(None) internally calls dlopen(NULL), and as the dlopen
133 + # manpage says, "If filename is NULL, then the returned handle is for the
134 + # main program". This way we can let the linker do the work to figure out
135 + # which libc Python is actually using.
136 + free = CDLL(None).free
138 + free = CDLL('@libc@').free
139 +free.argtypes = [c_void_p]
144 diff --git a/tests/test_dlls.py b/tests/test_dlls.py
145 index 35f9cc2..3dfcaac 100644
146 --- a/tests/test_dlls.py
147 +++ b/tests/test_dlls.py
148 @@ -12,12 +12,7 @@ class LoadingTestCase(unittest.TestCase):
149 @unittest.skipIf(sys.platform == "win32", "FIXME: adapt test for win32")
150 def test_fallbacks(self):
151 load_dll('geos_c', fallbacks=[
152 - os.path.join(sys.prefix, "lib", "libgeos_c.dylib"), # anaconda (Mac OS X)
153 - '/opt/local/lib/libgeos_c.dylib', # MacPorts
154 - '/usr/local/lib/libgeos_c.dylib', # homebrew (Mac OS X)
155 - os.path.join(sys.prefix, "lib", "libgeos_c.so"), # anaconda (Linux)