Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-python/gmpy/files/, dev-python/gmpy/
Date: Sat, 15 May 2021 11:51:40
Message-Id: 1621079488.7bd30f9950b53bc733b5ec74f2d8cd2b7ab2c54a.mgorny@gentoo
1 commit: 7bd30f9950b53bc733b5ec74f2d8cd2b7ab2c54a
2 Author: Ekaterina Vaartis <vaartis <AT> kotobank <DOT> ch>
3 AuthorDate: Fri May 14 14:53:14 2021 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Sat May 15 11:51:28 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7bd30f99
7
8 dev-python/gmpy: Bump to 2.1.0_beta5 and python 3.10
9
10 Signed-off-by: Ekaterina Vaartis <vaartis <AT> kotobank.ch>
11 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
12
13 dev-python/gmpy/Manifest | 1 +
14 .../gmpy/files/gmpy-2.1.0_beta5-failed-tests.patch | 132 +++++++++++++++++++++
15 .../gmpy/files/gmpy-2.1.0_beta5-pyhash-nan.patch | 17 +++
16 .../gmpy/files/gmpy-2.1.0_beta5-test-input.patch | 12 ++
17 dev-python/gmpy/gmpy-2.1.0_beta5.ebuild | 53 +++++++++
18 5 files changed, 215 insertions(+)
19
20 diff --git a/dev-python/gmpy/Manifest b/dev-python/gmpy/Manifest
21 index 16c5bf2552d..9c471701495 100644
22 --- a/dev-python/gmpy/Manifest
23 +++ b/dev-python/gmpy/Manifest
24 @@ -1 +1,2 @@
25 DIST gmpy2-2.0.8.zip 280551 BLAKE2B b73c48b739ae6972231672ad28598c09e00db6348cd281d190c6dfcf49b0e977563baabe84825658d78bf1e2ac4927ad1882787b6d4efd19f28a4f7fd6a061b4 SHA512 090f449641f378c73eb166831b1d956c6cee3da83e42fde8741f18aa0fa687e37927fc3b045d4b35e3a3b75570e6b1074150d8bc29d16119ab5c717bcfcf9fb4
26 +DIST gmpy2-2.1.0b5.tar.gz 264742 BLAKE2B 1dd6dc66f9ec8cb2738f449112aa44feb40ba983f6da5f7a0760016e79ffed19037d77d47c0c0b816f9088725207e50ba3bd423349ed4c744ff03059c4c6a19a SHA512 7dc647642d7b61af77258881a7b91ab967dd11a86ba88ff5b7fd41cd4c999d2bb4cfe586511e79cc5f21f0f00d0823bbd2620d69df051c8cead15090423a657a
27
28 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
29 new file mode 100644
30 index 00000000000..38a98579409
31 --- /dev/null
32 +++ b/dev-python/gmpy/files/gmpy-2.1.0_beta5-failed-tests.patch
33 @@ -0,0 +1,132 @@
34 +diff --git a/src/gmpy2_mpz.c b/src/gmpy2_mpz.c
35 +index e5087fa..66a297a 100644
36 +--- a/src/gmpy2_mpz.c
37 ++++ b/src/gmpy2_mpz.c
38 +@@ -69,7 +69,7 @@ static PyNumberMethods GMPy_MPZ_number_methods =
39 + (binaryfunc) GMPy_MPZ_ISub_Slot, /* nb_inplace_subtract */
40 + (binaryfunc) GMPy_MPZ_IMul_Slot, /* nb_inplace_multiply */
41 + (binaryfunc) GMPy_MPZ_IRem_Slot, /* nb_inplace_remainder */
42 +- (ternaryfunc) GMPy_MPZ_IPow_Slot, /* nb_inplace_power */
43 ++ 0, /* nb_inplace_power */
44 + (binaryfunc) GMPy_MPZ_ILshift_Slot, /* nb_inplace_lshift */
45 + (binaryfunc) GMPy_MPZ_IRshift_Slot, /* nb_inplace_rshift */
46 + 0, /* nb_inplace_and */
47 +@@ -113,7 +113,7 @@ static PyNumberMethods GMPy_MPZ_number_methods =
48 + (binaryfunc) GMPy_MPZ_IMul_Slot, /* nb_inplace_multiply */
49 + 0, /* nb_inplace_divide */
50 + (binaryfunc) GMPy_MPZ_IRem_Slot, /* nb_inplace_remainder */
51 +- (ternaryfunc) GMPy_MPZ_IPow_Slot, /* nb_inplace_power */
52 ++ 0, /* nb_inplace_power */
53 + (binaryfunc) GMPy_MPZ_ILshift_Slot, /* nb_inplace_lshift */
54 + (binaryfunc) GMPy_MPZ_IRshift_Slot, /* nb_inplace_rshift */
55 + 0, /* nb_inplace_and */
56 +@@ -229,4 +229,3 @@ static PyTypeObject MPZ_Type =
57 + GMPy_MPZ_NewInit, /* tp_new */
58 + 0, /* tp_free */
59 + };
60 +-
61 +diff --git a/src/gmpy2_pow.c b/src/gmpy2_pow.c
62 +index ddcb43a..cf96470 100644
63 +--- a/src/gmpy2_pow.c
64 ++++ b/src/gmpy2_pow.c
65 +@@ -98,8 +98,11 @@ GMPy_Integer_Pow(PyObject *b, PyObject *e, PyObject *m, CTXT_Object *context)
66 + unsigned long el;
67 +
68 + if (mpz_sgn(tempe->z) < 0) {
69 +- VALUE_ERROR("pow() exponent cannot be negative");
70 +- goto err;
71 ++ Py_DECREF((PyObject*)result);
72 ++ Py_DECREF((PyObject*)tempb);
73 ++ Py_DECREF((PyObject*)tempe);
74 ++
75 ++ return GMPy_Real_Pow(b, e, m, context);
76 + }
77 +
78 + /* Catch -1, 0, 1 getting raised to large exponents. */
79 +diff --git a/src/gmpy2_xmpz_inplace.c b/src/gmpy2_xmpz_inplace.c
80 +index bbcd977..e5bbf09 100644
81 +--- a/src/gmpy2_xmpz_inplace.c
82 ++++ b/src/gmpy2_xmpz_inplace.c
83 +@@ -271,14 +271,14 @@ GMPy_XMPZ_IPow_Slot(PyObject *self, PyObject *other, PyObject *mod)
84 + mp_bitcnt_t exp;
85 +
86 + exp = mp_bitcnt_t_From_Integer(other);
87 +- if (exp == (mp_bitcnt_t)(-1) && PyErr_Occurred()) {
88 +- PyErr_Clear();
89 +- Py_RETURN_NOTIMPLEMENTED;
90 +- }
91 ++ if (exp == (mp_bitcnt_t)(-1) && PyErr_Occurred())
92 ++ return NULL;
93 +
94 + mpz_pow_ui(MPZ(self), MPZ(self), exp);
95 + Py_INCREF((PyObject*)self);
96 + return (PyObject*)self;
97 ++
98 ++ Py_RETURN_NOTIMPLEMENTED;
99 + }
100 +
101 + /* Inplace xmpz and.
102 +@@ -346,4 +346,3 @@ GMPy_XMPZ_IIor_Slot(PyObject *self, PyObject *other)
103 +
104 + Py_RETURN_NOTIMPLEMENTED;
105 + }
106 +-
107 +diff --git a/test/test_gmpy2_mpz_inplace.txt b/test/test_gmpy2_mpz_inplace.txt
108 +index e7a8b96..147118c 100644
109 +--- a/test/test_gmpy2_mpz_inplace.txt
110 ++++ b/test/test_gmpy2_mpz_inplace.txt
111 +@@ -147,18 +147,16 @@ Test ipow operator
112 + mpz(25)
113 + >>> x **= xmpz(2); x
114 + mpz(625)
115 +->>> x **= -2
116 +-Traceback (most recent call last):
117 +- File "<stdin>", line 1, in <module>
118 +-TypeError: unsupported operand type(s) for ** or pow(): 'mpz' and 'int'
119 ++>>> x **= -2; x
120 ++mpfr('2.5600000000000001e-06')
121 ++>>> x = mpz(625)
122 + >>> x **= 2; x
123 + mpz(390625)
124 +->>> x **= mpfr(2)
125 +-Traceback (most recent call last):
126 +- File "<stdin>", line 1, in <module>
127 +-TypeError: unsupported operand type(s) for ** or pow(): 'mpz' and 'mpfr'
128 +->>> 1
129 +-1
130 ++>>> x **= mpfr(2); x
131 ++mpfr('152587890625.0')
132 ++>>> x = mpz(390625)
133 ++>>> x **= mpfr(-2); x
134 ++mpfr('6.5535999999999999e-12')
135 +
136 + Test iand operator
137 + ------------------
138 +diff --git a/test/test_gmpy2_pow.txt b/test/test_gmpy2_pow.txt
139 +index 89bd876..d5b1f45 100644
140 +--- a/test/test_gmpy2_pow.txt
141 ++++ b/test/test_gmpy2_pow.txt
142 +@@ -15,9 +15,7 @@ mpz(25)
143 + >>> ctx.pow(z1, z2)
144 + mpz(25)
145 + >>> z1 ** -z2
146 +-Traceback (most recent call last):
147 +- File "<stdin>", line 1, in <module>
148 +-ValueError: pow() exponent cannot be negative
149 ++mpfr('0.040000000000000001')
150 + >>> z1 ** 0
151 + mpz(1)
152 + >>> mpz(0) ** 32
153 +diff --git a/test/test_gmpy2_xmpz_inplace.txt b/test/test_gmpy2_xmpz_inplace.txt
154 +index 94f86b7..c02f966 100644
155 +--- a/test/test_gmpy2_xmpz_inplace.txt
156 ++++ b/test/test_gmpy2_xmpz_inplace.txt
157 +@@ -135,7 +135,7 @@ xmpz(625)
158 + >>> x **= -2
159 + Traceback (most recent call last):
160 + File "<stdin>", line 1, in <module>
161 +-TypeError: unsupported operand type(s) for ** or pow(): 'xmpz' and 'int'
162 ++ValueError: a non-negative value is required
163 + >>> x **= 2; x
164 + xmpz(390625)
165 + >>> x **= mpfr(2)
166
167 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
168 new file mode 100644
169 index 00000000000..9f59a6096fc
170 --- /dev/null
171 +++ b/dev-python/gmpy/files/gmpy-2.1.0_beta5-pyhash-nan.patch
172 @@ -0,0 +1,17 @@
173 +diff --git a/src/gmpy2_hash.c b/src/gmpy2_hash.c
174 +index f276a42..1d2bfd1 100644
175 +--- a/src/gmpy2_hash.c
176 ++++ b/src/gmpy2_hash.c
177 +@@ -147,7 +147,12 @@ _mpfr_hash(mpfr_t f)
178 + }
179 + }
180 + else {
181 ++#if PY_VERSION_HEX >= 0x030A00A0
182 ++ // Python 3.10
183 ++ return _Py_HashPointer(f);
184 ++#else
185 + return _PyHASH_NAN;
186 ++#endif
187 + }
188 + }
189 +
190
191 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
192 new file mode 100644
193 index 00000000000..16705d917c9
194 --- /dev/null
195 +++ b/dev-python/gmpy/files/gmpy-2.1.0_beta5-test-input.patch
196 @@ -0,0 +1,12 @@
197 +diff --git a/test/runtests.py b/test/runtests.py
198 +index 5e5842d..7d64e52 100644
199 +--- a/test/runtests.py
200 ++++ b/test/runtests.py
201 +@@ -81,7 +81,6 @@ if sys.version.startswith('3.1.'):
202 + print("with Python 3.1. The doctest module in Python 3.2 and later does not")
203 + print("have this issue.")
204 + print()
205 +- input("Press ENTER to continue.. ")
206 + print()
207 +
208 + mpz_doctests = ["test_mpz_create.txt", "test_mpz.txt", "test_mpz_io.txt",
209
210 diff --git a/dev-python/gmpy/gmpy-2.1.0_beta5.ebuild b/dev-python/gmpy/gmpy-2.1.0_beta5.ebuild
211 new file mode 100644
212 index 00000000000..739475e74e0
213 --- /dev/null
214 +++ b/dev-python/gmpy/gmpy-2.1.0_beta5.ebuild
215 @@ -0,0 +1,53 @@
216 +# Copyright 1999-2021 Gentoo Authors
217 +# Distributed under the terms of the GNU General Public License v2
218 +
219 +EAPI=7
220 +
221 +PYTHON_COMPAT=( python3_{7..10} )
222 +inherit distutils-r1
223 +
224 +MY_PN="${PN}2"
225 +MY_P="${MY_PN}-${PV/_beta/b}"
226 +
227 +DESCRIPTION="Python bindings for GMP, MPC, MPFR and MPIR libraries"
228 +HOMEPAGE="https://github.com/aleaxit/gmpy"
229 +SRC_URI="mirror://pypi/${PN:0:1}/${MY_PN}/${MY_P}.tar.gz"
230 +S="${WORKDIR}"/${MY_P}
231 +
232 +LICENSE="LGPL-3+"
233 +SLOT="2"
234 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos"
235 +IUSE="mpir"
236 +
237 +RDEPEND="
238 + >=dev-libs/mpc-1.0.2:=
239 + >=dev-libs/mpfr-3.1.2:=
240 + !mpir? ( dev-libs/gmp:0= )
241 + mpir? ( sci-libs/mpir:= )"
242 +DEPEND="${RDEPEND}"
243 +
244 +PATCHES=(
245 + # In python 3.10 _PyHASH_NAN was removed and its usage replaced with _Py_HashPointer
246 + # see https://github.com/python/cpython/blob/3.10/Python/pyhash.c
247 + # https://github.com/aleaxit/gmpy/pull/297
248 + "${FILESDIR}"/${P}-pyhash-nan.patch
249 + # The tests program asks for input when running, disable that
250 + "${FILESDIR}"/${P}-test-input.patch
251 + # Based on this commit:
252 + # https://github.com/aleaxit/gmpy/commit/db7ce2ef46fab84e7b9c32b05725e9b02e8cf206
253 + "${FILESDIR}"/${P}-failed-tests.patch
254 +)
255 +
256 +distutils_enable_sphinx docs
257 +
258 +python_configure_all() {
259 + mydistutilsargs=(
260 + # GMP is the default, add mpir if the USE flag is set
261 + $(usex mpir --mpir "")
262 + )
263 +}
264 +
265 +python_test() {
266 + cd test || die
267 + "${EPYTHON}" runtests.py || die "tests failed under ${EPYTHON}"
268 +}