summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/rasterio/default.nix
blob: 30161b345ed16ce243523de90354a57c1e44ea14 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
{
  lib,
  stdenv,
  buildPythonPackage,
  fetchFromGitHub,

  # build-system
  cython,
  numpy,
  setuptools,

  # non-Python dependencies
  gdal-cpp,

  # dependencies
  affine,
  attrs,
  certifi,
  click,
  click-plugins,
  cligj,
  snuggs,

  # optional-dependencies
  ipython,
  matplotlib,
  boto3,

  # tests
  fsspec,
  hypothesis,
  packaging,
  pytestCheckHook,
  pytest-randomly,
  shapely,
  versionCheckHook,
}:

buildPythonPackage rec {
  pname = "rasterio";
  version = "1.4.4";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "rasterio";
    repo = "rasterio";
    tag = version;
    hash = "sha256-6y55JJ3R/JEEneM10UPHIDpSopaybY5XHJPiU+77ke4=";
  };

  postPatch = ''
    substituteInPlace pyproject.toml \
      --replace-fail "cython~=3.1.0" cython
  '';

  build-system = [
    cython
    numpy
    setuptools
  ];

  nativeBuildInputs = [
    gdal-cpp # for gdal-config
  ];

  buildInputs = [
    gdal-cpp
  ];

  pythonRelaxDeps = [
    "click"
  ];

  dependencies = [
    affine
    attrs
    certifi
    click
    click-plugins
    cligj
    numpy
    snuggs
  ];

  optional-dependencies = {
    ipython = [ ipython ];
    plot = [ matplotlib ];
    s3 = [ boto3 ];
  };

  nativeCheckInputs = [
    boto3
    fsspec
    hypothesis
    packaging
    pytestCheckHook
    pytest-randomly
    shapely
    versionCheckHook
  ];

  preCheck = ''
    rm -r rasterio # prevent importing local rasterio
  '';

  disabledTestMarks = [ "network" ];

  disabledTests = [
    # flaky
    "test_outer_boundless_pixel_fidelity"
    # network access
    "test_issue1982"
    "test_opener_fsspec_http_fs"
    "test_fsspec_http_msk_sidecar"
    # expect specific magic numbers that our version of GDAL does not produce
    "test_warp"
    "test_warpedvrt"
    "test_rio_warp"

    # AssertionError CLI exists with non-zero error code
    # This is a regression introduced by https://github.com/NixOS/nixpkgs/pull/448189
    "test_sample_stdin"
    "test_transform"
    "test_transform_point"
    "test_transform_point_dst_file"
    "test_transform_point_multi"
    "test_transform_point_src_file"
  ]
  ++ lib.optionals stdenv.hostPlatform.isDarwin [ "test_reproject_error_propagation" ];

  pythonImportsCheck = [ "rasterio" ];

  meta = {
    description = "Python package to read and write geospatial raster data";
    mainProgram = "rio";
    homepage = "https://rasterio.readthedocs.io/";
    changelog = "https://github.com/rasterio/rasterio/blob/${version}/CHANGES.txt";
    license = lib.licenses.bsd3;
    teams = [ lib.teams.geospatial ];
  };
}