commit:     8e23e81588d0e0b0e900fdd016053824dad54c9c
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Sep  6 16:04:49 2025 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Sep  6 16:15:11 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8e23e815

dev-python/xdoctest: Enable py3.14

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 .../xdoctest/files/xdoctest-1.2.0-py314.patch      | 58 ++++++++++++++++++++++
 dev-python/xdoctest/xdoctest-1.2.0-r1.ebuild       | 52 +++++++++++++++++++
 2 files changed, 110 insertions(+)

diff --git a/dev-python/xdoctest/files/xdoctest-1.2.0-py314.patch 
b/dev-python/xdoctest/files/xdoctest-1.2.0-py314.patch
new file mode 100644
index 000000000000..2c143ae4b157
--- /dev/null
+++ b/dev-python/xdoctest/files/xdoctest-1.2.0-py314.patch
@@ -0,0 +1,58 @@
+diff --git a/setup.py b/setup.py
+index e9c0f587..06b1eeb0 100755
+--- a/setup.py
++++ b/setup.py
+@@ -18,7 +18,8 @@ def parse_version(fpath):
+ 
+ def static_parse(varname, fpath):
+     """
+-    Statically parse the a constant variable from a python file
++    Statically parse the a constant variable from a python file.
++    Raise an error if the variable is not a constant.
+     """
+     import ast
+ 
+@@ -29,10 +30,13 @@ def static_parse(varname, fpath):
+     pt = ast.parse(sourcecode)
+ 
+     class StaticVisitor(ast.NodeVisitor):
+-        def visit_Assign(self, node):
++        def visit_Assign(self, node: ast.Assign):
+             for target in node.targets:
+                 if getattr(target, "id", None) == varname:
+-                    self.static_value = node.value.s
++                    value: ast.expr = node.value
++                    if not isinstance(value, ast.Constant):
++                        raise ValueError("variable {!r} is not a 
constant".format(varname))
++                    self.static_value = value.value
+ 
+     visitor = StaticVisitor()
+     visitor.visit(pt)
+diff --git a/src/xdoctest/static_analysis.py b/src/xdoctest/static_analysis.py
+index d8171b2..cb1f798 100644
+--- a/src/xdoctest/static_analysis.py
++++ b/src/xdoctest/static_analysis.py
+@@ -21,8 +21,10 @@ import platform
+ PLAT_IMPL = platform.python_implementation()
+ 
+ 
+-IS_PY_GE_308 = sys.version_info[0] >= 3 and sys.version_info[1] >= 8
+-IS_PY_GE_312 = sys.version_info[0] >= 3 and sys.version_info[1] >= 12
++IS_PY_GE_312 = sys.version_info[0:2] >= (3, 12)
++IS_PY_GE_308 = sys.version_info[0:2] >= (3, 8)  # type: bool
++IS_PY_LT_314 = sys.version_info[0:2] < (3, 14)  # type: bool
++
+ 
+ if IS_PY_GE_312:
+     from xdoctest import _tokenize as tokenize
+@@ -771,7 +773,9 @@ def _parse_static_node_value(node):
+         values = map(_parse_static_node_value, node.values)
+         value = OrderedDict(zip(keys, values))
+         # value = dict(zip(keys, values))
+-    elif isinstance(node, (ast.NameConstant)):
++    elif IS_PY_LT_314 and isinstance(node, (ast.NameConstant)):
++        value = node.value
++    elif isinstance(node, ast.Constant):
+         value = node.value
+     else:
+         print(node.__dict__)

diff --git a/dev-python/xdoctest/xdoctest-1.2.0-r1.ebuild 
b/dev-python/xdoctest/xdoctest-1.2.0-r1.ebuild
new file mode 100644
index 000000000000..9a33f65f1229
--- /dev/null
+++ b/dev-python/xdoctest/xdoctest-1.2.0-r1.ebuild
@@ -0,0 +1,52 @@
+# Copyright 1999-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DISTUTILS_USE_PEP517=setuptools
+PYTHON_COMPAT=( python3_{11..14} )
+
+inherit distutils-r1
+
+DESCRIPTION="A rewrite of Python's builtin doctest module but without all the 
weirdness"
+HOMEPAGE="
+       https://github.com/Erotemic/xdoctest/
+       https://pypi.org/project/xdoctest/
+"
+SRC_URI="
+       https://github.com/Erotemic/xdoctest/archive/v${PV}.tar.gz
+               -> ${P}.gh.tar.gz
+"
+
+LICENSE="Apache-2.0"
+SLOT="0"
+KEYWORDS="~amd64 ~arm64 ~x86"
+
+RDEPEND="
+       dev-python/pytest[${PYTHON_USEDEP}]
+"
+# dev-python/nbformat-5.1.{0..2} did not install package data
+BDEPEND="
+       test? (
+               >=dev-python/nbformat-5.1.2-r1[${PYTHON_USEDEP}]
+       )
+"
+
+EPYTEST_PLUGIN_LOAD_VIA_ENV=1
+EPYTEST_PLUGINS=( "${PN}" )
+EPYTEST_XDIST=1
+distutils_enable_tests pytest
+
+PATCHES=(
+       # https://github.com/Erotemic/xdoctest/pull/168
+       # + parts of https://github.com/Erotemic/xdoctest/pull/177
+       "${FILESDIR}/${P}-py314.patch"
+)
+
+python_test() {
+       local EPYTEST_DESELECT=(
+               tests/test_pytest_cli.py::test_simple_pytest_import_error_cli
+       )
+
+       epytest --pyargs tests xdoctest
+}

Reply via email to