commit:     7bd30f9950b53bc733b5ec74f2d8cd2b7ab2c54a
Author:     Ekaterina Vaartis <vaartis <AT> kotobank <DOT> ch>
AuthorDate: Fri May 14 14:53:14 2021 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat May 15 11:51:28 2021 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7bd30f99

dev-python/gmpy: Bump to 2.1.0_beta5 and python 3.10

Signed-off-by: Ekaterina Vaartis <vaartis <AT> kotobank.ch>
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 dev-python/gmpy/Manifest                           |   1 +
 .../gmpy/files/gmpy-2.1.0_beta5-failed-tests.patch | 132 +++++++++++++++++++++
 .../gmpy/files/gmpy-2.1.0_beta5-pyhash-nan.patch   |  17 +++
 .../gmpy/files/gmpy-2.1.0_beta5-test-input.patch   |  12 ++
 dev-python/gmpy/gmpy-2.1.0_beta5.ebuild            |  53 +++++++++
 5 files changed, 215 insertions(+)

diff --git a/dev-python/gmpy/Manifest b/dev-python/gmpy/Manifest
index 16c5bf2552d..9c471701495 100644
--- a/dev-python/gmpy/Manifest
+++ b/dev-python/gmpy/Manifest
@@ -1 +1,2 @@
 DIST gmpy2-2.0.8.zip 280551 BLAKE2B 
b73c48b739ae6972231672ad28598c09e00db6348cd281d190c6dfcf49b0e977563baabe84825658d78bf1e2ac4927ad1882787b6d4efd19f28a4f7fd6a061b4
 SHA512 
090f449641f378c73eb166831b1d956c6cee3da83e42fde8741f18aa0fa687e37927fc3b045d4b35e3a3b75570e6b1074150d8bc29d16119ab5c717bcfcf9fb4
+DIST gmpy2-2.1.0b5.tar.gz 264742 BLAKE2B 
1dd6dc66f9ec8cb2738f449112aa44feb40ba983f6da5f7a0760016e79ffed19037d77d47c0c0b816f9088725207e50ba3bd423349ed4c744ff03059c4c6a19a
 SHA512 
7dc647642d7b61af77258881a7b91ab967dd11a86ba88ff5b7fd41cd4c999d2bb4cfe586511e79cc5f21f0f00d0823bbd2620d69df051c8cead15090423a657a

