Accepting request 1112318 from devel:languages:python:numeric
OBS-URL: https://build.opensuse.org/request/show/1112318 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-gmpy2?expand=0&rev=6
This commit is contained in:
commit
617ccba342
73
gmpy2_cache.c.diff
Normal file
73
gmpy2_cache.c.diff
Normal file
@ -0,0 +1,73 @@
|
||||
--- gmpy2-2.1.5.orig/src/gmpy2_cache.c 2022-09-24 07:12:17.000000000 +0300
|
||||
+++ gmpy2-2.1.5/src/gmpy2_cache.c 2023-09-05 17:15:05.035841008 +0300
|
||||
@@ -537,19 +537,17 @@
|
||||
|
||||
if (global.in_gmpympfrcache) {
|
||||
result = global.gmpympfrcache[--(global.in_gmpympfrcache)];
|
||||
- /* Py_INCREF does not set the debugging pointers, so need to use
|
||||
- _Py_NewReference instead. */
|
||||
- _Py_NewReference((PyObject*)result);
|
||||
- mpfr_set_prec(result->f, bits);
|
||||
+ Py_INCREF((PyObject*)result);
|
||||
}
|
||||
else {
|
||||
- if (!(result = PyObject_New(MPFR_Object, &MPFR_Type))) {
|
||||
+ result = PyObject_New(MPFR_Object, &MPFR_Type);
|
||||
+ if (result == NULL) {
|
||||
/* LCOV_EXCL_START */
|
||||
return NULL;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
- mpfr_init2(result->f, bits);
|
||||
}
|
||||
+ mpfr_init2(result->f, bits);
|
||||
result->hash_cache = -1;
|
||||
result->rc = 0;
|
||||
return result;
|
||||
@@ -704,7 +702,7 @@
|
||||
static MPC_Object *
|
||||
GMPy_MPC_New(mpfr_prec_t rprec, mpfr_prec_t iprec, CTXT_Object *context)
|
||||
{
|
||||
- MPC_Object *self;
|
||||
+ MPC_Object *result;
|
||||
|
||||
if (rprec < 2) {
|
||||
CHECK_CONTEXT(context);
|
||||
@@ -722,29 +720,21 @@
|
||||
return NULL;
|
||||
}
|
||||
if (global.in_gmpympccache) {
|
||||
- self = global.gmpympccache[--(global.in_gmpympccache)];
|
||||
- /* Py_INCREF does not set the debugging pointers, so need to use
|
||||
- _Py_NewReference instead. */
|
||||
- _Py_NewReference((PyObject*)self);
|
||||
- if (rprec == iprec) {
|
||||
- mpc_set_prec(self->c, rprec);
|
||||
- }
|
||||
- else {
|
||||
- mpc_clear(self->c);
|
||||
- mpc_init3(self->c, rprec, iprec);
|
||||
- }
|
||||
+ result = global.gmpympccache[--(global.in_gmpympccache)];
|
||||
+ Py_INCREF((PyObject*)result);
|
||||
}
|
||||
else {
|
||||
- if (!(self = PyObject_New(MPC_Object, &MPC_Type))) {
|
||||
+ result = PyObject_New(MPC_Object, &MPC_Type);
|
||||
+ if (result == NULL) {
|
||||
/* LCOV_EXCL_START */
|
||||
return NULL;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
- mpc_init3(self->c, rprec, iprec);
|
||||
}
|
||||
- self->hash_cache = -1;
|
||||
- self->rc = 0;
|
||||
- return self;
|
||||
+ mpc_init3(result->c, rprec, iprec);
|
||||
+ result->hash_cache = -1;
|
||||
+ result->rc = 0;
|
||||
+ return result;
|
||||
}
|
||||
|
||||
static PyObject *
|
31
mpfr421.patch
Normal file
31
mpfr421.patch
Normal file
@ -0,0 +1,31 @@
|
||||
From 68a6b489c3d8d95b2658a1ed884fb99f4bd955c1 Mon Sep 17 00:00:00 2001
|
||||
From: Sergey B Kirpichev <skirpichev@gmail.com>
|
||||
Date: Sun, 3 Sep 2023 02:35:19 +0300
|
||||
Subject: [PATCH 2/2] Exclude MPFR workaround for MPFR >= 4.2.1
|
||||
|
||||
Co-authored-by: Vincent Lefevre <vincent@vinc17.net>
|
||||
|
||||
Closes #418
|
||||
---
|
||||
src/gmpy2_format.c | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/src/gmpy2_format.c b/src/gmpy2_format.c
|
||||
index 3e450c96..303bb7bf 100644
|
||||
--- a/src/gmpy2_format.c
|
||||
+++ b/src/gmpy2_format.c
|
||||
@@ -592,12 +592,14 @@ GMPy_MPC_Format(PyObject *self, PyObject *args)
|
||||
if (mpcstyle)
|
||||
strcat(tempbuf, " ");
|
||||
else {
|
||||
+#if MPFR_VERSION < MPFR_VERSION_NUM(4,2,1)
|
||||
/* Need to insert + if imag is nan or +inf. */
|
||||
if (mpfr_nan_p(mpc_imagref(MPC(self))) ||
|
||||
(mpfr_inf_p(mpc_imagref(MPC(self))) &&
|
||||
mpfr_sgn(mpc_imagref(MPC(self))) > 0)) {
|
||||
strcat(tempbuf, "+");
|
||||
}
|
||||
+#endif
|
||||
}
|
||||
strcat(tempbuf, imagbuf);
|
||||
if (strlen(imagbuf) < 50 &&
|
@ -1,3 +1,9 @@
|
||||
-------------------------------------------------------------------
|
||||
Tue Sep 19 09:03:02 UTC 2023 - Markéta Machová <mmachova@suse.com>
|
||||
|
||||
- Add upstream mpfr421.patch and gmpy2_cache.c.diff to fix build
|
||||
with mpfr 4.2.1
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sat Jun 10 17:36:09 UTC 2023 - ecsos <ecsos@opensuse.org>
|
||||
|
||||
|
@ -24,6 +24,10 @@ Summary: GMP/MPIR, MPFR, and MPC interface to Python 2.6+ and 3x
|
||||
License: LGPL-3.0-only
|
||||
URL: https://github.com/aleaxit/gmpy
|
||||
Source: https://files.pythonhosted.org/packages/source/g/gmpy2/gmpy2-%{version}.tar.gz
|
||||
# PATCH-FIX-UPSTREAM https://github.com/aleaxit/gmpy/pull/422 Update MPFR to 4.2.1 in build scripts & fix test failures on new version
|
||||
Patch: mpfr421.patch
|
||||
# PATCH-FIX-UPSTREAM file included in https://github.com/aleaxit/gmpy/issues/418#issuecomment-1706721394
|
||||
Patch: gmpy2_cache.c.diff
|
||||
BuildRequires: %{python_module devel}
|
||||
BuildRequires: %{python_module setuptools}
|
||||
BuildRequires: fdupes
|
||||
@ -43,7 +47,7 @@ rounded real floating-point arithmetic) and MPC (correctly
|
||||
rounded complex floating-point arithmetic) libraries.
|
||||
|
||||
%prep
|
||||
%setup -q -n gmpy2-%{version}
|
||||
%autosetup -p1 -n gmpy2-%{version}
|
||||
|
||||
%build
|
||||
export CFLAGS="%{optflags}"
|
||||
@ -64,6 +68,7 @@ popd
|
||||
%files %{python_files}
|
||||
%doc README
|
||||
%license COPYING COPYING.LESSER
|
||||
%{python_sitearch}/*
|
||||
%{python_sitearch}/gmpy2
|
||||
%{python_sitearch}/gmpy2-%{version}*-info
|
||||
|
||||
%changelog
|
||||
|
Loading…
Reference in New Issue
Block a user