1{ stdenv
2, buildPythonPackage
3, fetchFromGitHub
4, fetchpatch
5, isPyPy
6, gmp
7, mpfr
8, libmpc
9}:
10
11let
12 pname = "gmpy2";
13 version = "2.1a4";
14in
15
16buildPythonPackage {
17 inherit pname version;
18
19 disabled = isPyPy;
20
21 src = fetchFromGitHub {
22 owner = "aleaxit";
23 repo = "gmpy";
24 rev = "gmpy2-${version}";
25 sha256 = "1wg4w4q2l7n26ksrdh4rwqmifgfm32n7x29cgdvmmbv5lmilb5hz";
26 };
27
28 patches = [
29 # Backport of two bugfixes (including a segfault):
30 # https://github.com/aleaxit/gmpy/pull/217
31 # https://github.com/aleaxit/gmpy/pull/218
32 (fetchpatch {
33 name = "bugfixes.patch";
34 url = "https://git.sagemath.org/sage.git/plain/build/pkgs/gmpy2/patches/PR217_PR218_conversion_methods.patch?id=b7fbb9a4dac5d6882f6b83a57447dd79ecafb84c";
35 sha256 = "1x3gwvqac36k4ypclxq37fcvi6p790k4xdpm2bj2b3xsvjb80ycz";
36 })
37 ];
38
39 buildInputs = [ gmp mpfr libmpc ];
40
41 meta = with stdenv.lib; {
42 description = "GMP/MPIR, MPFR, and MPC interface to Python 2.6+ and 3.x";
43 homepage = "https://github.com/aleaxit/gmpy/";
44 license = licenses.gpl3Plus;
45 };
46}