The python_check_deps() examples given in the python-r1.eclass documentation of the python_gen_any_dep and python_setup functions are incorrect. The default behavior of has_version is to check the *runtime* system (RDEPEND), but python_check_deps() is meant to check that the *build* system (BDEPEND) has a suitable Python environment. Therefore, python_check_deps() should be calling has_version with the -b option. The examples fail to do this and thus likely are leading developers to write incorrect python_check_deps() functions in their ebuilds. ---------------- Incorrect: BDEPEND="$(python_gen_any_dep ' dev-python/foo[${PYTHON_SINGLE_USEDEP}] || ( dev-python/bar[${PYTHON_USEDEP}] dev-python/baz[${PYTHON_USEDEP}] )' -2)" python_check_deps() { has_version "dev-python/foo[${PYTHON_SINGLE_USEDEP}]" \ && { has_version "dev-python/bar[${PYTHON_USEDEP}]" \ || has_version "dev-python/baz[${PYTHON_USEDEP}]"; } } Correct: BDEPEND="$(python_gen_any_dep ' dev-python/foo[${PYTHON_SINGLE_USEDEP}] || ( dev-python/bar[${PYTHON_USEDEP}] dev-python/baz[${PYTHON_USEDEP}] )' -2)" python_check_deps() { has_version -b "dev-python/foo[${PYTHON_SINGLE_USEDEP}]" \ && { has_version -b "dev-python/bar[${PYTHON_USEDEP}]" \ || has_version -b "dev-python/baz[${PYTHON_USEDEP}]"; } } ---------------- Incorrect: BDEPEND="doc? ( $(python_gen_any_dep 'dev-python/epydoc[${PYTHON_USEDEP}]' 'python2*') )" python_check_deps() { has_version "dev-python/epydoc[${PYTHON_USEDEP}]" } Correct: BDEPEND="doc? ( $(python_gen_any_dep 'dev-python/epydoc[${PYTHON_USEDEP}]' 'python2*') )" python_check_deps() { has_version -b "dev-python/epydoc[${PYTHON_USEDEP}]" }
Same problem in python-any-r1.eclass.
Looking at this again, that second example is still incorrect even after the addition of -b because its python_check_deps() function doesn't check the "doc" USE flag. ---------------- Incorrect: BDEPEND="doc? ( $(python_gen_any_dep 'dev-python/epydoc[${PYTHON_USEDEP}]' 'python2*') )" python_check_deps() { has_version "dev-python/epydoc[${PYTHON_USEDEP}]" } Correct: BDEPEND="doc? ( $(python_gen_any_dep 'dev-python/epydoc[${PYTHON_USEDEP}]' 'python2*') )" python_check_deps() { use !doc || has_version -b "dev-python/epydoc[${PYTHON_USEDEP}]" }
Note, I'm not reporting a problem with the code. I'm reporting a problem with the documentation. That's why I filed this under Documentation, Devmanual. I apologize if that was the incorrect classification.
(In reply to Matt Whitlock from comment #3) > Note, I'm not reporting a problem with the code. I'm reporting a problem > with the documentation. That's why I filed this under Documentation, > Devmanual. I apologize if that was the incorrect classification. Sorry, I should've commented: it's that eclassdocs are actually within eclasses => assign to eclass maintainers. The reference eclass documentation appears within the devmanual but it's generated from elsewhere (the eclasses themselves).
Care to submit a PR? I suppose you can use python_has_version instead which defaults to -b.
(In reply to Michał Górny from comment #5) > I suppose you can use python_has_version instead which defaults to -b. python_has_version is nice. Thanks for the tip. > Care to submit a PR? Done. https://github.com/gentoo/gentoo/pull/24647
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f80b0acf7f78971b601aabb913e067a0dde70268 commit f80b0acf7f78971b601aabb913e067a0dde70268 Author: Matt Whitlock <gentoo@mattwhitlock.name> AuthorDate: 2022-03-18 21:44:05 +0000 Commit: Michał Górny <mgorny@gentoo.org> CommitDate: 2023-08-19 18:28:11 +0000 python{,-any}-r1.eclass: use python_has_version in examples The python_check_deps() examples given in the documentation of several functions and variables in python-r1.eclass and python-any-r1.eclass are incorrect. The default behavior of has_version() is to check the *runtime* system (RDEPEND), but python_check_deps() is meant to check that the *build* system (BDEPEND) has a suitable Python environment. The examples fail to do this and thus likely are leading developers to write incorrect python_check_deps() functions in their ebuilds. Thankfully, python-utils-r1.eclass supplies a python_has_version() function that defaults to checking the build system and implements some other enhancements that make it nicer for use in python_check_deps(). Change the examples to use python_has_version. Closes: https://bugs.gentoo.org/835462 Signed-off-by: Matt Whitlock <gentoo@mattwhitlock.name> Signed-off-by: Michał Górny <mgorny@gentoo.org> eclass/python-any-r1.eclass | 6 +++--- eclass/python-r1.eclass | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-)