commit: 7ea8eeba336ead2cb94f4394497f0414d2e3d71b Author: Alfred Wingate <parona <AT> protonmail <DOT> com> AuthorDate: Wed Jul 16 12:38:19 2025 +0000 Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org> CommitDate: Sun Jul 20 16:17:09 2025 +0000 URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=7ea8eeba
python: Allow use of PYTHON_SINGLE_USEDEP in python_has_version Signed-off-by: Alfred Wingate <parona <AT> protonmail.com> Closes: https://github.com/pkgcore/pkgcheck/pull/749 Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org> src/pkgcheck/checks/python.py | 12 +++++------ .../PythonHasVersionUsage-2.ebuild | 25 ++++++++++++++++++++++ 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/pkgcheck/checks/python.py b/src/pkgcheck/checks/python.py index 39fbe55e..71a25f91 100644 --- a/src/pkgcheck/checks/python.py +++ b/src/pkgcheck/checks/python.py @@ -33,7 +33,7 @@ PYPI_WHEEL_URI_RE = re.compile( re.escape(PYPI_URI_PREFIX) + r"(?P<pytag>[^/]+)/[^/]/(?P<package>[^/]+)/" r"(?P<fn_package>[^/-]+)-(?P<version>[^/-]+)-(?P=pytag)-(?P<abitag>[^/]+)\.whl$" ) -USE_FLAGS_PYTHON_USEDEP = re.compile(r"\[(.+,)?\$\{PYTHON_USEDEP\}(,.+)?\]$") +USE_FLAGS_PYTHON_USEDEP = re.compile(r"\[(.+,)?\$\{PYTHON_(SINGLE_)?USEDEP\}(,.+)?\]$") PROJECT_SYMBOL_NORMALIZE_RE = re.compile(r"[-_.]+") @@ -168,20 +168,18 @@ class PythonHasVersionUsage(results.LinesResult, results.Style): class PythonHasVersionMissingPythonUseDep(results.LineResult, results.Error): """Package calls ``python_has_version`` or ``has_version`` without - ``[${PYTHON_USEDEP}]`` suffix. + ``[${PYTHON_USEDEP}]`` or ``[${PYTHON_SINGLE_USEDEP}]`` suffix. All calls to ``python_has_version`` or ``has_version`` inside - ``python_check_deps`` should contain ``[${PYTHON_USEDEP}]`` suffix for the - dependency argument [#]_. + ``python_check_deps`` should contain ``[${PYTHON_USEDEP}]`` or ``[${PYTHON_SINGLE_USEDEP}]`` + suffix for the dependency argument [#]_. .. [#] https://projects.gentoo.org/python/guide/any.html#dependencies """ @property def desc(self): - return ( - f"line: {self.lineno}: missing [${{PYTHON_USEDEP}}] suffix for argument {self.line!r}" - ) + return f"line: {self.lineno}: missing [${{PYTHON_USEDEP}}] or [${{PYTHON_SINGLE_USEDEP}}] suffix for argument {self.line!r}" class PythonAnyMismatchedUseHasVersionCheck(results.VersionResult, results.Warning): diff --git a/testdata/repos/python/PythonCheck/PythonHasVersionUsage/PythonHasVersionUsage-2.ebuild b/testdata/repos/python/PythonCheck/PythonHasVersionUsage/PythonHasVersionUsage-2.ebuild new file mode 100644 index 00000000..5da6ad03 --- /dev/null +++ b/testdata/repos/python/PythonCheck/PythonHasVersionUsage/PythonHasVersionUsage-2.ebuild @@ -0,0 +1,25 @@ +# Copyright 2025 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +PYTHON_COMPAT=( pypy3.11 python3_10 ) + +inherit python-any-r1 + +DESCRIPTION="Ebuild that uses has_version with PYTHON_SINGLE_USEDEP" +HOMEPAGE="https://github.com/pkgcore/pkgcheck" + +LICENSE="BSD" +SLOT="0" + +DEPEND="${PYTHON_DEPS}" +BDEPEND="${PYTHON_DEPS} + $(python_gen_any_dep ' + dev-util/babeltrace:2[python,${PYTHON_SINGLE_USEDEP}] + ') +" + +python_check_deps() { + python_has_version -b "dev-util/babeltrace:2[python,${PYTHON_SINGLE_USEDEP}]" +}
