pythonPackages.shapely: use patch to set library paths

This commit is contained in:
Robert Schütz
2019-02-25 15:10:45 +01:00
parent d54485a145
commit 83ec5c102b
2 changed files with 127 additions and 13 deletions

View File

@@ -1,5 +1,5 @@
{ stdenv, buildPythonPackage, fetchPypi
, geos, glibcLocales, pytest, cython
{ stdenv, buildPythonPackage, fetchPypi, substituteAll
, geos, pytest, cython
, numpy
}:
@@ -12,26 +12,31 @@ buildPythonPackage rec {
sha256 = "c4b87bb61fc3de59fc1f85e71a79b0c709dc68364d9584473697aad4aa13240f";
};
buildInputs = [ geos glibcLocales cython ];
nativeBuildInputs = [
geos # for geos-config
cython
];
checkInputs = [ pytest ];
propagatedBuildInputs = [ numpy ];
preConfigure = ''
export LANG="en_US.UTF-8";
'';
# environment variable used in shapely/_buildcfg.py
GEOS_LIBRARY_PATH = "${geos}/lib/libgeos_c${stdenv.hostPlatform.extensions.sharedLibrary}";
patchPhase = let
libc = if stdenv.isDarwin then "libc.dylib" else "libc.so.6";
in ''
sed -i "s|_lgeos = load_dll('geos_c', fallbacks=.*)|_lgeos = load_dll('geos_c', fallbacks=['${geos}/lib/libgeos_c${stdenv.hostPlatform.extensions.sharedLibrary}'])|" shapely/geos.py
sed -i "s|free = load_dll('c').free|free = load_dll('c', fallbacks=['${stdenv.cc.libc}/lib/${libc}']).free|" shapely/geos.py
'';
patches = [
(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";
})
];
# Disable the tests that improperly try to use the built extensions
checkPhase = ''
py.test -k 'not test_vectorized and not test_fallbacks' tests
rm -r shapely # prevent import of local shapely
py.test tests
'';
meta = with stdenv.lib; {