1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 fetchpatch,
6 cython,
7 cmake,
8 symengine,
9 pytest,
10 sympy,
11 python,
12 setuptools,
13}:
14
15buildPythonPackage rec {
16 pname = "symengine";
17 version = "0.11.0";
18
19 build-system = [ setuptools ];
20 pyproject = true;
21
22 src = fetchFromGitHub {
23 owner = "symengine";
24 repo = "symengine.py";
25 rev = "refs/tags/v${version}";
26 hash = "sha256-uUMcNnynE2itIwc7IGFwxveqLRL8f4dAAcaD6FUWJaY=";
27 };
28
29 env = {
30 SymEngine_DIR = "${symengine}";
31 };
32
33 patches = [
34 # Distutils has been removed in python 3.12
35 # See https://github.com/symengine/symengine.py/pull/478
36 (fetchpatch {
37 name = "no-distutils.patch";
38 url = "https://github.com/symengine/symengine.py/pull/478/commits/e72006d5f7425cd50c54b22766e0ed4bcd2dca85.patch";
39 hash = "sha256-kGJRGkBgxOfI1wf88JwnSztkOYd1wvg62H7wA6CcYEQ=";
40 })
41 ];
42
43 postPatch = ''
44 substituteInPlace setup.py \
45 --replace-fail "\"cmake\"" "\"${lib.getExe' cmake "cmake"}\"" \
46 --replace-fail "'cython>=0.29.24'" "'cython'"
47
48 export PATH=${cython}/bin:$PATH
49 '';
50
51 nativeBuildUnputs = [ cmake ];
52
53 buildInputs = [ cython ];
54
55 nativeCheckInputs = [
56 pytest
57 sympy
58 ];
59
60 checkPhase = ''
61 mkdir empty && cd empty
62 ${python.interpreter} ../bin/test_python.py
63 '';
64
65 meta = with lib; {
66 description = "Python library providing wrappers to SymEngine";
67 homepage = "https://github.com/symengine/symengine.py";
68 license = licenses.mit;
69 maintainers = [ ];
70 };
71}