Gentoo Archives: gentoo-dev

From: Mike Gilbert <floppym@g.o>
To: "Michał Górny" <mgorny@g.o>
Cc: Gentoo Dev <gentoo-dev@l.g.o>, Gentoo Python Project <python@g.o>
Subject: [gentoo-dev] Re: [PATCH] Check for USE_PYTHON <-> PYTHON_TARGETS equiv.
Date: Mon, 05 Nov 2012 15:23:27
Message-Id: CAJ0EP42FBERJp2pL48p6sMfPk5jcszPFDpLbw=uaZ7JGh8uzMA@mail.gmail.com
In Reply to: [gentoo-dev] [PATCH] Check for USE_PYTHON <-> PYTHON_TARGETS equiv. by "Michał Górny"
1 On Mon, Nov 5, 2012 at 6:59 AM, Michał Górny <mgorny@g.o> wrote:
2 > ---
3 > gx86/eclass/python-r1.eclass | 66 ++++++++++++++++++++++++++++++++++++++++++++
4 > 1 file changed, 66 insertions(+)
5 >
6 > diff --git a/gx86/eclass/python-r1.eclass b/gx86/eclass/python-r1.eclass
7 > index 0d6ef4c..6d4eb33 100644
8 > --- a/gx86/eclass/python-r1.eclass
9 > +++ b/gx86/eclass/python-r1.eclass
10 > @@ -363,6 +363,70 @@ python_copy_sources() {
11 > done
12 > }
13 >
14 > +# @FUNCTION: _python_check_USE_PYTHON
15 > +# @INTERNAL
16 > +# @DESCRIPTION:
17 > +# Check whether USE_PYTHON and PYTHON_TARGETS are in sync. Output
18 > +# warnings if they are not.
19 > +_python_check_USE_PYTHON() {
20 > + if [[ ! ${_PYTHON_USE_PYTHON_CHECKED} ]]; then
21 > + _PYTHON_USE_PYTHON_CHECKED=1
22 > +
23 > + local USE_PYTHON=${USE_PYTHON}
24 > +
25 > + if [[ ! ${USE_PYTHON} ]]; then
26 > + # default to selected Python2+3
27 > + if has_version app-admin/eselect-python; then
28 > + local py2=$(eselect python show --python2)
29 > + local py3=$(eselect python show --python3)
30 > +
31 > + USE_PYTHON="${py2#python} ${py3#python}"
32 > + fi
33 > + fi
34 > +
35 > + local impl warned
36 > + for impl in "${PYTHON_COMPAT[@]}"; do
37 > + local abi
38 > + case "${impl}" in
39 > + python*)
40 > + abi=${impl#python}
41 > + ;;
42 > + jython*)
43 > + abi=${impl#jython}-jython
44 > + ;;
45 > + pypy*)
46 > + abi=2.7-pypy-${impl#pypy}
47 > + ;;
48 > + *)
49 > + die "Unexpected Python implementation: ${impl}"
50 > + ;;
51 > + esac
52 > +
53 > + has "${abi/_/.}" ${USE_PYTHON}
54 > + local has_abi=${?}
55 > + use "python_targets_${impl}"
56 > + local has_impl=${?}
57 > +
58 > + if [[ ${has_abi} != ${has_impl} ]]; then
59 > + if [[ ! ${warned} ]]; then
60 > + ewarn "PYTHON_TARGETS <-> USE_PYTHON inconsistency found. This may result"
61 > + ewarn "in missing modules when trying to use Python packages. Please ensure"
62 > + ewarn "that the same implementations are listed in both variables."
63 > + ewarn
64 > +
65 > + warned=1
66 > + fi
67 > +
68 > + if [[ ${has_abi} == 0 ]]; then
69 > + ewarn "Implementation ${impl} disabled but ${abi/_/.} in USE_PYTHON"
70 > + else
71 > + ewarn "Implementation ${impl} enabled but ${abi/_/.} not in USE_PYTHON"
72 > + fi
73 > + fi
74 > + done
75 > + fi
76 > +}
77 > +
78 > # @FUNCTION: python_foreach_impl
79 > # @USAGE: <command> [<args>...]
80 > # @DESCRIPTION:
81 > @@ -376,6 +440,8 @@ python_copy_sources() {
82 > python_foreach_impl() {
83 > debug-print-function ${FUNCNAME} "${@}"
84 >
85 > + _python_check_USE_PYTHON
86 > +
87 > local impl
88 > local bdir=${BUILD_DIR:-${S}}
89 >
90 > --
91 > 1.7.12.4
92 >
93
94 We should not encourage users to set USE_PYTHON if it has not been set
95 already; the variable is pretty much undocumented, and should probably
96 stay that way. If USE_PYTHON is unset, we should advise them to update
97 PYTHON_TARGETS to match their active python2 and python3 versions
98 (from eselect python).

Replies