summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/netcdf4/default.nix
blob: 07d4d53b75a44505a5983e1a9a96387c06f63810 (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
{
  lib,
  buildPythonPackage,
  certifi,
  cftime,
  curl,
  cython,
  fetchFromGitHub,
  hdf5,
  isPyPy,
  libjpeg,
  netcdf,
  numpy,
  oldest-supported-numpy,
  python,
  setuptools-scm,
  stdenv,
  wheel,
  zlib,
}:

let
  version = "1.7.2";
  suffix = lib.optionalString (lib.match ''.*\.post[0-9]+'' version == null) "rel";
  tag = "v${version}${suffix}";
in
buildPythonPackage {
  pname = "netcdf4";
  inherit version;
  pyproject = true;

  disabled = isPyPy;

  src = fetchFromGitHub {
    owner = "Unidata";
    repo = "netcdf4-python";
    inherit tag;
    hash = "sha256-orwCHKOSam+2eRY/yAduFYWREOkJlWIJGIZPZwQZ/RI=";
  };

  build-system = [
    cython
    oldest-supported-numpy
    setuptools-scm
    wheel
  ];

  dependencies = [
    certifi
    cftime
    numpy
  ];

  buildInputs = [
    curl
    hdf5
    libjpeg
    netcdf
    zlib
  ];

  checkPhase = ''
    runHook preCheck

    pushd test/
    NO_NET=1 NO_CDL=1 ${python.interpreter} run_all.py

    runHook postCheck
  '';

  env = {
    # Variables used to configure the build process
    USE_NCCONFIG = "0";
    HDF5_DIR = lib.getDev hdf5;
    NETCDF4_DIR = netcdf;
    CURL_DIR = curl.dev;
    JPEG_DIR = libjpeg.dev;
  }
  // lib.optionalAttrs stdenv.cc.isClang { NIX_CFLAGS_COMPILE = "-Wno-error=int-conversion"; };

  pythonImportsCheck = [ "netCDF4" ];

  meta = {
    description = "Interface to netCDF library (versions 3 and 4)";
    homepage = "https://github.com/Unidata/netcdf4-python";
    changelog = "https://github.com/Unidata/netcdf4-python/raw/${tag}/Changelog";
    maintainers = [ ];
    license = lib.licenses.mit;
  };
}