From 7d3b6e79afd427d4c4f952f2553e21f540763715 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Bissey?= Date: Sun, 8 Sep 2024 22:58:09 +1200 Subject: [PATCH 1/6] sci-mathematics/sage_docbuild: fix on fix for py3.9 --- .../sage_docbuild/files/sphinx8-act2.patch | 84 +++++++++++++++++++ .../sage_docbuild/sage_docbuild-9999.ebuild | 1 + 2 files changed, 85 insertions(+) create mode 100644 sci-mathematics/sage_docbuild/files/sphinx8-act2.patch diff --git a/sci-mathematics/sage_docbuild/files/sphinx8-act2.patch b/sci-mathematics/sage_docbuild/files/sphinx8-act2.patch new file mode 100644 index 000000000..040c5cb07 --- /dev/null +++ b/sci-mathematics/sage_docbuild/files/sphinx8-act2.patch @@ -0,0 +1,84 @@ +diff --git a/sage_docbuild/ext/sage_autodoc.py b/sage_docbuild/ext/sage_autodoc.py +index 0cc04e7..062bb58 100644 +--- a/sage_docbuild/ext/sage_autodoc.py ++++ b/sage_docbuild/ext/sage_autodoc.py +@@ -1577,8 +1577,13 @@ class ClassDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # type: + def can_document_member( + cls: type[Documenter], member: Any, membername: str, isattr: bool, parent: Any, + ) -> bool: +- return isinstance(member, type) or ( +- isattr and (inspect.isNewType(member) or isinstance(member, TypeVar))) ++ try: ++ result_bool = isinstance(member, type) or ( ++ isattr and isinstance(member, NewType | TypeVar)) ++ except: ++ result_bool = isinstance(member, type) or ( ++ isattr and (inspect.isNewType(member) or isinstance(member, TypeVar))) ++ return result_bool + + def import_object(self, raiseerror: bool = False) -> bool: + ret = super().import_object(raiseerror) +@@ -1651,7 +1656,11 @@ class ClassDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # type: + # ------------------------------------------------------------------- + else: + self.doc_as_attr = True +- if inspect.isNewType(self.object) or isinstance(self.object, TypeVar): ++ try: ++ test_bool = isinstance(self.object, NewType | TypeVar) ++ except: ++ test_bool = inspect.isNewType(self.object) or isinstance(self.object, TypeVar) ++ if test_bool: + modname = getattr(self.object, '__module__', self.modname) + if modname != self.modname and self.modname.startswith(modname): + bases = self.modname[len(modname):].strip('.').split('.') +@@ -1660,7 +1669,11 @@ class ClassDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # type: + return ret + + def _get_signature(self) -> tuple[Any | None, str | None, Signature | None]: +- if inspect.isNewType(self.object) or isinstance(self.object, TypeVar): ++ try: ++ test_bool = isinstance(self.object, NewType | TypeVar) ++ except: ++ test_bool = inspect.isNewType(self.object) or isinstance(self.object, TypeVar) ++ if test_bool: + # Suppress signature + return None, None, None + +@@ -1845,14 +1858,22 @@ class ClassDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # type: + self.directivetype = 'attribute' + super().add_directive_header(sig) + +- if inspect.isNewType(self.object) or isinstance(self.object, TypeVar): ++ try: ++ test_bool = isinstance(self.object, NewType | TypeVar) ++ except: ++ test_bool = inspect.isNewType(self.object) or isinstance(self.object, TypeVar) ++ if test_bool: + return + + if self.analyzer and '.'.join(self.objpath) in self.analyzer.finals: + self.add_line(' :final:', sourcename) + + canonical_fullname = self.get_canonical_fullname() +- if (not self.doc_as_attr and not inspect.isNewType(self.object) ++ try: ++ newtype_test = isinstance(self.object, NewType) ++ except: ++ newtype_test = inspect.isNewType(self.object) ++ if (not self.doc_as_attr and not newtype_test + and canonical_fullname and self.fullname != canonical_fullname): + self.add_line(' :canonical: %s' % canonical_fullname, sourcename) + +@@ -1989,7 +2010,11 @@ class ClassDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # type: + return None + + def add_content(self, more_content: StringList | None) -> None: +- if inspect.isNewType(self.object): ++ try: ++ newtype_test = isinstance(self.object, NewType) ++ except: ++ newtype_test = inspect.isNewType(self.object) ++ if newtype_test: + if self.config.autodoc_typehints_format == "short": + supertype = restify(self.object.__supertype__, "smart") + else: diff --git a/sci-mathematics/sage_docbuild/sage_docbuild-9999.ebuild b/sci-mathematics/sage_docbuild/sage_docbuild-9999.ebuild index f5c9a5229..1fa568e46 100644 --- a/sci-mathematics/sage_docbuild/sage_docbuild-9999.ebuild +++ b/sci-mathematics/sage_docbuild/sage_docbuild-9999.ebuild @@ -32,4 +32,5 @@ PDEPEND="~sci-mathematics/sagemath-standard-${PV}[${PYTHON_USEDEP}]" PATCHES=( "${FILESDIR}"/sage-9.3-linguas.patch + "${FILESDIR}"/sphinx8-act2.patch ) From b6206e5dc52491be40eab25f7bd72aaa16296a4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Bissey?= Date: Tue, 10 Sep 2024 10:03:30 +1200 Subject: [PATCH 2/6] sci-mathematics/cubex: update EAPI 6 -> 8 --- sci-mathematics/cubex/cubex-20060128.ebuild | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sci-mathematics/cubex/cubex-20060128.ebuild b/sci-mathematics/cubex/cubex-20060128.ebuild index 82a5c3b1e..81142228d 100644 --- a/sci-mathematics/cubex/cubex-20060128.ebuild +++ b/sci-mathematics/cubex/cubex-20060128.ebuild @@ -1,7 +1,7 @@ # Copyright 1999-2023 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 -EAPI=6 +EAPI=8 inherit toolchain-funcs From abb12ce20b4c8ce33210f7c06c9637576e78f636 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Bissey?= Date: Tue, 10 Sep 2024 10:04:46 +1200 Subject: [PATCH 3/6] sci-mathematics/optimal: update EAPI 6 -> 8 --- sci-mathematics/optimal/optimal-20040603-r1.ebuild | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sci-mathematics/optimal/optimal-20040603-r1.ebuild b/sci-mathematics/optimal/optimal-20040603-r1.ebuild index 43cfa40c1..df1b467f1 100644 --- a/sci-mathematics/optimal/optimal-20040603-r1.ebuild +++ b/sci-mathematics/optimal/optimal-20040603-r1.ebuild @@ -1,7 +1,7 @@ # Copyright 1999-2023 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 -EAPI=6 +EAPI=8 inherit toolchain-funcs From af4caa6854f96d0124c749e5b71246555168acc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Bissey?= Date: Tue, 10 Sep 2024 10:41:04 +1200 Subject: [PATCH 4/6] sci-mathematics/sagemath-standard: apply PR 38113 --- .../sagemath-standard/files/mpmath.patch | 333 ++++++++++++++++++ .../sagemath-standard-9999.ebuild | 13 +- 2 files changed, 342 insertions(+), 4 deletions(-) create mode 100644 sci-mathematics/sagemath-standard/files/mpmath.patch diff --git a/sci-mathematics/sagemath-standard/files/mpmath.patch b/sci-mathematics/sagemath-standard/files/mpmath.patch new file mode 100644 index 000000000..d45cc5549 --- /dev/null +++ b/sci-mathematics/sagemath-standard/files/mpmath.patch @@ -0,0 +1,333 @@ +diff --git a/sage/env.py b/sage/env.py +index 3548c65f43e..d6b6218d7b6 100644 +--- a/sage/env.py ++++ b/sage/env.py +@@ -245,8 +245,9 @@ SINGULAR_BIN = var("SINGULAR_BIN") or "Singular" + OPENMP_CFLAGS = var("OPENMP_CFLAGS", "") + OPENMP_CXXFLAGS = var("OPENMP_CXXFLAGS", "") + +-# Make sure mpmath uses Sage types +-os.environ['MPMATH_SAGE'] = '1' ++# Make sure that mpmath < 1.4 does not try to use Sage types ++os.environ.pop('MPMATH_SAGE', None) ++os.environ['MPMATH_NOSAGE'] = '1' + + # misc + SAGE_BANNER = var("SAGE_BANNER", "") +diff --git a/sage/libs/mpmath/utils.pyx b/sage/libs/mpmath/utils.pyx +index 0123d4190be..0f451e18f65 100644 +--- a/sage/libs/mpmath/utils.pyx ++++ b/sage/libs/mpmath/utils.pyx +@@ -1,9 +1,9 @@ + """ + Utilities for Sage-mpmath interaction +- +-Also patches some mpmath functions for speed + """ + ++cimport gmpy2 ++ + from sage.ext.stdsage cimport PY_NEW + + from sage.rings.integer cimport Integer +@@ -16,141 +16,8 @@ from sage.libs.gmp.all cimport * + + from sage.rings.real_mpfr cimport RealField + +-cpdef int bitcount(n) noexcept: +- """ +- Bitcount of a Sage Integer or Python int/long. +- +- EXAMPLES:: +- +- sage: from mpmath.libmp import bitcount +- sage: bitcount(0) +- 0 +- sage: bitcount(1) +- 1 +- sage: bitcount(100) +- 7 +- sage: bitcount(-100) +- 7 +- sage: bitcount(2r) +- 2 +- sage: bitcount(2L) +- 2 +- """ +- cdef Integer m +- if isinstance(n, Integer): +- m = n +- else: +- m = Integer(n) +- if mpz_sgn(m.value) == 0: +- return 0 +- return mpz_sizeinbase(m.value, 2) +- +-cpdef isqrt(n): +- """ +- Square root (rounded to floor) of a Sage Integer or Python int/long. +- The result is a Sage Integer. +- +- EXAMPLES:: +- +- sage: from mpmath.libmp import isqrt +- sage: isqrt(0) +- 0 +- sage: isqrt(100) +- 10 +- sage: isqrt(10) +- 3 +- sage: isqrt(10r) +- 3 +- sage: isqrt(10L) +- 3 +- """ +- cdef Integer m, y +- if isinstance(n, Integer): +- m = n +- else: +- m = Integer(n) +- if mpz_sgn(m.value) < 0: +- raise ValueError("square root of negative integer not defined.") +- y = PY_NEW(Integer) +- mpz_sqrt(y.value, m.value) +- return y +- +-cpdef from_man_exp(man, exp, long prec = 0, str rnd = 'd'): +- """ +- Create normalized mpf value tuple from mantissa and exponent. +- +- With prec > 0, rounds the result in the desired direction +- if necessary. ++gmpy2.import_gmpy2() + +- EXAMPLES:: +- +- sage: from mpmath.libmp import from_man_exp +- sage: from_man_exp(-6, -1) +- (1, 3, 0, 2) +- sage: from_man_exp(-6, -1, 1, 'd') +- (1, 1, 1, 1) +- sage: from_man_exp(-6, -1, 1, 'u') +- (1, 1, 2, 1) +- """ +- cdef Integer res +- cdef long bc +- res = Integer(man) +- bc = mpz_sizeinbase(res.value, 2) +- if not prec: +- prec = bc +- if mpz_sgn(res.value) < 0: +- mpz_neg(res.value, res.value) +- return normalize(1, res, exp, bc, prec, rnd) +- else: +- return normalize(0, res, exp, bc, prec, rnd) +- +-cpdef normalize(long sign, Integer man, exp, long bc, long prec, str rnd): +- """ +- Create normalized mpf value tuple from full list of components. +- +- EXAMPLES:: +- +- sage: from mpmath.libmp import normalize +- sage: normalize(0, 4, 5, 3, 53, 'n') +- (0, 1, 7, 1) +- """ +- cdef long shift +- cdef Integer res +- cdef unsigned long trail +- if mpz_sgn(man.value) == 0: +- from mpmath.libmp import fzero +- return fzero +- if bc <= prec and mpz_odd_p(man.value): +- return (sign, man, exp, bc) +- shift = bc - prec +- res = PY_NEW(Integer) +- if shift > 0: +- if rnd == 'n': +- if mpz_tstbit(man.value, shift-1) and (mpz_tstbit(man.value, shift) +- or (mpz_scan1(man.value, 0) < (shift-1))): +- mpz_cdiv_q_2exp(res.value, man.value, shift) +- else: +- mpz_fdiv_q_2exp(res.value, man.value, shift) +- elif rnd == 'd': +- mpz_fdiv_q_2exp(res.value, man.value, shift) +- elif rnd == 'f': +- if sign: mpz_cdiv_q_2exp(res.value, man.value, shift) +- else: mpz_fdiv_q_2exp(res.value, man.value, shift) +- elif rnd == 'c': +- if sign: mpz_fdiv_q_2exp(res.value, man.value, shift) +- else: mpz_cdiv_q_2exp(res.value, man.value, shift) +- elif rnd == 'u': +- mpz_cdiv_q_2exp(res.value, man.value, shift) +- exp += shift +- else: +- mpz_set(res.value, man.value) +- # Strip trailing bits +- trail = mpz_scan1(res.value, 0) +- if 0 < trail < bc: +- mpz_tdiv_q_2exp(res.value, res.value, trail) +- exp += trail +- bc = mpz_sizeinbase(res.value, 2) +- return (sign, res, int(exp), bc) + + cdef mpfr_from_mpfval(mpfr_t res, tuple x): + """ +@@ -158,12 +25,12 @@ cdef mpfr_from_mpfval(mpfr_t res, tuple x): + data tuple. + """ + cdef int sign +- cdef Integer man ++ cdef gmpy2.mpz man + cdef long exp + cdef long bc + sign, man, exp, bc = x + if man: +- mpfr_set_z(res, man.value, MPFR_RNDZ) ++ mpfr_set_z(res, man.z, MPFR_RNDZ) + if sign: + mpfr_neg(res, res, MPFR_RNDZ) + mpfr_mul_2si(res, res, exp, MPFR_RNDZ) +@@ -207,7 +74,7 @@ cdef mpfr_to_mpfval(mpfr_t value): + mpz_tdiv_q_2exp(man.value, man.value, trailing) + exp += trailing + bc = mpz_sizeinbase(man.value, 2) +- return (sign, man, int(exp), bc) ++ return (sign, man.__mpz__(), int(exp), bc) + + + def mpmath_to_sage(x, prec): +@@ -412,7 +279,7 @@ def call(func, *args, **kwargs): + Check that :issue:`11885` is fixed:: + + sage: a.call(a.ei, 1.0r, parent=float) +- 1.8951178163559366 ++ 1.8951178163559368 + + Check that :issue:`14984` is fixed:: + +diff --git a/sage/rings/real_mpfr.pyx b/sage/rings/real_mpfr.pyx +index 7e1ab748b55..4a332e6fb5d 100644 +--- a/sage/rings/real_mpfr.pyx ++++ b/sage/rings/real_mpfr.pyx +@@ -150,8 +150,6 @@ from sage.structure.richcmp cimport rich_to_bool_sgn + cdef bin_op + from sage.structure.element import bin_op + +-from sage.libs.mpmath.utils cimport mpfr_to_mpfval +- + from sage.rings.integer cimport Integer + from sage.rings.rational cimport Rational + from sage.rings.real_double cimport RealDoubleElement +diff --git a/sage/structure/coerce.pyx b/sage/structure/coerce.pyx +index cc15eff82e9..79d5ecb74e0 100644 +--- a/sage/structure/coerce.pyx ++++ b/sage/structure/coerce.pyx +@@ -144,6 +144,13 @@ cpdef py_scalar_parent(py_type): + Real Double Field + sage: py_scalar_parent(gmpy2.mpc) # needs sage.rings.complex_double + Complex Double Field ++ ++ sage: # needs mpmath ++ sage: import mpmath ++ sage: py_scalar_parent(mpmath.mpf) ++ Real Double Field ++ sage: py_scalar_parent(mpmath.mpc) # needs sage.rings.complex_double ++ Complex Double Field + """ + if issubclass(py_type, int): + import sage.rings.integer_ring +@@ -151,39 +158,46 @@ cpdef py_scalar_parent(py_type): + if py_type is FractionType: + import sage.rings.rational_field + return sage.rings.rational_field.QQ +- elif issubclass(py_type, float): ++ if issubclass(py_type, float): + import sage.rings.real_double + return sage.rings.real_double.RDF +- elif issubclass(py_type, complex): ++ if issubclass(py_type, complex): + import sage.rings.complex_double + return sage.rings.complex_double.CDF +- elif is_numpy_type(py_type): ++ if is_numpy_type(py_type): + import numpy + if issubclass(py_type, numpy.integer): + import sage.rings.integer_ring + return sage.rings.integer_ring.ZZ +- elif issubclass(py_type, numpy.floating): ++ if issubclass(py_type, numpy.floating): + import sage.rings.real_double + return sage.rings.real_double.RDF +- elif issubclass(py_type, numpy.complexfloating): ++ if issubclass(py_type, numpy.complexfloating): + import sage.rings.complex_double + return sage.rings.complex_double.CDF +- else: +- return None +- elif issubclass(py_type, gmpy2.mpz): ++ return None ++ if issubclass(py_type, gmpy2.mpz): + import sage.rings.integer_ring + return sage.rings.integer_ring.ZZ +- elif issubclass(py_type, gmpy2.mpq): ++ if issubclass(py_type, gmpy2.mpq): + import sage.rings.rational_field + return sage.rings.rational_field.QQ +- elif issubclass(py_type, gmpy2.mpfr): ++ if issubclass(py_type, gmpy2.mpfr): + import sage.rings.real_double + return sage.rings.real_double.RDF +- elif issubclass(py_type, gmpy2.mpc): ++ if issubclass(py_type, gmpy2.mpc): + import sage.rings.complex_double + return sage.rings.complex_double.CDF +- else: ++ if is_mpmath_type(py_type): ++ import mpmath ++ if issubclass(py_type, mpmath.mpf): ++ from sage.rings.real_double import RDF ++ return RDF ++ if issubclass(py_type, mpmath.mpc): ++ from sage.rings.complex_double import CDF ++ return CDF + return None ++ return None + + cpdef py_scalar_to_element(x): + """ +@@ -469,10 +483,10 @@ cpdef bint is_numpy_type(t) noexcept: + return True + return False + ++ + cpdef bint is_mpmath_type(t) noexcept: + r""" +- Check whether the type ``t`` is a type whose name starts with either +- ``mpmath.`` or ``sage.libs.mpmath.``. ++ Check whether the type ``t`` is a type whose name starts with ``mpmath.`` + + EXAMPLES:: + +@@ -489,7 +503,7 @@ cpdef bint is_mpmath_type(t) noexcept: + True + """ + return isinstance(t, type) and \ +- strncmp((t).tp_name, "sage.libs.mpmath.", 17) == 0 ++ t.__module__.startswith("mpmath.") + + + cdef class CoercionModel: +diff --git a/sage/tests/books/computational-mathematics-with-sagemath/integration_doctest.py b/sage/tests/books/computational-mathematics-with-sagemath/integration_doctest.py +index bf0bb747282..9e7597eba9d 100644 +--- a/sage/tests/books/computational-mathematics-with-sagemath/integration_doctest.py ++++ b/sage/tests/books/computational-mathematics-with-sagemath/integration_doctest.py +@@ -151,7 +151,7 @@ Sage example in ./integration.tex, line 846:: + sage: mpmath.quad(f, [0, 1]) + Traceback (most recent call last): + ... +- TypeError: no canonical coercion from to ... ++ TypeError: no canonical coercion from to ... + + Sage example in ./integration.tex, line 866:: + diff --git a/sci-mathematics/sagemath-standard/sagemath-standard-9999.ebuild b/sci-mathematics/sagemath-standard/sagemath-standard-9999.ebuild index 1c0f09648..18de29f0e 100644 --- a/sci-mathematics/sagemath-standard/sagemath-standard-9999.ebuild +++ b/sci-mathematics/sagemath-standard/sagemath-standard-9999.ebuild @@ -7,10 +7,6 @@ PYTHON_COMPAT=( python3_{10..12} ) PYTHON_REQ_USE="readline,sqlite" DISTUTILS_USE_PEP517=setuptools DISTUTILS_EXT=1 -# 38113 mpmath 1.4 support -# GIT_PRS=( -# 38113 -# ) inherit desktop distutils-r1 multiprocessing sage-git-patch toolchain-funcs @@ -145,6 +141,7 @@ REQUIRED_USE="doc? ( jmol ) PATCHES=( "${FILESDIR}"/gap-4.13.1_b.patch + "${FILESDIR}"/mpmath.patch "${FILESDIR}"/${PN}-10.4-env.patch "${FILESDIR}"/sage_exec-9.3.patch "${FILESDIR}"/${PN}-10.4b-neutering.patch @@ -158,6 +155,14 @@ pkg_setup() { python_prepare_all() { distutils-r1_python_prepare_all + # delete mpmath files. This saves a lot of patch space + rm -r \ + sage/libs/mpmath/ext_impl.pxd \ + sage/libs/mpmath/ext_impl.pyx \ + sage/libs/mpmath/ext_libmp.pyx \ + sage/libs/mpmath/ext_main.pxd \ + sage/libs/mpmath/ext_main.pyx + # use installed copy, not the vendored one. rm -rf sage_setup From 52fbbd8403893edac1c5356e57c1a7e8697297b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Bissey?= Date: Thu, 12 Sep 2024 11:11:35 +1200 Subject: [PATCH 5/6] removing UC clandestine mirror --- profiles/thirdpartymirrors | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/profiles/thirdpartymirrors b/profiles/thirdpartymirrors index 88a8f6dc7..9ffbf3d85 100644 --- a/profiles/thirdpartymirrors +++ b/profiles/thirdpartymirrors @@ -1,2 +1,2 @@ sageupstream http://files.sagemath.org//spkg/upstream/ https://ftp.riken.jp/sagemath/spkg/upstream/ https://www-ftp.lip6.fr/pub/math/sagemath/spkg/upstream ftp://ftp.fu-berlin.de/unix/misc/sage/spkg/upstream -sagemath http://202.36.178.9/sage/ https://sage-on-gentoo.lipn.univ-paris13.fr/sage/ +sagemath https://sage-on-gentoo.lipn.univ-paris13.fr/sage/ From 3b8624e3136d0d0e051dab2bcc25a4bb7f02aac8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Bissey?= Date: Sun, 15 Sep 2024 15:40:16 +1200 Subject: [PATCH 6/6] sci-mathematics/sage_docbuild: patch upstreamed --- .../sage_docbuild/files/sphinx8-act2.patch | 84 ------------------- .../sage_docbuild/sage_docbuild-9999.ebuild | 1 - 2 files changed, 85 deletions(-) delete mode 100644 sci-mathematics/sage_docbuild/files/sphinx8-act2.patch diff --git a/sci-mathematics/sage_docbuild/files/sphinx8-act2.patch b/sci-mathematics/sage_docbuild/files/sphinx8-act2.patch deleted file mode 100644 index 040c5cb07..000000000 --- a/sci-mathematics/sage_docbuild/files/sphinx8-act2.patch +++ /dev/null @@ -1,84 +0,0 @@ -diff --git a/sage_docbuild/ext/sage_autodoc.py b/sage_docbuild/ext/sage_autodoc.py -index 0cc04e7..062bb58 100644 ---- a/sage_docbuild/ext/sage_autodoc.py -+++ b/sage_docbuild/ext/sage_autodoc.py -@@ -1577,8 +1577,13 @@ class ClassDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # type: - def can_document_member( - cls: type[Documenter], member: Any, membername: str, isattr: bool, parent: Any, - ) -> bool: -- return isinstance(member, type) or ( -- isattr and (inspect.isNewType(member) or isinstance(member, TypeVar))) -+ try: -+ result_bool = isinstance(member, type) or ( -+ isattr and isinstance(member, NewType | TypeVar)) -+ except: -+ result_bool = isinstance(member, type) or ( -+ isattr and (inspect.isNewType(member) or isinstance(member, TypeVar))) -+ return result_bool - - def import_object(self, raiseerror: bool = False) -> bool: - ret = super().import_object(raiseerror) -@@ -1651,7 +1656,11 @@ class ClassDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # type: - # ------------------------------------------------------------------- - else: - self.doc_as_attr = True -- if inspect.isNewType(self.object) or isinstance(self.object, TypeVar): -+ try: -+ test_bool = isinstance(self.object, NewType | TypeVar) -+ except: -+ test_bool = inspect.isNewType(self.object) or isinstance(self.object, TypeVar) -+ if test_bool: - modname = getattr(self.object, '__module__', self.modname) - if modname != self.modname and self.modname.startswith(modname): - bases = self.modname[len(modname):].strip('.').split('.') -@@ -1660,7 +1669,11 @@ class ClassDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # type: - return ret - - def _get_signature(self) -> tuple[Any | None, str | None, Signature | None]: -- if inspect.isNewType(self.object) or isinstance(self.object, TypeVar): -+ try: -+ test_bool = isinstance(self.object, NewType | TypeVar) -+ except: -+ test_bool = inspect.isNewType(self.object) or isinstance(self.object, TypeVar) -+ if test_bool: - # Suppress signature - return None, None, None - -@@ -1845,14 +1858,22 @@ class ClassDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # type: - self.directivetype = 'attribute' - super().add_directive_header(sig) - -- if inspect.isNewType(self.object) or isinstance(self.object, TypeVar): -+ try: -+ test_bool = isinstance(self.object, NewType | TypeVar) -+ except: -+ test_bool = inspect.isNewType(self.object) or isinstance(self.object, TypeVar) -+ if test_bool: - return - - if self.analyzer and '.'.join(self.objpath) in self.analyzer.finals: - self.add_line(' :final:', sourcename) - - canonical_fullname = self.get_canonical_fullname() -- if (not self.doc_as_attr and not inspect.isNewType(self.object) -+ try: -+ newtype_test = isinstance(self.object, NewType) -+ except: -+ newtype_test = inspect.isNewType(self.object) -+ if (not self.doc_as_attr and not newtype_test - and canonical_fullname and self.fullname != canonical_fullname): - self.add_line(' :canonical: %s' % canonical_fullname, sourcename) - -@@ -1989,7 +2010,11 @@ class ClassDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # type: - return None - - def add_content(self, more_content: StringList | None) -> None: -- if inspect.isNewType(self.object): -+ try: -+ newtype_test = isinstance(self.object, NewType) -+ except: -+ newtype_test = inspect.isNewType(self.object) -+ if newtype_test: - if self.config.autodoc_typehints_format == "short": - supertype = restify(self.object.__supertype__, "smart") - else: diff --git a/sci-mathematics/sage_docbuild/sage_docbuild-9999.ebuild b/sci-mathematics/sage_docbuild/sage_docbuild-9999.ebuild index 1fa568e46..f5c9a5229 100644 --- a/sci-mathematics/sage_docbuild/sage_docbuild-9999.ebuild +++ b/sci-mathematics/sage_docbuild/sage_docbuild-9999.ebuild @@ -32,5 +32,4 @@ PDEPEND="~sci-mathematics/sagemath-standard-${PV}[${PYTHON_USEDEP}]" PATCHES=( "${FILESDIR}"/sage-9.3-linguas.patch - "${FILESDIR}"/sphinx8-act2.patch )