commit: 4a1560e50bfa935eacec648af6310dd914ff2489 Author: Michał Górny <mgorny <AT> gentoo <DOT> org> AuthorDate: Sat Dec 12 22:21:11 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=4a1560e5
python-single-r1.eclass: Support PYTHON_COMPAT_OVERRIDE eclass/python-single-r1.eclass | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/eclass/python-single-r1.eclass b/eclass/python-single-r1.eclass index 4c4f057..4d5026f 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