Gentoo Archives: gentoo-dev

From: Sebastian Pipping <sping@g.o>
To: gentoo-dev@l.g.o
Cc: Gentoo Python Project <python@g.o>
Subject: [gentoo-dev] [rfc] Sane defaults for USE_PYTHON, patch to python eclass
Date: Sat, 04 Dec 2010 00:24:24
Message-Id: 4CF98A0D.9030605@gentoo.org
1 Hello!
2
3
4 Current situation
5 =================
6 Without specifying USE_PYTHON in /etc/make.conf ebuilds based on the
7 python eclass will install packages for no more ABIs than the two active
8 versions on the 2.x and 3.x lines. To give an example: with Python 2.6,
9 2.7 and 3.1 installed and 2.7 set as the active 2.x Python version I
10 would get files installed for python 2.7 and 3.1, but not 2.6.
11
12 Is that a sane default? Especially when a new slot of Python arrives at
13 the Gentoo tree, you run into situations with two slots of Python 2.x
14 installed. To have packages functioning with both, you would need a
15 custom USE_PYTHON line like USE_PYTHON="2.6 2.7" - otherwise one of
16 these slots' Python will be very limited.
17
18 This problem is made worse by the fact that USE_PYTHON has almost no
19 documentation. This bug shows well, that the current behavior is a
20 surprising troublemaker:
21
22 https://bugs.gentoo.org/show_bug.cgi?id=347153
23
24
25 Proposed new situation
26 ======================
27 If I have a version of Python installed, it should be usable well.
28 So USE_PYTHON is derived from the list of all available Python slots.
29 Excluded are ABIs restricted by an ebuild, say by a line like
30
31 RESTRICT_PYTHON_ABIS="3.*"
32
33 for software that does not build with Python 3.x.
34
35
36 Proposed code
37 =============
38 I would love to just pass a patch here - I have two files to diff
39 between - but (due to the algorithm diff works with) the patch is much
40 less clear as the relevant excerpt itself.
41
42 If you want a patch or the file version get my modified python.eclass
43 file from here:
44 http://hartwork.org/public/python.eclass
45
46 So now comes the excerpt (with tabs converted to double spaces just for
47 this mail). The code is meant to fill variable PYTHON_ABIS with content
48 like "2.6 2.7" in case of no USE_PYTHON line around.
49
50 =======================================================================
51 debug-print 'USE_PYTHON not specified in make.conf, deriving default'
52 # - include all installed ABIs
53 # - but exclude those restricted by the ebuild
54
55 local PYTHON_ABI restricted_ABI restricted_ABIs support_ABI
56 python_versions
57
58 restricted_ABIs="${RESTRICT_PYTHON_ABIS// /$'\n'}"
59 python_versions=("${_CPYTHON2_SUPPORTED_ABIS[@]}"
60 "${_CPYTHON3_SUPPORTED_ABIS[@]}")
61
62 for PYTHON_ABI in ${python_versions[@]} ; do
63 # ABI available?
64 local interpreter="${EPREFIX}"/usr/bin/python${PYTHON_ABI}
65 if [[ ! -x "${interpreter}" ]]; then
66 debug-print "Disabling ABI ${PYTHON_ABI} (interpreter
67 ${interpreter} missing)"
68 continue
69 fi
70
71 # ABI restricted by ebuild?
72 support_ABI="1"
73 while read restricted_ABI; do
74 if [[ "${PYTHON_ABI}" == ${restricted_ABI} ]]; then
75 support_ABI="0"
76 break
77 fi
78 done <<< "${restricted_ABIs}"
79 if [[ "${support_ABI}" != "1" ]]; then
80 debug-print "Disabling ABI ${PYTHON_ABI} (due to restrictions from
81 the ebuild)"
82 continue
83 fi
84
85 debug-print "Enabling ABI ${PYTHON_ABI}"
86 export PYTHON_ABIS+="${PYTHON_ABIS:+ }${PYTHON_ABI}"
87 done
88
89 export PYTHON_ABIS="${PYTHON_ABIS% }"
90 debug-print "PYTHON_ABIS now is '${PYTHON_ABIS}'"
91 =======================================================================
92
93 Please review the proposal and above code. Thanks in advance.
94 ECLASS_DEBUG_OUTPUT=on may be of use when testing.
95
96 Best,
97
98
99
100 Sebastian

Replies