summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/pyinterp/default.nix
blob: b3a162ef1f93e87dbce759777ebb5c76dacb6ddd (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
{
  lib,
  stdenv,
  buildPythonPackage,
  fetchFromGitHub,

  # buildInputs
  boost,
  blas,
  eigen,
  gtest,
  pybind11,

  # build-system
  cmake,
  setuptools,

  # dependencies
  dask,
  numpy,
  xarray,

  # tests
  pytestCheckHook,
}:
buildPythonPackage rec {
  pname = "pyinterp";
  version = "2025.8.1";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "CNES";
    repo = "pangeo-pyinterp";
    tag = version;
    hash = "sha256-9DZIPiqt0JbadeGIkVrg+XuPu4XfVlHm36sBKZ2G7ww=";
  };

  # Remove the git submodule link to pybind11, patch setup.py build backend and version information
  postPatch = ''
    rm -rf third_party/pybind11
    mkdir -p third_party
    ln -sr ${pybind11.src} third_party/pybind11

    substituteInPlace pyproject.toml --replace-fail 'build-backend = "backend"' 'build-backend = "setuptools.build_meta"'
    substituteInPlace pyproject.toml --replace-fail 'backend-path = ["_custom_build"]' ""

    substituteInPlace setup.py \
      --replace-fail 'version=revision(),' 'version="${version}",'

    substituteInPlace src/pyinterp/__init__.py \
     --replace-fail 'from . import geodetic, geohash, version' 'from . import geodetic, geohash' \
     --replace-fail '__version__ = version.release()' '__version__ = "${version}"' \
     --replace-fail '__date__ = version.date()' '__date__ = "${version}"' \
     --replace-fail 'del version' ""
  '';

  dontUseCmakeConfigure = true;

  buildInputs = [
    blas
    boost
    eigen
    gtest
    pybind11
  ];

  build-system = [
    cmake
    setuptools
  ];

  dependencies = [
    dask
    numpy
    xarray
  ];

  pythonImportsCheck = [
    "pyinterp"
    "pyinterp.geohash"
  ];

  disabledTests = [
    # segmentation fault
    "test_bounding_box"
    "test_geohash"
    "test_encoding"
    "test_neighbors"
  ]
  ++ lib.optionals stdenv.hostPlatform.isAarch64 [
    # AssertionError, probably floating point precision differences
    "test_quadrivariate"
  ];

  nativeCheckInputs = [
    pytestCheckHook
  ];

  meta = {
    description = "Python library for optimized geo-referenced interpolation";
    homepage = "https://github.com/CNES/pangeo-pyinterp";
    changelog = "https://github.com/CNES/pangeo-pyinterp/releases/tag/${src.tag}";
    license = lib.licenses.bsd3;
    maintainers = with lib.maintainers; [ daspk04 ];
  };
}