diff --git a/pkgs/development/python-modules/cypari/default.nix b/pkgs/development/python-modules/cypari/default.nix new file mode 100644 index 000000000000..da8e988829ad --- /dev/null +++ b/pkgs/development/python-modules/cypari/default.nix @@ -0,0 +1,80 @@ +{ + lib, + python, + buildPythonPackage, + fetchFromGitHub, + fetchurl, + setuptools, + cython, + bash, + perl, + gnum4, + texliveBasic, +}: + +let + pariVersion = "2.15.4"; + gmpVersion = "6.3.0"; + + pariSrc = fetchurl { + url = "https://pari.math.u-bordeaux.fr/pub/pari/OLD/${lib.versions.majorMinor pariVersion}/pari-${pariVersion}.tar.gz"; + hash = "sha256-w1Rb/uDG37QLd/tLurr5mdguYAabn20ovLbPAEyMXA8="; + }; + + gmpSrc = fetchurl { + url = "https://ftp.gnu.org/gnu/gmp/gmp-${gmpVersion}.tar.bz2"; + hash = "sha256-rCghGnz7YJuuLiyNYFjWbI/pZDT3QM9v4uR7AA0cIMs="; + }; +in +buildPythonPackage rec { + pname = "cypari"; + version = "2.5.5"; + pyproject = true; + + src = fetchFromGitHub { + owner = "3-manifolds"; + repo = "CyPari"; + tag = "${version}_as_released"; + hash = "sha256-RJ9O1KsDHmMkTCIFUrcSUkA5ijTsxmoI939QCsCib0Y="; + }; + + postPatch = '' + substituteInPlace ./setup.py \ + --replace-fail "/bin/bash" "${lib.getExe bash}" + # final character is stripped from PARI error messages for some reason + substituteInPlace ./cypari/handle_error.pyx \ + --replace-fail "not a function in function call" "not a function in function cal" + ln -s ${pariSrc} ${pariSrc.name} + ln -s ${gmpSrc} ${gmpSrc.name} + ''; + + build-system = [ + setuptools + cython + ]; + + NIX_LDFLAGS = "-lc"; + + nativeBuildInputs = [ + gnum4 + perl + texliveBasic + ]; + + pythonImportsCheck = [ "cypari" ]; + + checkPhase = '' + runHook preCheck + rm -r cypari + ${python.interpreter} -m cypari.test + runHook postCheck + ''; + + meta = { + description = "Sage's PARI extension, modified to stand alone"; + homepage = "https://github.com/3-manifolds/CyPari"; + license = lib.licenses.gpl2Plus; + maintainers = with lib.maintainers; [ noiioiu ]; + changelog = "https://github.com/3-manifolds/CyPari/releases/tag/${src.tag}"; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index ec0e0cba8bd0..c3c6b1c512f7 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -3128,6 +3128,8 @@ self: super: with self; { cynthion = callPackage ../development/python-modules/cynthion { }; + cypari = callPackage ../development/python-modules/cypari { }; + cypari2 = callPackage ../development/python-modules/cypari2 { }; cypherpunkpay = callPackage ../development/python-modules/cypherpunkpay { };