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 gdal,
19 hypothesis,
20 ipython,
21 matplotlib,
22 numpy,
23 packaging,
24 pytest-randomly,
25 setuptools,
26 shapely,
27 snuggs,
28 wheel,
29
30 rasterio, # required to run version test
31}:
32
33buildPythonPackage rec {
34 pname = "rasterio";
35 version = "1.3.10";
36 format = "pyproject";
37
38 disabled = pythonOlder "3.8";
39
40 src = fetchFromGitHub {
41 owner = "rasterio";
42 repo = "rasterio";
43 rev = "refs/tags/${version}";
44 hash = "sha256-FidUaSpbTR8X1/Cqy/IwApkOOl2RRtPqYJaSISRPThI=";
45 };
46
47 postPatch = ''
48 # remove useless import statement requiring distutils to be present at the runtime
49 substituteInPlace rasterio/rio/calc.py \
50 --replace-fail "from distutils.version import LooseVersion" ""
51
52 # relax dependency on yet non-packaged, RC version of numpy
53 substituteInPlace pyproject.toml \
54 --replace-fail "numpy==2.0.0rc1" "numpy"
55 '';
56
57 nativeBuildInputs = [
58 cython
59 gdal
60 numpy
61 setuptools
62 wheel
63 ];
64
65 propagatedBuildInputs = [
66 affine
67 attrs
68 certifi
69 click
70 click-plugins
71 cligj
72 numpy
73 snuggs
74 ];
75
76 passthru.optional-dependencies = {
77 ipython = [ ipython ];
78 plot = [ matplotlib ];
79 s3 = [ boto3 ];
80 };
81
82 nativeCheckInputs = [
83 boto3
84 hypothesis
85 packaging
86 pytestCheckHook
87 pytest-randomly
88 shapely
89 ];
90
91 doCheck = true;
92
93 preCheck = ''
94 rm -r rasterio # prevent importing local rasterio
95 '';
96
97 pytestFlagsArray = [ "-m 'not network'" ];
98
99 disabledTests = [
100 # flaky
101 "test_outer_boundless_pixel_fidelity"
102 ] ++ lib.optionals stdenv.isDarwin [ "test_reproject_error_propagation" ];
103
104 pythonImportsCheck = [ "rasterio" ];
105
106 passthru.tests.version = testers.testVersion {
107 package = rasterio;
108 version = version;
109 command = "${rasterio}/bin/rio --version";
110 };
111
112 meta = with lib; {
113 description = "Python package to read and write geospatial raster data";
114 mainProgram = "rio";
115 homepage = "https://rasterio.readthedocs.io/";
116 changelog = "https://github.com/rasterio/rasterio/blob/${version}/CHANGES.txt";
117 license = licenses.bsd3;
118 maintainers = teams.geospatial.members;
119 };
120}