From 1597d61c4c70b044b00db5b6ce932fc95c213437 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Schr=C3=B6ter?= Date: Thu, 21 Sep 2023 10:16:31 +0200 Subject: [PATCH] Sync from SUSE:ALP:Source:Standard:1.0 python-gmpy2 revision b377597fcc6eb20da102fb40dca84e76 --- .gitattributes | 23 ++++++++++++++ gmpy2-2.1.5.tar.gz | 3 ++ gmpy2_cache.c.diff | 73 +++++++++++++++++++++++++++++++++++++++++++ mpfr421.patch | 31 +++++++++++++++++++ python-gmpy2.changes | 61 ++++++++++++++++++++++++++++++++++++ python-gmpy2.spec | 74 ++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 265 insertions(+) create mode 100644 .gitattributes create mode 100644 gmpy2-2.1.5.tar.gz create mode 100644 gmpy2_cache.c.diff create mode 100644 mpfr421.patch create mode 100644 python-gmpy2.changes create mode 100644 python-gmpy2.spec diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..fecc750 --- /dev/null +++ b/.gitattributes @@ -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 diff --git a/gmpy2-2.1.5.tar.gz b/gmpy2-2.1.5.tar.gz new file mode 100644 index 0000000..20595b3 --- /dev/null +++ b/gmpy2-2.1.5.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bc297f1fd8c377ae67a4f493fc0f926e5d1b157e5c342e30a4d84dc7b9f95d96 +size 261709 diff --git a/gmpy2_cache.c.diff b/gmpy2_cache.c.diff new file mode 100644 index 0000000..753edd5 --- /dev/null +++ b/gmpy2_cache.c.diff @@ -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 * diff --git a/mpfr421.patch b/mpfr421.patch new file mode 100644 index 0000000..963e3ce --- /dev/null +++ b/mpfr421.patch @@ -0,0 +1,31 @@ +From 68a6b489c3d8d95b2658a1ed884fb99f4bd955c1 Mon Sep 17 00:00:00 2001 +From: Sergey B Kirpichev +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 + +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 && diff --git a/python-gmpy2.changes b/python-gmpy2.changes new file mode 100644 index 0000000..447710f --- /dev/null +++ b/python-gmpy2.changes @@ -0,0 +1,61 @@ +------------------------------------------------------------------- +Tue Sep 19 09:03:02 UTC 2023 - Markéta Machová + +- 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 + +- Add %{?sle15_python_module_pythons} + +------------------------------------------------------------------- +Fri Apr 7 21:06:58 UTC 2023 - Jan Engelhardt + +- Remove unused build dependency on mpir (gmp was used anyway) + +------------------------------------------------------------------- +Thu Jan 5 21:04:37 UTC 2023 - Dirk Müller + +- 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 + +- 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 diff --git a/python-gmpy2.spec b/python-gmpy2.spec new file mode 100644 index 0000000..28e7a18 --- /dev/null +++ b/python-gmpy2.spec @@ -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