1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6
7 # buildInputs
8 boost,
9 blas,
10 eigen,
11 gtest,
12 pybind11,
13
14 # build-system
15 cmake,
16 setuptools,
17
18 # dependencies
19 dask,
20 numpy,
21 xarray,
22
23 # tests
24 pytestCheckHook,
25}:
26buildPythonPackage rec {
27 pname = "pyinterp";
28 version = "2025.8.1";
29 pyproject = true;
30
31 src = fetchFromGitHub {
32 owner = "CNES";
33 repo = "pangeo-pyinterp";
34 tag = version;
35 hash = "sha256-9DZIPiqt0JbadeGIkVrg+XuPu4XfVlHm36sBKZ2G7ww=";
36 };
37
38 # Remove the git submodule link to pybind11, patch setup.py build backend and version information
39 postPatch = ''
40 rm -rf third_party/pybind11
41 mkdir -p third_party
42 ln -sr ${pybind11.src} third_party/pybind11
43
44 substituteInPlace pyproject.toml --replace-fail 'build-backend = "backend"' 'build-backend = "setuptools.build_meta"'
45 substituteInPlace pyproject.toml --replace-fail 'backend-path = ["_custom_build"]' ""
46
47 substituteInPlace setup.py \
48 --replace-fail 'version=revision(),' 'version="${version}",'
49
50 substituteInPlace src/pyinterp/__init__.py \
51 --replace-fail 'from . import geodetic, geohash, version' 'from . import geodetic, geohash' \
52 --replace-fail '__version__ = version.release()' '__version__ = "${version}"' \
53 --replace-fail '__date__ = version.date()' '__date__ = "${version}"' \
54 --replace-fail 'del version' ""
55 '';
56
57 dontUseCmakeConfigure = true;
58
59 buildInputs = [
60 blas
61 boost
62 eigen
63 gtest
64 pybind11
65 ];
66
67 build-system = [
68 cmake
69 setuptools
70 ];
71
72 dependencies = [
73 dask
74 numpy
75 xarray
76 ];
77
78 pythonImportsCheck = [
79 "pyinterp"
80 "pyinterp.geohash"
81 ];
82
83 disabledTests = [
84 # segmentation fault
85 "test_bounding_box"
86 "test_geohash"
87 "test_encoding"
88 "test_neighbors"
89 ]
90 ++ lib.optionals stdenv.hostPlatform.isAarch64 [
91 # AssertionError, probably floating point precision differences
92 "test_quadrivariate"
93 ];
94
95 nativeCheckInputs = [
96 pytestCheckHook
97 ];
98
99 meta = {
100 description = "Python library for optimized geo-referenced interpolation";
101 homepage = "https://github.com/CNES/pangeo-pyinterp";
102 changelog = "https://github.com/CNES/pangeo-pyinterp/releases/tag/${src.tag}";
103 license = lib.licenses.bsd3;
104 maintainers = with lib.maintainers; [ daspk04 ];
105 };
106}