Sync from SUSE:ALP:Source:Standard:1.0 python-gmpy2 revision b377597fcc6eb20da102fb40dca84e76

This commit is contained in:
Adrian Schröter 2023-09-21 10:16:31 +02:00
commit 1597d61c4c
6 changed files with 265 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

BIN
gmpy2-2.1.5.tar.gz (Stored with Git LFS) Normal file

Binary file not shown.

73
gmpy2_cache.c.diff Normal file
View 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
View 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 &&

61
python-gmpy2.changes Normal file
View File

@ -0,0 +1,61 @@
-------------------------------------------------------------------
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>
- Add %{?sle15_python_module_pythons}
-------------------------------------------------------------------
Fri Apr 7 21:06:58 UTC 2023 - Jan Engelhardt <jengelh@inai.de>
- Remove unused build dependency on mpir (gmp was used anyway)
-------------------------------------------------------------------
Thu Jan 5 21:04:37 UTC 2023 - Dirk Müller <dmueller@suse.com>
- update to gmpy2-2.1.5:
* Final (?) release of the 2.1.x series. No code changes since 2.1.3.
Fixes to build Apple Silicon binary builds are the only changes since
* Latest release with minor bug fixes and support for Python 3.11
-------------------------------------------------------------------
Mon Feb 21 03:30:39 UTC 2022 - Steve Kowalik <steven.kowalik@suse.com>
- Update to 2.1.2:
* Allow GIL release for mpz/xmpz/mpq types only.
* Improve argument type processing by saving type information to
decrease the number of type check calls. Especially helpful for mpfr and mpc types.
* Avoid MPFR bug in mfr_fac_ui (gmpy2.factorial) on platforms where
long is 32-bits and argument is >= 44787929.
* Adjust test suite to reflect changes in output in MPFR 4.1.0.
* Added cmp() and cmp_abs().
* Improved compatibility with _numbers_ protocol.
* Initial support for MPFR4
+ Add nrandom()
+ grandom() now calls nrandom twice; may return different values versus MPFR3
+ Add rootn(); same as root() except different sign when taking even root of -0.0
* Thread-safe contexts are now supported. Properly integrating thread-safe contexts required
an extensive rewrite of almost all internal functions.
* MPFR and MPC are now required. It is no longer possible to build a version of gmpy2 that
only supports the GMP library.
* The function inverse() now raises an exception if the inverse does not exist.
* Context methods have been added for MPFR/MPC related functions.
* A new context option (rational_division) has been added that changes the behavior of
integer division involving mpz instances to return a rational result instead of a
floating point result.
* gmpy2 types are now registered in the numeric tower.
- Remove unzip BuildRequires, as upstream has switched to tarballs.
-------------------------------------------------------------------
Thu May 24 17:33:34 UTC 2018 - toddrme2178@gmail.com
- spec file cleanups
-------------------------------------------------------------------
Sat Aug 26 02:00:40 UTC 2017 - toddrme2178@gmail.com
- Initial version

74
python-gmpy2.spec Normal file
View File

@ -0,0 +1,74 @@
#
# spec file for package python-gmpy2
#
# Copyright (c) 2023 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%{?sle15_python_module_pythons}
Name: python-gmpy2
Version: 2.1.5
Release: 0
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
BuildRequires: gmp-devel
BuildRequires: mpc-devel
BuildRequires: mpfr-devel
BuildRequires: python-rpm-macros
%python_subpackages
%description
gmpy2 is a C-coded Python extension module that supports
multiple-precision arithmetic. In addition to supporting
GMP or MPIR for multiple-precision integer and rational
arithmetic, gmpy2 adds support for the MPFR (correctly
rounded real floating-point arithmetic) and MPC (correctly
rounded complex floating-point arithmetic) libraries.
%prep
%autosetup -p1 -n gmpy2-%{version}
%build
export CFLAGS="%{optflags}"
%python_build
%install
%python_install
%python_expand %fdupes %{buildroot}%{$python_sitearch}
%check
%{python_expand export PYTHONDONTWRITEBYTECODE=1
export PYTHONPATH=%{buildroot}%{$python_sitearch}
pushd test
$python runtests.py
popd
}
%files %{python_files}
%doc README
%license COPYING COPYING.LESSER
%{python_sitearch}/gmpy2
%{python_sitearch}/gmpy2-%{version}*-info
%changelog