1diff --git a/shapely/geos.py b/shapely/geos.py
2index d5a67d2..19b7ffc 100644
3--- a/shapely/geos.py
4+++ b/shapely/geos.py
5@@ -61,123 +61,11 @@ 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 []))
8
9-_lgeos = None
10-
11-if sys.platform.startswith('linux'):
12- # Test to see if we have a wheel repaired by 'auditwheel' containing its
13- # own libgeos_c
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', ''):
25- # conda package.
26- _lgeos = CDLL(os.path.join(sys.prefix, 'lib', 'libgeos_c.so'))
27- else:
28- alt_paths = [
29- 'libgeos_c.so.1',
30- 'libgeos_c.so',
31- ]
32- _lgeos = load_dll('geos_c', fallbacks=alt_paths)
33- # Necessary for environments with only libc.musl
34- c_alt_paths = [
35- 'libc.musl-x86_64.so.1'
36- ]
37- free = load_dll('c', fallbacks=c_alt_paths).free
38- free.argtypes = [c_void_p]
39- free.restype = None
40-
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'))
45-
46- if os.path.exists(geos_whl_dylib):
47- handle = CDLL(None)
48- if hasattr(handle, "initGEOS_r"):
49- LOG.debug("GEOS already loaded")
50- _lgeos = handle
51- else:
52- _lgeos = CDLL(geos_whl_dylib)
53- LOG.debug("Found GEOS DLL: %r, using it.", _lgeos)
54-
55- elif os.getenv('CONDA_PREFIX', ''):
56- # conda package.
57- _lgeos = CDLL(os.path.join(sys.prefix, 'lib', 'libgeos_c.dylib'))
58- else:
59- if hasattr(sys, 'frozen'):
60- try:
61- # .app file from py2app
62- alt_paths = [os.path.join(
63- os.environ['RESOURCEPATH'], '..', 'Frameworks',
64- 'libgeos_c.dylib')]
65- except KeyError:
66- # binary from pyinstaller
67- alt_paths = [
68- os.path.join(sys.executable, 'libgeos_c.dylib')]
69- if hasattr(sys, '_MEIPASS'):
70- alt_paths.append(
71- os.path.join(sys._MEIPASS, 'libgeos_c.1.dylib'))
72- else:
73- alt_paths = [
74- # The Framework build from Kyng Chaos
75- "/Library/Frameworks/GEOS.framework/Versions/Current/GEOS",
76- # macports
77- '/opt/local/lib/libgeos_c.dylib',
78- # homebrew
79- '/usr/local/lib/libgeos_c.dylib',
80- ]
81- _lgeos = load_dll('geos_c', fallbacks=alt_paths)
82-
83- free = load_dll('c').free
84- free.argtypes = [c_void_p]
85- free.restype = None
86-
87-elif sys.platform == 'win32':
88- if os.getenv('CONDA_PREFIX', ''):
89- # conda package.
90- _lgeos = CDLL(os.path.join(sys.prefix, 'Library', 'bin', 'geos_c.dll'))
91- else:
92- try:
93- egg_dlls = os.path.abspath(
94- os.path.join(os.path.dirname(__file__), 'DLLs'))
95- if hasattr(sys, '_MEIPASS'):
96- wininst_dlls = sys._MEIPASS
97- elif hasattr(sys, "frozen"):
98- wininst_dlls = os.path.normpath(
99- os.path.abspath(sys.executable + '../../DLLS'))
100- else:
101- wininst_dlls = os.path.abspath(os.__file__ + "../../../DLLs")
102- original_path = os.environ['PATH']
103- os.environ['PATH'] = "%s;%s;%s" % \
104- (egg_dlls, wininst_dlls, original_path)
105- _lgeos = load_dll("geos_c.dll")
106- except (ImportError, WindowsError, OSError):
107- raise
108-
109- def free(m):
110- try:
111- cdll.msvcrt.free(m)
112- except WindowsError:
113- # XXX: See http://trac.gispython.org/projects/PCL/ticket/149
114- pass
115
116-elif sys.platform == 'sunos5':
117- _lgeos = load_dll('geos_c', fallbacks=['libgeos_c.so.1', 'libgeos_c.so'])
118- free = CDLL('libc.so.1').free
119- free.argtypes = [c_void_p]
120- free.restype = None
121-else: # other *nix systems
122- _lgeos = load_dll('geos_c', fallbacks=['libgeos_c.so.1', 'libgeos_c.so'])
123- free = load_dll('c', fallbacks=['libc.so.6']).free
124- free.argtypes = [c_void_p]
125- free.restype = None
126+_lgeos = CDLL('@libgeos_c@')
127+free = CDLL('@libc@').free
128+free.argtypes = [c_void_p]
129+free.restype = None
130
131
132 def _geos_version():
133diff --git a/tests/test_dlls.py b/tests/test_dlls.py
134index 35f9cc2..3dfcaac 100644
135--- a/tests/test_dlls.py
136+++ b/tests/test_dlls.py
137@@ -12,12 +12,7 @@ class LoadingTestCase(unittest.TestCase):
138 @unittest.skipIf(sys.platform == "win32", "FIXME: adapt test for win32")
139 def test_fallbacks(self):
140 load_dll('geos_c', fallbacks=[
141- os.path.join(sys.prefix, "lib", "libgeos_c.dylib"), # anaconda (Mac OS X)
142- '/opt/local/lib/libgeos_c.dylib', # MacPorts
143- '/usr/local/lib/libgeos_c.dylib', # homebrew (Mac OS X)
144- os.path.join(sys.prefix, "lib", "libgeos_c.so"), # anaconda (Linux)
145- 'libgeos_c.so.1',
146- 'libgeos_c.so'])
147+ '@libgeos_c@'])
148
149
150 def test_suite():