1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 pytestCheckHook,
6 pythonOlder,
7 stdenv,
8 testers,
9
10 affine,
11 attrs,
12 boto3,
13 certifi,
14 click,
15 click-plugins,
16 cligj,
17 cython,
18 fsspec,
19 gdal,
20 hypothesis,
21 ipython,
22 matplotlib,
23 numpy,
24 packaging,
25 pytest-randomly,
26 setuptools,
27 shapely,
28 snuggs,
29 wheel,
30
31 rasterio, # required to run version test
32}:
33
34buildPythonPackage rec {
35 pname = "rasterio";
36 version = "1.4.3";
37 format = "pyproject";
38
39 disabled = pythonOlder "3.8";
40
41 src = fetchFromGitHub {
42 owner = "rasterio";
43 repo = "rasterio";
44 tag = version;
45 hash = "sha256-InejYBRa4i0E2GxEWbtBpaErtcoYrhtypAlRtMlUoDk=";
46 };
47
48 postPatch = ''
49 substituteInPlace pyproject.toml \
50 --replace-fail "cython~=3.0.2" cython
51 '';
52
53 nativeBuildInputs = [
54 cython
55 gdal
56 numpy
57 setuptools
58 wheel
59 ];
60
61 propagatedBuildInputs = [
62 affine
63 attrs
64 certifi
65 click
66 click-plugins
67 cligj
68 numpy
69 snuggs
70 ];
71
72 optional-dependencies = {
73 ipython = [ ipython ];
74 plot = [ matplotlib ];
75 s3 = [ boto3 ];
76 };
77
78 nativeCheckInputs = [
79 boto3
80 fsspec
81 hypothesis
82 packaging
83 pytestCheckHook
84 pytest-randomly
85 shapely
86 ];
87
88 preCheck = ''
89 rm -r rasterio # prevent importing local rasterio
90 '';
91
92 disabledTestMarks = [ "network" ];
93
94 disabledTests = [
95 # flaky
96 "test_outer_boundless_pixel_fidelity"
97 # network access
98 "test_issue1982"
99 "test_opener_fsspec_http_fs"
100 "test_fsspec_http_msk_sidecar"
101 # expect specific magic numbers that our version of GDAL does not produce
102 "test_warp"
103 "test_warpedvrt"
104 "test_rio_warp"
105 ]
106 ++ lib.optionals stdenv.hostPlatform.isDarwin [ "test_reproject_error_propagation" ];
107
108 pythonImportsCheck = [ "rasterio" ];
109
110 passthru.tests.version = testers.testVersion {
111 package = rasterio;
112 version = version;
113 command = "${rasterio}/bin/rio --version";
114 };
115
116 meta = with lib; {
117 description = "Python package to read and write geospatial raster data";
118 mainProgram = "rio";
119 homepage = "https://rasterio.readthedocs.io/";
120 changelog = "https://github.com/rasterio/rasterio/blob/${version}/CHANGES.txt";
121 license = licenses.bsd3;
122 teams = [ teams.geospatial ];
123 };
124}