1{ lib
2, stdenv
3, buildPythonPackage
4, fetchPypi
5, substituteAll
6, pythonOlder
7, geos
8, pytestCheckHook
9, cython
10, numpy
11, fetchpatch
12}:
13
14buildPythonPackage rec {
15 pname = "Shapely";
16 version = "1.7.1";
17 disabled = pythonOlder "3.5";
18
19 src = fetchPypi {
20 inherit pname version;
21 sha256 = "0adiz4jwmwxk7k1awqifb1a9bj5x4nx4gglb5dz9liam21674h8n";
22 };
23
24 nativeBuildInputs = [
25 geos # for geos-config
26 cython
27 ];
28
29 propagatedBuildInputs = [
30 numpy
31 ];
32
33 checkInputs = [
34 pytestCheckHook
35 ];
36
37 # Environment variable used in shapely/_buildcfg.py
38 GEOS_LIBRARY_PATH = "${geos}/lib/libgeos_c${stdenv.hostPlatform.extensions.sharedLibrary}";
39
40 patches = [
41 # Fix with geos 3.9. This patch will be part of the next release after 1.7.1
42 (fetchpatch {
43 url = "https://github.com/Toblerity/Shapely/commit/77879a954d24d1596f986d16ba3eff5e13861164.patch";
44 sha256 = "1w7ngjqbpf9vnvrfg4nyv34kckim9a60gvx20h6skc79xwihd4m5";
45 excludes = [
46 "tests/test_create_inconsistent_dimensionality.py"
47 "appveyor.yml"
48 ".travis.yml"
49 ];
50 })
51 # Patch to search form GOES .so/.dylib files in a Nix-aware way
52 (substituteAll {
53 src = ./library-paths.patch;
54 libgeos_c = GEOS_LIBRARY_PATH;
55 libc = lib.optionalString (!stdenv.isDarwin) "${stdenv.cc.libc}/lib/libc${stdenv.hostPlatform.extensions.sharedLibrary}.6";
56 })
57 ];
58
59 preCheck = ''
60 rm -r shapely # prevent import of local shapely
61 '';
62
63 disabledTests = [
64 "test_collection"
65 ];
66
67 pythonImportsCheck = [ "shapely" ];
68
69 meta = with lib; {
70 description = "Geometric objects, predicates, and operations";
71 homepage = "https://pypi.python.org/pypi/Shapely/";
72 license = with licenses; [ bsd3 ];
73 maintainers = with maintainers; [ knedlsepp ];
74 };
75}