From c5a59b1cdd62a9df5747eefe33bcb6404aa7b09c Mon Sep 17 00:00:00 2001 From: Mario Rodas Date: Mon, 28 Dec 2020 04:20:00 +0000 Subject: [PATCH] python3Packages.shapely: fix build on darwin --- pkgs/development/python-modules/shapely/default.nix | 3 +-- .../python-modules/shapely/library-paths.patch | 11 +++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/pkgs/development/python-modules/shapely/default.nix b/pkgs/development/python-modules/shapely/default.nix index eb3b5b9e44d1..e2b738c479e6 100644 --- a/pkgs/development/python-modules/shapely/default.nix +++ b/pkgs/development/python-modules/shapely/default.nix @@ -29,8 +29,7 @@ buildPythonPackage rec { (substituteAll { src = ./library-paths.patch; libgeos_c = GEOS_LIBRARY_PATH; - libc = "${stdenv.cc.libc}/lib/libc${stdenv.hostPlatform.extensions.sharedLibrary}" - + stdenv.lib.optionalString (!stdenv.isDarwin) ".6"; + libc = stdenv.lib.optionalString (!stdenv.isDarwin) "${stdenv.cc.libc}/lib/libc${stdenv.hostPlatform.extensions.sharedLibrary}.6"; }) ]; diff --git a/pkgs/development/python-modules/shapely/library-paths.patch b/pkgs/development/python-modules/shapely/library-paths.patch index 319eb8a72db5..7681fb1d9bb2 100644 --- a/pkgs/development/python-modules/shapely/library-paths.patch +++ b/pkgs/development/python-modules/shapely/library-paths.patch @@ -2,7 +2,7 @@ diff --git a/shapely/geos.py b/shapely/geos.py index d5a67d2..19b7ffc 100644 --- a/shapely/geos.py +++ b/shapely/geos.py -@@ -61,127 +61,10 @@ def load_dll(libname, fallbacks=None, mode=DEFAULT_MODE): +@@ -61,127 +61,17 @@ def load_dll(libname, fallbacks=None, mode=DEFAULT_MODE): "Could not find lib {} or load any of its variants {}.".format( libname, fallbacks or [])) @@ -128,7 +128,14 @@ index d5a67d2..19b7ffc 100644 - free.argtypes = [c_void_p] - free.restype = None +_lgeos = CDLL('@libgeos_c@') -+free = CDLL('@libc@').free ++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] +free.restype = None