summaryrefslogtreecommitdiffstats
path: root/pkgs/development/python-modules/cartopy/default.nix
blob: 0df39bf4cf96619d6cba7cf1b2df2b18d7c6ce57 (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
142
143
144
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,

  # build-system
  cython,
  setuptools-scm,

  # nativeBuildInputs
  geos,
  proj,

  # dependencies
  matplotlib,
  numpy,
  pyproj,
  pyshp,
  shapely,

  # optional-dependencies
  # ows
  owslib,
  pillow,
  # plotting
  gdal,
  scipy,

  # tests
  fontconfig,
  pytest-mpl,
  pytestCheckHook,
  writableTmpDirAsHomeHook,
}:

buildPythonPackage (finalAttrs: {
  pname = "cartopy";
  version = "0.25.0.post2";
  pyproject = true;
  __structuredAttrs = true;

  src = fetchFromGitHub {
    owner = "SciTools";
    repo = "cartopy";
    tag = "v${finalAttrs.version}";
    hash = "sha256-N5cE+VKux5Wu2CtGujuMy3UA1fZBFkD+Fin/rb4rtUM=";
  };

  build-system = [
    cython
    setuptools-scm
  ];

  nativeBuildInputs = [
    geos # for geos-config
    proj
  ];

  buildInputs = [
    geos
    proj
  ];

  dependencies = [
    matplotlib
    numpy
    pyproj
    pyshp
    shapely
  ];

  optional-dependencies = {
    ows = [
      owslib
      pillow
    ];
    plotting = [
      gdal
      pillow
      scipy
    ];
  };

  nativeCheckInputs = [
    pytest-mpl
    pytestCheckHook
    writableTmpDirAsHomeHook
  ]
  ++ lib.concatAttrValues finalAttrs.passthru.optional-dependencies;

  preCheck = ''
    export FONTCONFIG_FILE=${fontconfig.out}/etc/fonts/fonts.conf
  '';

  pytestFlags = [
    "--pyargs"
    "cartopy"
  ];

  disabledTestMarks = [
    "network"
    "natural_earth"
  ];

  disabledTests = [
    # Numerical errors. Example:
    #   AssertionError: Arrays are not almost equal to 4 decimals
    "test_LatitudeFormatter_mercator"
    "test_cursor_values"
    "test_default"
    "test_extents"
    "test_geoaxes_no_subslice"
    "test_geoaxes_set_boundary_clipping"
    "test_get_extent"
    "test_gridliner_labels_zoom"
    "test_infinite_loop_bounds"
    "test_invalid_xy_domain_corner"
    "test_invalid_y_domain"
    "test_osgb_vals"
    "test_pcolormesh_datalim"
    "test_plot_after_contour_doesnt_shrink"
    "test_sweep"
    "test_tiny_point_between_boundary_points"
    "test_transform_point"
    "test_with_transform"

    # Failed: Error: Image files did not match.
    "test_background_img"
    "test_gridliner_constrained_adjust_datalim"
    "test_imshow"
    "test_pil_Image"
    "test_stock_img"
  ];

  meta = {
    description = "Process geospatial data to create maps and perform analyses";
    homepage = "https://scitools.org.uk/cartopy/docs/latest/";
    changelog = "https://github.com/SciTools/cartopy/releases/tag/${finalAttrs.src.tag}";
    license = lib.licenses.lgpl3Plus;
    maintainers = [ ];
    teams = [ lib.teams.geospatial ];
    mainProgram = "feature_download";
  };
})