diff options
author | Michał Górny <mgorny@gentoo.org> | 2022-02-04 15:46:51 +0100 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2022-02-15 20:12:31 +0100 |
commit | 9e323d64b378d595c0c8e670d4316217bc98e850 (patch) | |
tree | 85f6637b04dabebaefbb6b28eb0400f109df630b /eclass/python-utils-r1.eclass | |
parent | distutils-r1.eclass: Require explicit root for d_pep517_install (diff) | |
download | gentoo-9e323d64b378d595c0c8e670d4316217bc98e850.tar.gz gentoo-9e323d64b378d595c0c8e670d4316217bc98e850.tar.bz2 gentoo-9e323d64b378d595c0c8e670d4316217bc98e850.zip |
python-utils-r1.eclass: Add a verbose python_has_version() wrapper
Add a python_has_version() wrapper for convenient use
in python_check_deps(). It includes:
- verbose output
- default "-b" root that's more suitable for build-time checks
- forward compatibility for -b/-d/-r arguments in EAPI 6
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'eclass/python-utils-r1.eclass')
-rw-r--r-- | eclass/python-utils-r1.eclass | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass index 204392e08da4..5f8c49298090 100644 --- a/eclass/python-utils-r1.eclass +++ b/eclass/python-utils-r1.eclass @@ -1397,5 +1397,47 @@ _python_run_check_deps() { eend ${?} } +# @FUNCTION: python_has_version +# @USAGE: [-b|-d|-r] <atom>... +# @DESCRIPTION: +# A convenience wrapper for has_version() with verbose output and better +# defaults for use in python_check_deps(). +# +# The wrapper accepts EAPI 7+-style -b/-d/-r options to indicate +# the root to perform the lookup on. Unlike has_version, the default +# is -b. In EAPI 6, -b and -d are translated to --host-root +# for compatibility. +# +# The wrapper accepts multiple package specifications. For the check +# to succeed, *all* specified atoms must match. +python_has_version() { + debug-print-function ${FUNCNAME} "${@}" + + local root_arg=( -b ) + case ${1} in + -b|-d|-r) + root_arg=( "${1}" ) + shift + ;; + esac + + if [[ ${EAPI} == 6 ]]; then + if [[ ${root_arg} == -r ]]; then + root_arg=() + else + root_arg=( --host-root ) + fi + fi + + local pkg + for pkg; do + ebegin " ${pkg}" + has_version "${root_arg[@]}" "${pkg}" + eend ${?} || return + done + + return 0 +} + _PYTHON_UTILS_R1=1 fi |