diff --git a/dev-python/gmpy/files/gmpy-2.1.0_beta5-failed-tests.patch 
b/dev-python/gmpy/files/gmpy-2.1.0_beta5-failed-tests.patch
new file mode 100644
index 00000000000..38a98579409
--- /dev/null
+++ b/dev-python/gmpy/files/gmpy-2.1.0_beta5-failed-tests.patch
@@ -0,0 +1,132 @@
+diff --git a/src/gmpy2_mpz.c b/src/gmpy2_mpz.c
+index e5087fa..66a297a 100644
+--- a/src/gmpy2_mpz.c
++++ b/src/gmpy2_mpz.c
+@@ -69,7 +69,7 @@ static PyNumberMethods GMPy_MPZ_number_methods =
+     (binaryfunc) GMPy_MPZ_ISub_Slot,       /* nb_inplace_subtract     */
+     (binaryfunc) GMPy_MPZ_IMul_Slot,       /* nb_inplace_multiply     */
+     (binaryfunc) GMPy_MPZ_IRem_Slot,       /* nb_inplace_remainder    */
+-    (ternaryfunc) GMPy_MPZ_IPow_Slot,      /* nb_inplace_power        */
++    0,      /* nb_inplace_power        */
+     (binaryfunc) GMPy_MPZ_ILshift_Slot,    /* nb_inplace_lshift       */
+     (binaryfunc) GMPy_MPZ_IRshift_Slot,    /* nb_inplace_rshift       */
+         0,                                 /* nb_inplace_and          */
+@@ -113,7 +113,7 @@ static PyNumberMethods GMPy_MPZ_number_methods =
+     (binaryfunc) GMPy_MPZ_IMul_Slot,       /* nb_inplace_multiply     */
+         0,                                 /* nb_inplace_divide       */
+     (binaryfunc) GMPy_MPZ_IRem_Slot,       /* nb_inplace_remainder    */
+-    (ternaryfunc) GMPy_MPZ_IPow_Slot,      /* nb_inplace_power        */
++    0,      /* nb_inplace_power        */
+     (binaryfunc) GMPy_MPZ_ILshift_Slot,    /* nb_inplace_lshift       */
+     (binaryfunc) GMPy_MPZ_IRshift_Slot,    /* nb_inplace_rshift       */
+         0,                                 /* nb_inplace_and          */
+@@ -229,4 +229,3 @@ static PyTypeObject MPZ_Type =
+     GMPy_MPZ_NewInit,                       /* tp_new           */
+         0,                                  /* tp_free          */
+ };
+-
+diff --git a/src/gmpy2_pow.c b/src/gmpy2_pow.c
+index ddcb43a..cf96470 100644
+--- a/src/gmpy2_pow.c
++++ b/src/gmpy2_pow.c
+@@ -98,8 +98,11 @@ GMPy_Integer_Pow(PyObject *b, PyObject *e, PyObject *m, 
CTXT_Object *context)
+         unsigned long el;
+ 
+         if (mpz_sgn(tempe->z) < 0) {
+-            VALUE_ERROR("pow() exponent cannot be negative");
+-            goto err;
++            Py_DECREF((PyObject*)result);
++            Py_DECREF((PyObject*)tempb);
++            Py_DECREF((PyObject*)tempe);
++
++            return GMPy_Real_Pow(b, e, m, context);
+         }
+ 
+         /* Catch -1, 0, 1 getting raised to large exponents. */
+diff --git a/src/gmpy2_xmpz_inplace.c b/src/gmpy2_xmpz_inplace.c
+index bbcd977..e5bbf09 100644
+--- a/src/gmpy2_xmpz_inplace.c
++++ b/src/gmpy2_xmpz_inplace.c
+@@ -271,14 +271,14 @@ GMPy_XMPZ_IPow_Slot(PyObject *self, PyObject *other, 
PyObject *mod)
+     mp_bitcnt_t exp;
+ 
+     exp = mp_bitcnt_t_From_Integer(other);
+-    if (exp == (mp_bitcnt_t)(-1) && PyErr_Occurred()) {
+-        PyErr_Clear();
+-        Py_RETURN_NOTIMPLEMENTED;
+-    }
++    if (exp == (mp_bitcnt_t)(-1) && PyErr_Occurred())
++        return NULL;
+ 
+     mpz_pow_ui(MPZ(self), MPZ(self), exp);
+     Py_INCREF((PyObject*)self);
+     return (PyObject*)self;
++
++    Py_RETURN_NOTIMPLEMENTED;
+ }
+ 
+ /* Inplace xmpz and.
+@@ -346,4 +346,3 @@ GMPy_XMPZ_IIor_Slot(PyObject *self, PyObject *other)
+ 
+     Py_RETURN_NOTIMPLEMENTED;
+ }
+-
+diff --git a/test/test_gmpy2_mpz_inplace.txt b/test/test_gmpy2_mpz_inplace.txt
+index e7a8b96..147118c 100644
+--- a/test/test_gmpy2_mpz_inplace.txt
++++ b/test/test_gmpy2_mpz_inplace.txt
+@@ -147,18 +147,16 @@ Test ipow operator
+ mpz(25)
+ >>> x **= xmpz(2); x
+ mpz(625)
+->>> x **= -2
+-Traceback (most recent call last):
+-  File "<stdin>", line 1, in <module>
+-TypeError: unsupported operand type(s) for ** or pow(): 'mpz' and 'int'
++>>> x **= -2; x
++mpfr('2.5600000000000001e-06')
++>>> x = mpz(625)
+ >>> x **= 2; x
+ mpz(390625)
+->>> x **= mpfr(2)
+-Traceback (most recent call last):
+-  File "<stdin>", line 1, in <module>
+-TypeError: unsupported operand type(s) for ** or pow(): 'mpz' and 'mpfr'
+->>> 1
+-1
++>>> x **= mpfr(2); x
++mpfr('152587890625.0')
++>>> x = mpz(390625)
++>>> x **= mpfr(-2); x
++mpfr('6.5535999999999999e-12')
+ 
+ Test iand operator
+ ------------------
+diff --git a/test/test_gmpy2_pow.txt b/test/test_gmpy2_pow.txt
+index 89bd876..d5b1f45 100644
+--- a/test/test_gmpy2_pow.txt
++++ b/test/test_gmpy2_pow.txt
+@@ -15,9 +15,7 @@ mpz(25)
+ >>> ctx.pow(z1, z2)
+ mpz(25)
+ >>> z1 ** -z2
+-Traceback (most recent call last):
+-  File "<stdin>", line 1, in <module>
+-ValueError: pow() exponent cannot be negative
++mpfr('0.040000000000000001')
+ >>> z1 ** 0
+ mpz(1)
+ >>> mpz(0) ** 32
+diff --git a/test/test_gmpy2_xmpz_inplace.txt 
b/test/test_gmpy2_xmpz_inplace.txt
+index 94f86b7..c02f966 100644
+--- a/test/test_gmpy2_xmpz_inplace.txt
++++ b/test/test_gmpy2_xmpz_inplace.txt
+@@ -135,7 +135,7 @@ xmpz(625)
+ >>> x **= -2
+ Traceback (most recent call last):
+   File "<stdin>", line 1, in <module>
+-TypeError: unsupported operand type(s) for ** or pow(): 'xmpz' and 'int'
++ValueError: a non-negative value is required
+ >>> x **= 2; x
+ xmpz(390625)
+ >>> x **= mpfr(2)

diff --git a/dev-python/gmpy/files/gmpy-2.1.0_beta5-pyhash-nan.patch 
b/dev-python/gmpy/files/gmpy-2.1.0_beta5-pyhash-nan.patch
new file mode 100644
index 00000000000..9f59a6096fc
--- /dev/null
+++ b/dev-python/gmpy/files/gmpy-2.1.0_beta5-pyhash-nan.patch
@@ -0,0 +1,17 @@
+diff --git a/src/gmpy2_hash.c b/src/gmpy2_hash.c
+index f276a42..1d2bfd1 100644
+--- a/src/gmpy2_hash.c
++++ b/src/gmpy2_hash.c
+@@ -147,7 +147,12 @@ _mpfr_hash(mpfr_t f)
+             }
+         }
+         else {
++#if PY_VERSION_HEX >= 0x030A00A0
++            // Python 3.10
++            return _Py_HashPointer(f);
++#else
+             return _PyHASH_NAN;
++#endif
+         }
+     }
+ 

diff --git a/dev-python/gmpy/files/gmpy-2.1.0_beta5-test-input.patch 
b/dev-python/gmpy/files/gmpy-2.1.0_beta5-test-input.patch
new file mode 100644
index 00000000000..16705d917c9
--- /dev/null
+++ b/dev-python/gmpy/files/gmpy-2.1.0_beta5-test-input.patch
@@ -0,0 +1,12 @@
+diff --git a/test/runtests.py b/test/runtests.py
+index 5e5842d..7d64e52 100644
+--- a/test/runtests.py
++++ b/test/runtests.py
+@@ -81,7 +81,6 @@ if sys.version.startswith('3.1.'):
+     print("with Python 3.1. The doctest module in Python 3.2 and later does 
not")
+     print("have this issue.")
+     print()
+-    input("Press ENTER to continue.. ")
+     print()
+ 
+ mpz_doctests = ["test_mpz_create.txt", "test_mpz.txt", "test_mpz_io.txt",

diff --git a/dev-python/gmpy/gmpy-2.1.0_beta5.ebuild 
b/dev-python/gmpy/gmpy-2.1.0_beta5.ebuild
new file mode 100644
index 00000000000..739475e74e0
--- /dev/null
+++ b/dev-python/gmpy/gmpy-2.1.0_beta5.ebuild
@@ -0,0 +1,53 @@
+# Copyright 1999-2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+PYTHON_COMPAT=( python3_{7..10} )
+inherit distutils-r1
+
+MY_PN="${PN}2"
+MY_P="${MY_PN}-${PV/_beta/b}"
+
+DESCRIPTION="Python bindings for GMP, MPC, MPFR and MPIR libraries"
+HOMEPAGE="https://github.com/aleaxit/gmpy";
+SRC_URI="mirror://pypi/${PN:0:1}/${MY_PN}/${MY_P}.tar.gz"
+S="${WORKDIR}"/${MY_P}
+
+LICENSE="LGPL-3+"
+SLOT="2"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc 
~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos"
+IUSE="mpir"
+
+RDEPEND="
+       >=dev-libs/mpc-1.0.2:=
+       >=dev-libs/mpfr-3.1.2:=
+       !mpir? ( dev-libs/gmp:0= )
+       mpir? ( sci-libs/mpir:= )"
+DEPEND="${RDEPEND}"
+
+PATCHES=(
+       # In python 3.10 _PyHASH_NAN was removed and its usage replaced with 
_Py_HashPointer
+       # see https://github.com/python/cpython/blob/3.10/Python/pyhash.c
+       # https://github.com/aleaxit/gmpy/pull/297
+       "${FILESDIR}"/${P}-pyhash-nan.patch
+       # The tests program asks for input when running, disable that
+       "${FILESDIR}"/${P}-test-input.patch
+       # Based on this commit:
+       # 
https://github.com/aleaxit/gmpy/commit/db7ce2ef46fab84e7b9c32b05725e9b02e8cf206
+       "${FILESDIR}"/${P}-failed-tests.patch
+)
+
+distutils_enable_sphinx docs
+
+python_configure_all() {
+       mydistutilsargs=(
+               # GMP is the default, add mpir if the USE flag is set
+               $(usex mpir --mpir "")
+       )
+}
+
+python_test() {
+       cd test || die
+       "${EPYTHON}" runtests.py || die "tests failed under ${EPYTHON}"
+}

Reply via email to