commit: 8b2a03095469242427067911fd4bc467173753c1
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 12 22:20:26 2015 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Dec 22 22:12:23 2015 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8b2a0309
python-any-r1.eclass: Support PYTHON_COMPAT_OVERRIDE
eclass/python-any-r1.eclass | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/eclass/python-any-r1.eclass b/eclass/python-any-r1.eclass
index dbfeded..99aac73 100644
--- a/eclass/python-any-r1.eclass
+++ b/eclass/python-any-r1.eclass
@@ -72,6 +72,24 @@ if [[ ! ${_PYTHON_ANY_R1} ]]; then
# PYTHON_COMPAT=( python{2_5,2_6,2_7} )
# @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 will be used to build the package. 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 dependencies. The value of
+# EPYTHON and eselect-python preferences are ignored. 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:
@@ -253,6 +271,23 @@ _python_EPYTHON_supported() {
python_setup() {
debug-print-function ${FUNCNAME} "${@}"
+ # 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-any-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
EPYTHON/eselect-python will be ignored."
+
+ python_export "${impls[0]}" EPYTHON PYTHON
+ python_wrapper_setup
+ return
+ fi
+
# first, try ${EPYTHON}... maybe it's good enough for us.
if [[ ${EPYTHON} ]]; then
if _python_EPYTHON_supported "${EPYTHON}"; then