Unverified Commit 84408fbf authored by Weijia Wang's avatar Weijia Wang Committed by GitHub
Browse files

Merge pull request #311196 from TomaSajt/gmpy-and-friends

python3Packages.{gmpy,gmpy2,phe}: bump version, refactor, adopt
parents 3c79060a cac738c3
Loading
Loading
Loading
Loading
+21 −10
Original line number Diff line number Diff line
{ buildPythonPackage, fetchurl, isPyPy, gmp, pythonAtLeast } :
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,
  isPyPy,
  pythonAtLeast,
  setuptools,
  gmp,
}:

let
buildPythonPackage rec {
  pname = "gmpy";
  version = "1.17";
  format = "setuptools";
in

buildPythonPackage {
  inherit pname version;
  pyproject = true;

  # Python 3.11 has finally made changes to its C API for which gmpy 1.17,
  # published in 2013, would require patching. It seems unlikely that any
  # patches will be forthcoming.
  disabled = isPyPy || pythonAtLeast "3.11";

  src = fetchurl {
    url = "mirror://pypi/g/gmpy/${pname}-${version}.zip";
    sha256 = "1a79118a5332b40aba6aa24b051ead3a31b9b3b9642288934da754515da8fa14";
  src = fetchFromGitHub {
    owner = "aleaxit";
    repo = "gmpy";
    rev = "refs/tags/gmpy_${lib.replaceStrings [ "." ] [ "_" ] version}";
    hash = "sha256-kMidOjhKJlDRu2qaiq9c+XcwD1tNAoPhRTvvGcOJe8I=";
  };

  build-system = [ setuptools ];

  buildInputs = [ gmp ];

  pythonImportsCheck = [ "gmpy" ];

  meta = {
    description = "GMP or MPIR interface to Python 2.4+ and 3.x";
    homepage = "https://github.com/aleaxit/gmpy/";
    license = lib.licenses.lgpl21Plus;
  };
}
+56 −25
Original line number Diff line number Diff line
{ lib
, buildPythonPackage
, fetchFromGitHub
, isPyPy
, gmp
, mpfr
, libmpc

{
  lib,
  stdenv,
  buildPythonPackage,
  fetchFromGitHub,
  isPyPy,
  pythonOlder,
  setuptools,
  gmp,
  mpfr,
  libmpc,
  pytestCheckHook,
  hypothesis,
  cython,
  mpmath,
  # Reverse dependency
, sage
  sage,
}:

let
buildPythonPackage rec {
  pname = "gmpy2";
  version = "2.1.2";
  format = "setuptools";
in

buildPythonPackage {
  inherit pname version;
  version = "2.2.0a2";
  pyproject = true;

  disabled = isPyPy;
  disabled = isPyPy || pythonOlder "3.7";

  src = fetchFromGitHub {
    owner = "aleaxit";
    repo = "gmpy";
    rev = "gmpy2-${version}";
    hash = "sha256-ARCttNzRA+Ji2j2NYaSCDXgvoEg01T9BnYadyqON2o0=";
    rev = "refs/tags/gmpy2-${version}";
    hash = "sha256-luLEDEY1cezhzZo4fXmM/MUg2YyAaz7n0HwSpbNayP8=";
  };

  buildInputs = [ gmp mpfr libmpc ];
  build-system = [ setuptools ];

  buildInputs = [
    gmp
    mpfr
    libmpc
  ];

  # make relative imports in tests work properly
  preCheck = ''
    rm gmpy2 -r
  '';

  nativeCheckInputs = [
    pytestCheckHook
    hypothesis
    cython
    mpmath
  ];

  disabledTests = lib.optionals (stdenv.isLinux && stdenv.isAarch64) [
    # issue with some overflow logic
    "test_mpz_to_bytes"
    "test_mpz_from_bytes"
  ];

  pythonImportsCheck = [ "gmpy2" ];

  passthru.tests = { inherit sage; };
  passthru.tests = {
    inherit sage;
  };

  meta = with lib; {
    description = "GMP/MPIR, MPFR, and MPC interface to Python 2.6+ and 3.x";
  meta = {
    changelog = "https://github.com/aleaxit/gmpy/blob/${src.rev}/docs/history.rst";
    description = "Interface to GMP, MPFR, and MPC for Python 3.7+";
    homepage = "https://github.com/aleaxit/gmpy/";
    license = licenses.gpl3Plus;
    license = lib.licenses.lgpl3Plus;
    maintainers = with lib.maintainers; [ tomasajt ];
  };
}
+33 −16
Original line number Diff line number Diff line
{ lib, buildPythonPackage, fetchPypi, isPyPy, isPy3k, click, gmpy2, numpy } :
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,
  isPyPy,
  isPy3k,
  setuptools,
  click,
  gmpy2,
  pytestCheckHook,
  numpy,
}:

let
buildPythonPackage rec {
  pname = "phe";
  version = "1.5.0";
  format = "setuptools";
in
  pyproject = true;

buildPythonPackage {
  inherit pname version;

  # https://github.com/n1analytics/python-paillier/issues/51
  # https://github.com/data61/python-paillier/issues/51
  disabled = isPyPy || !isPy3k;

  src = fetchPypi {
    inherit pname version;
    hash = "sha256-mS+3CR0kJ/DZczlG+PNQrN1NHQEgV/Kq02S6eflwM5w=";
  src = fetchFromGitHub {
    owner = "data61";
    repo = "python-paillier";
    rev = "refs/tags/${version}";
    hash = "sha256-fsZ8x/K+8V4zyVgkci6XNAm89zQFWEbmRVp4jazFfVY=";
  };

  buildInputs = [ click gmpy2 numpy ];
  build-system = [ setuptools ];

  dependencies = [
    click
    gmpy2 # optional, but major speed improvement
  ];

  # 29/233 tests fail
  doCheck = false;
  nativeCheckInputs = [
    pytestCheckHook
    numpy
  ];

  meta = with lib; {
    description = "A library for Partially Homomorphic Encryption in Python";
    mainProgram = "pheutil";
    homepage = "https://github.com/n1analytics/python-paillier";
    homepage = "https://github.com/data61/python-paillier";
    license = licenses.gpl3;
    maintainers = with maintainers; [ tomasajt ];
  };
}