1{
2 lib,
3 python,
4 buildPythonPackage,
5 fetchFromGitHub,
6 fetchurl,
7 setuptools,
8 cython,
9 bash,
10 perl,
11 gnum4,
12 texliveBasic,
13}:
14
15let
16 pariVersion = "2.15.4";
17 gmpVersion = "6.3.0";
18
19 pariSrc = fetchurl {
20 url = "https://pari.math.u-bordeaux.fr/pub/pari/OLD/${lib.versions.majorMinor pariVersion}/pari-${pariVersion}.tar.gz";
21 hash = "sha256-w1Rb/uDG37QLd/tLurr5mdguYAabn20ovLbPAEyMXA8=";
22 };
23
24 gmpSrc = fetchurl {
25 url = "https://ftp.gnu.org/gnu/gmp/gmp-${gmpVersion}.tar.bz2";
26 hash = "sha256-rCghGnz7YJuuLiyNYFjWbI/pZDT3QM9v4uR7AA0cIMs=";
27 };
28in
29buildPythonPackage rec {
30 pname = "cypari";
31 version = "2.5.5";
32 pyproject = true;
33
34 src = fetchFromGitHub {
35 owner = "3-manifolds";
36 repo = "CyPari";
37 tag = "${version}_as_released";
38 hash = "sha256-RJ9O1KsDHmMkTCIFUrcSUkA5ijTsxmoI939QCsCib0Y=";
39 };
40
41 postPatch = ''
42 substituteInPlace ./setup.py \
43 --replace-fail "/bin/bash" "${lib.getExe bash}"
44 # final character is stripped from PARI error messages for some reason
45 substituteInPlace ./cypari/handle_error.pyx \
46 --replace-fail "not a function in function call" "not a function in function cal"
47 ln -s ${pariSrc} ${pariSrc.name}
48 ln -s ${gmpSrc} ${gmpSrc.name}
49 '';
50
51 build-system = [
52 setuptools
53 cython
54 ];
55
56 NIX_LDFLAGS = "-lc";
57
58 nativeBuildInputs = [
59 gnum4
60 perl
61 texliveBasic
62 ];
63
64 pythonImportsCheck = [ "cypari" ];
65
66 checkPhase = ''
67 runHook preCheck
68 rm -r cypari
69 ${python.interpreter} -m cypari.test
70 runHook postCheck
71 '';
72
73 meta = {
74 description = "Sage's PARI extension, modified to stand alone";
75 homepage = "https://github.com/3-manifolds/CyPari";
76 license = lib.licenses.gpl2Plus;
77 maintainers = with lib.maintainers; [ noiioiu ];
78 changelog = "https://github.com/3-manifolds/CyPari/releases/tag/${src.tag}";
79 };
80}