1{ lib
2, buildPythonPackage
3, python
4, fetchpatch
5, fetchPypi
6, pari
7, gmp
8, cython
9, cysignals
10}:
11
12buildPythonPackage rec {
13 pname = "cypari2";
14 # upgrade may break sage, please test the sage build or ping @timokau on upgrade
15 version = "2.1.3";
16
17 src = fetchPypi {
18 inherit pname version;
19 sha256 = "17beb467d3cb39fffec3227c468f0dd8db8a09129faeb95a6bb4c84b2b6c6683";
20 };
21
22 patches = [
23 # patch to avoid some segfaults in sage's totallyreal.pyx test.
24 # (https://trac.sagemath.org/ticket/27267). depends on Cython patch.
25 (fetchpatch {
26 name = "use-trashcan-for-gen.patch";
27 url = "https://raw.githubusercontent.com/sagemath/sage/b6ea17ef8e4d652de0a85047bac8d41e90b25555/build/pkgs/cypari/patches/trashcan.patch";
28 hash = "sha256-w4kktWb9/aR9z4CjrUvAMOxEwRN2WkubaKzQttN8rU8=";
29 })
30 ];
31
32 # This differs slightly from the default python installPhase in that it pip-installs
33 # "." instead of "*.whl".
34 # That is because while the default install phase succeeds to build the package,
35 # it fails to generate the file "auto_paridecl.pxd".
36 installPhase = ''
37 export PYTHONPATH="$out/${python.sitePackages}:$PYTHONPATH"
38
39 # install "." instead of "*.whl"
40 pip install . --no-index --no-warn-script-location --prefix="$out" --no-cache
41 '';
42
43 nativeBuildInputs = [
44 pari
45 python.pythonOnBuildForHost.pkgs.pip
46 ];
47
48 buildInputs = [
49 gmp
50 ];
51
52 propagatedBuildInputs = [
53 cysignals
54 cython
55 ];
56
57 checkPhase = ''
58 make check
59 '';
60
61 meta = with lib; {
62 description = "Cython bindings for PARI";
63 license = licenses.gpl2Plus;
64 maintainers = teams.sage.members;
65 homepage = "https://github.com/defeo/cypari2";
66 };
67}