New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
python-r1.eclass: use python_has_version in examples of python_check_deps() #24647
Conversation
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>
has_version() defaults to checking the runtime system (-r), but python_check_deps() is meant to check the suitability of the build system (-b). python-utils-r1.eclass supplies python_has_version() for use in python_check_deps(), which defaults to -b. Use that function in scons-utils_python_check_deps(). Signed-off-by: Matt Whitlock <gentoo@mattwhitlock.name>
e5e2f70
to
880156e
Compare
Pull Request assignmentSubmitter: @whitslack @gentoo/github Linked bugsBugs linked: 835462 New packagesThis Pull Request appears to be introducing new packages only. Due to limited manpower, adding new packages is considered low priority. This does not mean that your Pull Request will not receive any attention, however, it might take quite some time for it to be reviewed. In the meantime, your new ebuild might find a home in the GURU project repository: the ebuild repository maintained collaboratively by Gentoo users. GURU offers your ebuild a place to be reviewed and improved by other Gentoo users, while making it easy for Gentoo users to install it and enjoy the software it adds. In order to force reassignment and/or bug reference scan, please append Docs: Code of Conduct ● Copyright policy (expl.) ● Devmanual ● GitHub PRs ● Proxy-maint guide |
Pull request CI reportReport generated at: 2022-03-18 23:47 UTC There are existing issues already. Please look into the report to make sure none of them affect the packages in question: |
Pull request CI reportReport generated at: 2022-03-19 00:03 UTC There are existing issues already. Please look into the report to make sure none of them affect the packages in question: |
@@ -683,7 +683,7 @@ python_foreach_impl() { | |||
# $(python_gen_any_dep 'dev-python/epydoc[${PYTHON_USEDEP}]' 'python2*') )" | |||
# | |||
# python_check_deps() { | |||
# has_version "dev-python/epydoc[${PYTHON_USEDEP}]" | |||
# use !doc || python_has_version "dev-python/epydoc[${PYTHON_USEDEP}]" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the newer examples prefer:
use doc || return 0
python_has_version ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I'll change it to that for consistency. It's functionally identical, though, right? And what if you had multiple different sets of use flags to check?
BDEPEND="$(python_gen_any_dep '
foo? ( dev-python/foo[${PYTHON_USEDEP}] )
bar? ( dev-python/bar[${PYTHON_USEDEP}] )
')"
Then what would you put in python_check_deps()
? I like my way because it structurally mirrors the syntax of BDEPEND
.
python_check_deps() {
{ use !foo || python_has_version "dev-python/foo[${PYTHON_USEDEP}]"; } &&
{ use !bar || python_has_version "dev-python/bar[${PYTHON_USEDEP}]"; }
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But that thing is horribly hard to read. Even the foo && { bar || baz; }
thing is ugly. To be honest, I'm wondering if maybe we should just remove the examples from eclassdoc and expect people to read the Guide.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But that thing is horribly hard to read.
Is it? Maybe for a complete n00b of a programmer. But again, I really was asking what you would put in python_check_deps()
in such a case. Would you write it all out like this?:
python_check_deps() {
if use foo ; then
python_has_version "dev-python/foo[${PYTHON_USEDEP}]" || return $?
fi
if use bar ; then
python_has_version "dev-python/bar[${PYTHON_USEDEP}]" || return $?
fi
}
Are you really arguing that that's less "horrible" than the compact form that I wrote using &&
?
Anyway, I find the whole mechanism of python_check_deps()
really awkward, as it requires duplicating the python_gen_any_dep
dependencies of the package but with different syntax. It would be so much nicer if an ebuild author could write:
BDEPEND="$(python_gen_any_dep '
foo? ( dev-python/foo[${PYTHON_SINGLE_USEDEP}] )
|| ( dev-python/bar[${PYTHON_USEDEP}]
dev-python/baz[${PYTHON_USEDEP}] )
')"
python_get_any_deps() {
echo "
foo? ( dev-python/foo[${PYTHON_SINGLE_USEDEP}] )
|| ( dev-python/bar[${PYTHON_USEDEP}]
dev-python/baz[${PYTHON_USEDEP}] )
"
}
And then the eclass would handle parsing of the returned dependency spec, including the flag? ( … )
and || ( … )
syntaxes. This would allow a straight copy+paste of the value of the python_gen_any_dep
argument to the python_get_any_deps()
output, with just a change from single-quoting to double-quoting to enable variable substitution.
This solution could co-exist with python_check_deps()
.
Side note: A devilishly clever ebuild author could even avoid the copy+paste rigmarole by doing this:
python_get_any_deps() {
echo "
foo? ( dev-python/foo[${PYTHON_SINGLE_USEDEP}] )
|| ( dev-python/bar[${PYTHON_USEDEP}]
dev-python/baz[${PYTHON_USEDEP}] )
"
}
BDEPEND="$(python_gen_any_dep "$(
PYTHON_SINGLE_USEDEP='${PYTHON_SINGLE_USEDEP}' \
PYTHON_USEDEP='${PYTHON_USEDEP}' \
python_get_any_deps)")"
Effectively reusing the ebuild's definition of python_get_any_deps()
to construct the argument to python_gen_any_dep
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have implemented the python_get_any_deps()
alternative in #24677. Please have a look there.
I'm sorry, I have forgotten about this. I'll merge it now since the doc changes are good. |
commit f80b0ac
|
The
python_check_deps()
examples given in the documentation of several functions and variables inpython-r1.eclass
andpython-any-r1.eclass
are incorrect. The default behavior ofhas_version()
is to check the runtime system (RDEPEND
), butpython_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 incorrectpython_check_deps()
functions in their ebuilds. Thankfully,python-utils-r1.eclass
supplies apython_has_version()
function that defaults to checking the build system and implements some other enhancements that make it nicer for use inpython_check_deps()
. Change the examples to usepython_has_version
.This PR fixes Bug 835462.