1{
2 lib,
3 buildPythonPackage,
4 certifi,
5 cftime,
6 curl,
7 cython,
8 fetchPypi,
9 hdf5,
10 isPyPy,
11 libjpeg,
12 netcdf,
13 numpy,
14 oldest-supported-numpy,
15 python,
16 pythonOlder,
17 setuptools-scm,
18 stdenv,
19 wheel,
20 zlib,
21}:
22
23buildPythonPackage rec {
24 pname = "netcdf4";
25 version = "1.7.1.post2";
26 pyproject = true;
27
28 disabled = isPyPy || pythonOlder "3.8";
29
30 src = fetchPypi {
31 inherit pname version;
32 hash = "sha256-N9VX42ZUiJ1wIBkr+1b51fk4lMsymX64N65YbFOP17Y=";
33 };
34
35 postPatch = ''
36 sed -i "/numpy>=/d" pyproject.toml
37 '';
38
39 build-system = [
40 cython
41 oldest-supported-numpy
42 setuptools-scm
43 wheel
44 ];
45
46 propagatedBuildInputs = [
47 certifi
48 cftime
49 curl
50 hdf5
51 libjpeg
52 netcdf
53 numpy
54 zlib
55 ];
56
57 checkPhase = ''
58 pushd test/
59 NO_NET=1 NO_CDL=1 ${python.interpreter} run_all.py
60 '';
61
62 env = {
63 # Variables used to configure the build process
64 USE_NCCONFIG = "0";
65 HDF5_DIR = lib.getDev hdf5;
66 NETCDF4_DIR = netcdf;
67 CURL_DIR = curl.dev;
68 JPEG_DIR = libjpeg.dev;
69 } // lib.optionalAttrs stdenv.cc.isClang { NIX_CFLAGS_COMPILE = "-Wno-error=int-conversion"; };
70
71 pythonImportsCheck = [ "netCDF4" ];
72
73 meta = with lib; {
74 description = "Interface to netCDF library (versions 3 and 4)";
75 homepage = "https://github.com/Unidata/netcdf4-python";
76 changelog = "https://github.com/Unidata/netcdf4-python/raw/v${version}/Changelog";
77 maintainers = [ ];
78 license = licenses.mit;
79 };
80}