1{
2 lib,
3 buildPythonPackage,
4 fetchPypi,
5 numpy,
6 pytestCheckHook,
7 setuptools,
8 wheel,
9}:
10
11buildPythonPackage rec {
12 pname = "numexpr";
13 version = "2.10.0";
14 pyproject = true;
15
16 src = fetchPypi {
17 inherit pname version;
18 hash = "sha256-yJ6TB1JjnfBAU5FgMm2PmahBWbvqQZQ6uOlgWR7arvA=";
19 };
20
21 # patch for compatibility with numpy < 2.0
22 # see more details, https://numpy.org/devdocs/numpy_2_0_migration_guide.html#c-api-changes
23 postPatch = ''
24 substituteInPlace pyproject.toml \
25 --replace-fail "numpy>=2.0.0rc1" "numpy"
26 sed -i "1i#define PyDataType_SET_ELSIZE(descr, elsize)" numexpr/interpreter.cpp
27 sed -i "1i#define PyDataType_ELSIZE(descr) ((descr)->elsize)" numexpr/interpreter.cpp
28 '';
29
30 build-system = [
31 setuptools
32 wheel
33 numpy
34 ];
35
36 dependencies = [ numpy ];
37
38 preBuild = ''
39 # Remove existing site.cfg, use the one we built for numpy
40 ln -s ${numpy.cfg} site.cfg
41 '';
42
43 nativeCheckInputs = [ pytestCheckHook ];
44
45 preCheck = ''
46 pushd $out
47 '';
48
49 postCheck = ''
50 popd
51 '';
52
53 disabledTests = [
54 # fails on computers with more than 8 threads
55 # https://github.com/pydata/numexpr/issues/479
56 "test_numexpr_max_threads_empty_string"
57 "test_omp_num_threads_empty_string"
58 ];
59
60 pythonImportsCheck = [ "numexpr" ];
61
62 meta = with lib; {
63 description = "Fast numerical array expression evaluator for NumPy";
64 homepage = "https://github.com/pydata/numexpr";
65 license = licenses.mit;
66 maintainers = [ ];
67 };
68}