1{ lib
2, buildPythonPackage
3, pythonOlder
4, fetchPypi
5, fetchpatch
6, cython
7, setuptools-scm
8, geos
9, proj
10, matplotlib
11, numpy
12, pyproj
13, pyshp
14, shapely
15, owslib
16, pillow
17, gdal
18, scipy
19, fontconfig
20, pytest-mpl
21, pytestCheckHook
22}:
23
24buildPythonPackage rec {
25 pname = "cartopy";
26 version = "0.21.1";
27
28 disabled = pythonOlder "3.8";
29
30 format = "setuptools";
31
32 src = fetchPypi {
33 inherit version;
34 pname = "Cartopy";
35 hash = "sha256-idVklxLIWCIxxuEYJaBMhfbwzulNu4nk2yPqvKHMJQo=";
36 };
37
38 patches = [
39 # https://github.com/SciTools/cartopy/pull/2163
40 (fetchpatch {
41 url = "https://github.com/SciTools/cartopy/commit/7fb57e294914dbda0ebe8caaeac4deffe5e71639.patch";
42 hash = "sha256-qc14q+v2IMC+1NQ+OqLjUfJA3Sr5txniqS7CTQ6c7LI=";
43 })
44 # https://github.com/SciTools/cartopy/pull/2130
45 (fetchpatch {
46 url = "https://github.com/SciTools/cartopy/commit/6b4572ba1a8a877f28e25dfe9559c14b7a565958.patch";
47 hash = "sha256-0u6VJMrvoD9bRLHiQV4HQCKDyWEb9dDS2A3rjm6uqYw=";
48 })
49 ];
50
51 nativeBuildInputs = [
52 cython
53 geos # for geos-config
54 proj
55 setuptools-scm
56 ];
57
58 buildInputs = [
59 geos proj
60 ];
61
62 propagatedBuildInputs = [
63 matplotlib
64 numpy
65 pyproj
66 pyshp
67 shapely
68 ];
69
70 passthru.optional-dependencies = {
71 ows = [ owslib pillow ];
72 plotting = [ gdal pillow scipy ];
73 };
74
75 nativeCheckInputs = [
76 pytest-mpl
77 pytestCheckHook
78 ] ++ lib.flatten (lib.attrValues passthru.optional-dependencies);
79
80 preCheck = ''
81 export FONTCONFIG_FILE=${fontconfig.out}/etc/fonts/fonts.conf
82 export HOME=$TMPDIR
83 '';
84
85 pytestFlagsArray = [
86 "--pyargs" "cartopy"
87 "-m" "'not network and not natural_earth'"
88 ];
89
90 disabledTests = [
91 "test_gridliner_labels_bbox_style"
92 ];
93
94 meta = with lib; {
95 description = "Process geospatial data to create maps and perform analyses";
96 license = licenses.lgpl3Plus;
97 homepage = "https://scitools.org.uk/cartopy/docs/latest/";
98 maintainers = with maintainers; [ mredaelli ];
99 };
100}