summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2015-12-12 23:21:11 +0100
committerMichał Górny <mgorny@gentoo.org>2015-12-22 23:12:23 +0100
commit4a1560e50bfa935eacec648af6310dd914ff2489 (patch)
treee16962165b819e8f9366526331d00d46f44ebcb5
parentpython-any-r1.eclass: Support PYTHON_COMPAT_OVERRIDE (diff)
downloadgentoo-4a1560e50bfa935eacec648af6310dd914ff2489.tar.gz
gentoo-4a1560e50bfa935eacec648af6310dd914ff2489.tar.bz2
gentoo-4a1560e50bfa935eacec648af6310dd914ff2489.zip
python-single-r1.eclass: Support PYTHON_COMPAT_OVERRIDE
-rw-r--r--eclass/python-single-r1.eclass36
1 files changed, 36 insertions, 0 deletions
diff --git a/eclass/python-single-r1.eclass b/eclass/python-single-r1.eclass
index 4c4f0576b860..4d5026fc9b31 100644
--- a/eclass/python-single-r1.eclass
+++ b/eclass/python-single-r1.eclass
@@ -96,6 +96,25 @@ if [[ ! ${_PYTHON_SINGLE_R1} ]]; then
# PYTHON_COMPAT=( python2_7 python3_{3,4} )
# @CODE
+# @ECLASS-VARIABLE: PYTHON_COMPAT_OVERRIDE
+# @INTERNAL
+# @DESCRIPTION:
+# This variable can be used when working with ebuilds to override
+# the in-ebuild PYTHON_COMPAT. It is a string naming the implementation
+# which package will be built for. It needs to be specified
+# in the calling environment, and not in ebuilds.
+#
+# It should be noted that in order to preserve metadata immutability,
+# PYTHON_COMPAT_OVERRIDE does not affect IUSE nor dependencies.
+# The state of PYTHON_TARGETS and PYTHON_SINGLE_TARGET is ignored,
+# and the implementation in PYTHON_COMPAT_OVERRIDE is built instead.
+# Dependencies need to be satisfied manually.
+#
+# Example:
+# @CODE
+# PYTHON_COMPAT_OVERRIDE='pypy' emerge -1v dev-python/bar
+# @CODE
+
# @ECLASS-VARIABLE: PYTHON_REQ_USE
# @DEFAULT_UNSET
# @DESCRIPTION:
@@ -401,6 +420,23 @@ python_setup() {
unset EPYTHON
+ # support developer override
+ if [[ ${PYTHON_COMPAT_OVERRIDE} ]]; then
+ local impls=( ${PYTHON_COMPAT_OVERRIDE} )
+ [[ ${#impls[@]} -eq 1 ]] || die "PYTHON_COMPAT_OVERRIDE must name exactly one implementation for python-single-r1"
+
+ ewarn "WARNING: PYTHON_COMPAT_OVERRIDE in effect. The following Python"
+ ewarn "implementation will be used:"
+ ewarn
+ ewarn " ${PYTHON_COMPAT_OVERRIDE}"
+ ewarn
+ ewarn "Dependencies won't be satisfied, and PYTHON_SINGLE_TARGET flags will be ignored."
+
+ python_export "${impls[0]}" EPYTHON PYTHON
+ python_wrapper_setup
+ return
+ fi
+
if [[ ${#_PYTHON_SUPPORTED_IMPLS[@]} -eq 1 ]]; then
if use "python_targets_${_PYTHON_SUPPORTED_IMPLS[0]}"; then
# Only one supported implementation, enable it explicitly