Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH 3/5] python-any-r1.eclass: Support PYTHON_COMPAT_OVERRIDE
Date: Thu, 17 Dec 2015 22:04:58
Message-Id: 1450389778-10144-4-git-send-email-mgorny@gentoo.org
In Reply to: [gentoo-dev] [PATCH 0/5] python*-r1: commonize PYTHON_COMPAT handling by "Michał Górny"
1 ---
2 eclass/python-any-r1.eclass | 35 +++++++++++++++++++++++++++++++++++
3 1 file changed, 35 insertions(+)
4
5 diff --git a/eclass/python-any-r1.eclass b/eclass/python-any-r1.eclass
6 index dbfeded..99aac73 100644
7 --- a/eclass/python-any-r1.eclass
8 +++ b/eclass/python-any-r1.eclass
9 @@ -72,6 +72,24 @@ if [[ ! ${_PYTHON_ANY_R1} ]]; then
10 # PYTHON_COMPAT=( python{2_5,2_6,2_7} )
11 # @CODE
12
13 +# @ECLASS-VARIABLE: PYTHON_COMPAT_OVERRIDE
14 +# @INTERNAL
15 +# @DESCRIPTION:
16 +# This variable can be used when working with ebuilds to override
17 +# the in-ebuild PYTHON_COMPAT. It is a string naming the implementation
18 +# which will be used to build the package. It needs to be specified
19 +# in the calling environment, and not in ebuilds.
20 +#
21 +# It should be noted that in order to preserve metadata immutability,
22 +# PYTHON_COMPAT_OVERRIDE does not affect dependencies. The value of
23 +# EPYTHON and eselect-python preferences are ignored. Dependencies need
24 +# to be satisfied manually.
25 +#
26 +# Example:
27 +# @CODE
28 +# PYTHON_COMPAT_OVERRIDE='pypy' emerge -1v dev-python/bar
29 +# @CODE
30 +
31 # @ECLASS-VARIABLE: PYTHON_REQ_USE
32 # @DEFAULT_UNSET
33 # @DESCRIPTION:
34 @@ -253,6 +271,23 @@ _python_EPYTHON_supported() {
35 python_setup() {
36 debug-print-function ${FUNCNAME} "${@}"
37
38 + # support developer override
39 + if [[ ${PYTHON_COMPAT_OVERRIDE} ]]; then
40 + local impls=( ${PYTHON_COMPAT_OVERRIDE} )
41 + [[ ${#impls[@]} -eq 1 ]] || die "PYTHON_COMPAT_OVERRIDE must name exactly one implementation for python-any-r1"
42 +
43 + ewarn "WARNING: PYTHON_COMPAT_OVERRIDE in effect. The following Python"
44 + ewarn "implementation will be used:"
45 + ewarn
46 + ewarn " ${PYTHON_COMPAT_OVERRIDE}"
47 + ewarn
48 + ewarn "Dependencies won't be satisfied, and EPYTHON/eselect-python will be ignored."
49 +
50 + python_export "${impls[0]}" EPYTHON PYTHON
51 + python_wrapper_setup
52 + return
53 + fi
54 +
55 # first, try ${EPYTHON}... maybe it's good enough for us.
56 if [[ ${EPYTHON} ]]; then
57 if _python_EPYTHON_supported "${EPYTHON}"; then
58 --
59 2.6.4