summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'eclass/python-any-r1.eclass')
-rw-r--r--eclass/python-any-r1.eclass48
1 files changed, 38 insertions, 10 deletions
diff --git a/eclass/python-any-r1.eclass b/eclass/python-any-r1.eclass
index 9fd7fd6bc27d..5f2dc5b8f384 100644
--- a/eclass/python-any-r1.eclass
+++ b/eclass/python-any-r1.eclass
@@ -24,9 +24,10 @@
# be called by the eclass with EPYTHON set to each matching Python
# implementation and it is expected to check whether the implementation
# fulfills the package requirements. You can use the locally exported
-# PYTHON_USEDEP to check USE-dependencies of relevant packages. It
-# should return a true value (0) if the Python implementation fulfills
-# the requirements, a false value (non-zero) otherwise.
+# PYTHON_USEDEP or PYTHON_SINGLE_USEDEP to check USE-dependencies
+# of relevant packages. It should return a true value (0) if the Python
+# implementation fulfills the requirements, a false value (non-zero)
+# otherwise.
#
# Please note that python-any-r1 will always inherit python-utils-r1
# as well. Thus, all the functions defined there can be used in the
@@ -131,8 +132,9 @@ EXPORT_FUNCTIONS pkg_setup
# An eclass-generated USE-dependency string for the currently tested
# implementation. It is set locally for python_check_deps() call.
#
-# The generate USE-flag list is compatible with packages using python-r1
-# eclass. It must not be used on packages using other eclasses.
+# The generated USE-flag list is compatible with packages using
+# python-r1 eclass. For python-single-r1 dependencies,
+# use PYTHON_SINGLE_USEDEP.
#
# Example use:
# @CODE
@@ -146,6 +148,28 @@ EXPORT_FUNCTIONS pkg_setup
# python_targets_python3_7(-),-python_single_target_python3_7(-)
# @CODE
+# @ECLASS-VARIABLE: PYTHON_SINGLE_USEDEP
+# @OUTPUT_VARIABLE
+# @DESCRIPTION:
+# An eclass-generated USE-dependency string for the currently tested
+# implementation. It is set locally for python_check_deps() call.
+#
+# The generated USE-flag list is compatible with packages using
+# python-single-r1 eclass. For python-r1 dependencies,
+# use PYTHON_USEDEP.
+#
+# Example use:
+# @CODE
+# python_check_deps() {
+# has_version "dev-python/bar[${PYTHON_SINGLE_USEDEP}]"
+# }
+# @CODE
+#
+# Example value:
+# @CODE
+# python_single_target_python3_7(-)
+# @CODE
+
_python_any_set_globals() {
local usestr deps i PYTHON_PKG_DEP
[[ ${PYTHON_REQ_USE} ]] && usestr="[${PYTHON_REQ_USE}]"
@@ -189,7 +213,8 @@ if [[ ! ${_PYTHON_ANY_R1} ]]; then
# Generate an any-of dependency that enforces a version match between
# the Python interpreter and Python packages. <dependency-block> needs
# to list one or more dependencies with verbatim '${PYTHON_USEDEP}'
-# references (quoted!) that will get expanded inside the function.
+# or '${PYTHON_SINGLE_USEDEP}' references (quoted!) that will get
+# expanded inside the function.
#
# This should be used along with an appropriate python_check_deps()
# that checks which of the any-of blocks were matched.
@@ -197,12 +222,12 @@ if [[ ! ${_PYTHON_ANY_R1} ]]; then
# Example use:
# @CODE
# DEPEND="$(python_gen_any_dep '
-# dev-python/foo[${PYTHON_USEDEP}]
+# dev-python/foo[${PYTHON_SINGLE_USEDEP}]
# || ( dev-python/bar[${PYTHON_USEDEP}]
# dev-python/baz[${PYTHON_USEDEP}] )')"
#
# python_check_deps() {
-# has_version "dev-python/foo[${PYTHON_USEDEP}]" \
+# has_version "dev-python/foo[${PYTHON_SINGLE_USEDEP}]" \
# && { has_version "dev-python/bar[${PYTHON_USEDEP}]" \
# || has_version "dev-python/baz[${PYTHON_USEDEP}]"; }
# }
@@ -213,13 +238,13 @@ if [[ ! ${_PYTHON_ANY_R1} ]]; then
# || (
# (
# dev-lang/python:3.7
-# dev-python/foo[python_targets_python3_7(-),-python_single_target_python3_7(-)]
+# dev-python/foo[python_single_target_python3_7(-)]
# || ( dev-python/bar[python_targets_python3_7(-),-python_single_target_python3_7(-)]
# dev-python/baz[python_targets_python3_7(-),-python_single_target_python3_7(-)] )
# )
# (
# dev-lang/python:3.8
-# dev-python/foo[python_targets_python3_8(-),-python_single_target_python3_8(-)]
+# dev-python/foo[python_single_target_python3_8(-)]
# || ( dev-python/bar[python_targets_python3_8(-),-python_single_target_python3_8(-)]
# dev-python/baz[python_targets_python3_8(-),-python_single_target_python3_8(-)] )
# )
@@ -234,9 +259,11 @@ python_gen_any_dep() {
local i PYTHON_PKG_DEP out=
for i in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do
local PYTHON_USEDEP="python_targets_${i}(-),-python_single_target_${i}(-)"
+ local PYTHON_SINGLE_USEDEP="python_single_target_${i}(-)"
_python_export "${i}" PYTHON_PKG_DEP
local i_depstr=${depstr//\$\{PYTHON_USEDEP\}/${PYTHON_USEDEP}}
+ i_depstr=${i_depstr//\$\{PYTHON_SINGLE_USEDEP\}/${PYTHON_SINGLE_USEDEP}}
# note: need to strip '=' slot operator for || deps
out="( ${PYTHON_PKG_DEP%=} ${i_depstr} ) ${out}"
done
@@ -268,6 +295,7 @@ _python_EPYTHON_supported() {
if python_is_installed "${i}"; then
if declare -f python_check_deps >/dev/null; then
local PYTHON_USEDEP="python_targets_${i}(-),-python_single_target_${i}(-)"
+ local PYTHON_SINGLE_USEDEP="python_single_target_${i}(-)"
python_check_deps
return ${?}
fi