diff --git a/pkgs/development/python-modules/shapely/default.nix b/pkgs/development/python-modules/shapely/default.nix index e8ea874e5ca5..7cf75e12cb54 100644 --- a/pkgs/development/python-modules/shapely/default.nix +++ b/pkgs/development/python-modules/shapely/default.nix @@ -13,12 +13,12 @@ buildPythonPackage rec { pname = "Shapely"; - version = "1.7.1"; - disabled = pythonOlder "3.5"; + version = "1.8.0"; + disabled = pythonOlder "3.6"; src = fetchPypi { inherit pname version; - sha256 = "0adiz4jwmwxk7k1awqifb1a9bj5x4nx4gglb5dz9liam21674h8n"; + sha256 = "177g8wxsgnphhhn4634n6ca1qrk462ijqlznpj5ry6d49ghpwc7m"; }; nativeBuildInputs = [ @@ -38,16 +38,6 @@ buildPythonPackage rec { GEOS_LIBRARY_PATH = "${geos}/lib/libgeos_c${stdenv.hostPlatform.extensions.sharedLibrary}"; patches = [ - # Fix with geos 3.9. This patch will be part of the next release after 1.7.1 - (fetchpatch { - url = "https://github.com/Toblerity/Shapely/commit/77879a954d24d1596f986d16ba3eff5e13861164.patch"; - sha256 = "1w7ngjqbpf9vnvrfg4nyv34kckim9a60gvx20h6skc79xwihd4m5"; - excludes = [ - "tests/test_create_inconsistent_dimensionality.py" - "appveyor.yml" - ".travis.yml" - ]; - }) # Patch to search form GOES .so/.dylib files in a Nix-aware way (substituteAll { src = ./library-paths.patch; diff --git a/pkgs/development/python-modules/shapely/library-paths.patch b/pkgs/development/python-modules/shapely/library-paths.patch index 7681fb1d9bb2..d55630be9c10 100644 --- a/pkgs/development/python-modules/shapely/library-paths.patch +++ b/pkgs/development/python-modules/shapely/library-paths.patch @@ -1,27 +1,45 @@ diff --git a/shapely/geos.py b/shapely/geos.py -index d5a67d2..19b7ffc 100644 +index 4619732..1abdb5e 100644 --- a/shapely/geos.py +++ b/shapely/geos.py -@@ -61,127 +61,17 @@ def load_dll(libname, fallbacks=None, mode=DEFAULT_MODE): +@@ -55,148 +55,21 @@ def load_dll(libname, fallbacks=None, mode=DEFAULT_MODE): "Could not find lib {} or load any of its variants {}.".format( libname, fallbacks or [])) -_lgeos = None + def exists_conda_env(): + """Does this module exist in a conda environment?""" + return os.path.exists(os.path.join(sys.prefix, 'conda-meta')) + - -if sys.platform.startswith('linux'): -- # Test to see if we have a wheel repaired by 'auditwheel' containing its -- # own libgeos_c -- geos_whl_so = glob.glob(os.path.abspath(os.path.join(os.path.dirname( -- __file__), '.libs/libgeos_c-*.so.*'))) -- if len(geos_whl_so) == 1: -- _lgeos = CDLL(geos_whl_so[0]) +- # Test to see if we have a wheel repaired by auditwheel which contains its +- # own libgeos_c. Note: auditwheel 3.1 changed the location of libs. +- geos_whl_so = glob.glob( +- os.path.abspath(os.path.join(os.path.dirname(__file__), ".libs/libgeos*.so*")) +- ) or glob.glob( +- os.path.abspath( +- os.path.join( +- os.path.dirname(__file__), "..", "Shapely.libs", "libgeos*.so*" +- ) +- ) +- ) +- +- if len(geos_whl_so) > 0: +- # We have observed problems with CDLL of libgeos_c not automatically +- # loading the sibling c++ library since the change made by auditwheel +- # 3.1, so we explicitly load them both. +- geos_whl_so = sorted(geos_whl_so) +- CDLL(geos_whl_so[0]) +- _lgeos = CDLL(geos_whl_so[-1]) - LOG.debug("Found GEOS DLL: %r, using it.", _lgeos) +- - elif hasattr(sys, 'frozen'): - geos_pyinstaller_so = glob.glob(os.path.join(sys.prefix, 'libgeos_c-*.so.*')) -- if len(geos_pyinstaller_so) == 1: +- if len(geos_pyinstaller_so) >= 1: - _lgeos = CDLL(geos_pyinstaller_so[0]) - LOG.debug("Found GEOS DLL: %r, using it.", _lgeos) -- elif os.getenv('CONDA_PREFIX', ''): +- elif exists_conda_env(): - # conda package. - _lgeos = CDLL(os.path.join(sys.prefix, 'lib', 'libgeos_c.so')) - else: @@ -30,11 +48,14 @@ index d5a67d2..19b7ffc 100644 - 'libgeos_c.so', - ] - _lgeos = load_dll('geos_c', fallbacks=alt_paths) -- # Necessary for environments with only libc.musl -- c_alt_paths = [ -- 'libc.musl-x86_64.so.1' -- ] -- free = load_dll('c', fallbacks=c_alt_paths).free +- ++_lgeos = CDLL('@libgeos_c@') ++if sys.platform == 'darwin': + # ctypes.CDLL(None) internally calls dlopen(NULL), and as the dlopen + # manpage says, "If filename is NULL, then the returned handle is for the + # main program". This way we can let the linker do the work to figure out + # which libc Python is actually using. + free = CDLL(None).free - free.argtypes = [c_void_p] - free.restype = None - @@ -52,7 +73,7 @@ index d5a67d2..19b7ffc 100644 - _lgeos = CDLL(geos_whl_dylib) - LOG.debug("Found GEOS DLL: %r, using it.", _lgeos) - -- elif os.getenv('CONDA_PREFIX', ''): +- elif exists_conda_env(): - # conda package. - _lgeos = CDLL(os.path.join(sys.prefix, 'lib', 'libgeos_c.dylib')) - else: @@ -63,9 +84,11 @@ index d5a67d2..19b7ffc 100644 - os.environ['RESOURCEPATH'], '..', 'Frameworks', - 'libgeos_c.dylib')] - except KeyError: -- # binary from pyinstaller - alt_paths = [ -- os.path.join(sys.executable, 'libgeos_c.dylib')] +- # binary from pyinstaller +- os.path.join(sys.executable, 'libgeos_c.dylib'), +- # .app from cx_Freeze +- os.path.join(os.path.dirname(sys.executable), 'libgeos_c.1.dylib')] - if hasattr(sys, '_MEIPASS'): - alt_paths.append( - os.path.join(sys._MEIPASS, 'libgeos_c.1.dylib')) @@ -75,23 +98,22 @@ index d5a67d2..19b7ffc 100644 - "/Library/Frameworks/GEOS.framework/Versions/Current/GEOS", - # macports - '/opt/local/lib/libgeos_c.dylib', -- # homebrew +- # homebrew Intel - '/usr/local/lib/libgeos_c.dylib', +- # homebrew Apple Silicon +- '/opt/homebrew/lib/libgeos_c.dylib', - ] - _lgeos = load_dll('geos_c', fallbacks=alt_paths) - -- # ctypes.CDLL(None) internally calls dlopen(NULL), and as the dlopen -- # manpage says, "If filename is NULL, then the returned handle is for the -- # main program". This way we can let the linker do the work to figure out -- # which libc Python is actually using. - free = CDLL(None).free - free.argtypes = [c_void_p] - free.restype = None - -elif sys.platform == 'win32': -- if os.getenv('CONDA_PREFIX', ''): +- _conda_dll_path = os.path.join(sys.prefix, 'Library', 'bin', 'geos_c.dll') +- if exists_conda_env() and os.path.exists(_conda_dll_path): - # conda package. -- _lgeos = CDLL(os.path.join(sys.prefix, 'Library', 'bin', 'geos_c.dll')) +- _lgeos = CDLL(_conda_dll_path) - else: - try: - egg_dlls = os.path.abspath( @@ -119,21 +141,15 @@ index d5a67d2..19b7ffc 100644 - -elif sys.platform == 'sunos5': - _lgeos = load_dll('geos_c', fallbacks=['libgeos_c.so.1', 'libgeos_c.so']) -- free = CDLL('libc.so.1').free +- free.restype = None - free.argtypes = [c_void_p] - free.restype = None +- -else: # other *nix systems - _lgeos = load_dll('geos_c', fallbacks=['libgeos_c.so.1', 'libgeos_c.so']) -- free = load_dll('c', fallbacks=['libc.so.6']).free +- free = CDLL(None).free - free.argtypes = [c_void_p] - free.restype = None -+_lgeos = CDLL('@libgeos_c@') -+if sys.platform == 'darwin': -+ # ctypes.CDLL(None) internally calls dlopen(NULL), and as the dlopen -+ # manpage says, "If filename is NULL, then the returned handle is for the -+ # main program". This way we can let the linker do the work to figure out -+ # which libc Python is actually using. -+ free = CDLL(None).free +else: + free = CDLL('@libc@').free +free.argtypes = [c_void_p] @@ -142,20 +158,18 @@ index d5a67d2..19b7ffc 100644 def _geos_version(): diff --git a/tests/test_dlls.py b/tests/test_dlls.py -index 35f9cc2..3dfcaac 100644 +index c71da8e..fae9da6 100644 --- a/tests/test_dlls.py +++ b/tests/test_dlls.py -@@ -12,12 +12,7 @@ class LoadingTestCase(unittest.TestCase): +@@ -12,10 +12,4 @@ class LoadingTestCase(unittest.TestCase): @unittest.skipIf(sys.platform == "win32", "FIXME: adapt test for win32") def test_fallbacks(self): load_dll('geos_c', fallbacks=[ - os.path.join(sys.prefix, "lib", "libgeos_c.dylib"), # anaconda (Mac OS X) -- '/opt/local/lib/libgeos_c.dylib', # MacPorts -- '/usr/local/lib/libgeos_c.dylib', # homebrew (Mac OS X) +- '/opt/local/lib/libgeos_c.dylib', # MacPorts +- '/usr/local/lib/libgeos_c.dylib', # homebrew (Mac OS X) +- '/opt/homebrew/lib/libgeos_c.dylib', # homebrew (macOS) - os.path.join(sys.prefix, "lib", "libgeos_c.so"), # anaconda (Linux) - 'libgeos_c.so.1', - 'libgeos_c.so']) + '@libgeos_c@']) - - - def test_suite():