1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 cons,
6 cython,
7 etuples,
8 fetchFromGitHub,
9 filelock,
10 hatch-vcs,
11 hatchling,
12 jax,
13 jaxlib,
14 logical-unification,
15 minikanren,
16 numba,
17 numba-scipy,
18 numpy,
19 pytestCheckHook,
20 pythonAtLeast,
21 pythonOlder,
22 scipy,
23 typing-extensions,
24}:
25
26buildPythonPackage rec {
27 pname = "aesara";
28 version = "2.9.3";
29 pyproject = true;
30
31 # Python 3.12 is not supported: https://github.com/aesara-devs/aesara/issues/1520
32 disabled = pythonOlder "3.8" || pythonAtLeast "3.12";
33
34 src = fetchFromGitHub {
35 owner = "aesara-devs";
36 repo = "aesara";
37 rev = "refs/tags/rel-${version}";
38 hash = "sha256-aO0+O7Ts9phsV4ghunNolxfAruGBbC+tHjVkmFedcCI=";
39 };
40
41 build-system = [
42 cython
43 hatch-vcs
44 hatchling
45 ];
46
47 dependencies = [
48 cons
49 etuples
50 filelock
51 logical-unification
52 minikanren
53 numpy
54 scipy
55 typing-extensions
56 ];
57
58 nativeCheckInputs = [
59 jax
60 jaxlib
61 numba
62 numba-scipy
63 pytestCheckHook
64 ];
65
66 postPatch = ''
67 substituteInPlace pyproject.toml \
68 --replace-fail "--durations=50" "" \
69 --replace-fail "hatch-vcs >=0.3.0,<0.4.0" "hatch-vcs"
70 '';
71
72 preBuild = ''
73 export HOME=$(mktemp -d)
74 '';
75
76 pythonImportsCheck = [ "aesara" ];
77
78 disabledTestPaths = [
79 # Don't run the most compute-intense tests
80 "tests/scan/"
81 "tests/tensor/"
82 "tests/sandbox/"
83 "tests/sparse/sandbox/"
84 # JAX is not available on all platform and often broken
85 "tests/link/jax/"
86
87 # 2024-04-27: The current nixpkgs numba version is too recent and incompatible with aesara 2.9.3
88 "tests/link/numba/"
89 ];
90
91 disabledTests = [
92 # Disable all benchmark tests
93 "test_scan_multiple_output"
94 "test_logsumexp_benchmark"
95
96 # TypeError: exceptions must be derived from Warning, not <class 'NoneType'>
97 "test_api_deprecation_warning"
98 # AssertionError: assert ['Elemwise{Co..._i{0} 0', ...] == ['Elemwise{Co..._i{0} 0', ...]
99 # At index 3 diff: '| |Gemv{inplace} d={0: [0]} 2' != '| |CGemv{inplace} d={0: [0]} 2'
100 "test_debugprint"
101 # ValueError: too many values to unpack (expected 3)
102 "test_ExternalCOp_c_code_cache_version"
103 ];
104
105 meta = with lib; {
106 description = "Python library to define, optimize, and efficiently evaluate mathematical expressions involving multi-dimensional arrays";
107 homepage = "https://github.com/aesara-devs/aesara";
108 changelog = "https://github.com/aesara-devs/aesara/releases/tag/rel-${version}";
109 license = licenses.bsd3;
110 maintainers = with maintainers; [ Etjean ];
111 broken = (stdenv.isLinux && stdenv.isAarch64);
112 };
113}