1{ lib
2, stdenv
3, buildPythonPackage
4, fetchPypi
5, substituteAll
6, pythonOlder
7, geos
8, pytestCheckHook
9, cython
10, numpy
11}:
12
13buildPythonPackage rec {
14 pname = "Shapely";
15 version = "1.8.4";
16 disabled = pythonOlder "3.6";
17
18 src = fetchPypi {
19 inherit pname version;
20 sha256 = "sha256-oZXlHKr6IYKR8suqP+9p/TNTyT7EtlsqRyLEz0DDGYw=";
21 };
22
23 nativeBuildInputs = [
24 geos # for geos-config
25 cython
26 ];
27
28 propagatedBuildInputs = [
29 numpy
30 ];
31
32 checkInputs = [
33 pytestCheckHook
34 ];
35
36 # Environment variable used in shapely/_buildcfg.py
37 GEOS_LIBRARY_PATH = "${geos}/lib/libgeos_c${stdenv.hostPlatform.extensions.sharedLibrary}";
38
39 patches = [
40 # Patch to search form GOES .so/.dylib files in a Nix-aware way
41 (substituteAll {
42 src = ./library-paths.patch;
43 libgeos_c = GEOS_LIBRARY_PATH;
44 libc = lib.optionalString (!stdenv.isDarwin) "${stdenv.cc.libc}/lib/libc${stdenv.hostPlatform.extensions.sharedLibrary}.6";
45 })
46 ];
47
48 preCheck = ''
49 rm -r shapely # prevent import of local shapely
50 '';
51
52 disabledTests = lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
53 # FIXME(lf-): these logging tests are broken, which is definitely our
54 # fault. I've tried figuring out the cause and failed.
55 #
56 # It is apparently some sandbox or no-sandbox related thing on macOS only
57 # though.
58 "test_error_handler_exception"
59 "test_error_handler"
60 "test_info_handler"
61 ];
62
63 pythonImportsCheck = [ "shapely" ];
64
65 meta = with lib; {
66 description = "Geometric objects, predicates, and operations";
67 homepage = "https://pypi.python.org/pypi/Shapely/";
68 license = with licenses; [ bsd3 ];
69 maintainers = with maintainers; [ knedlsepp ];
70 };
71}