Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: python@g.o, "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH] python-utils-r1.eclass: Block also pythonX.Y in wrappers
Date: Sat, 08 Sep 2018 07:09:54
Message-Id: 20180908070941.23482-1-mgorny@gentoo.org
1 Improve the wrapper blocking logic to block specific Python versions
2 as well rather than just 2/3. In other words, for eselected pythonX.Y
3 both pythonZ (Z = X^1) and python*.* (!= X.Y) will be blocked.
4 Hopefully this will catch more build systems that hardcode Python
5 versions rather than respecting what we're giving them.
6
7 This will work only for build systems respecting PATH. Build systems
8 (and ebuilds) using /usr/bin path directly will still be able to use
9 other Python versions.
10 ---
11 eclass/python-utils-r1.eclass | 12 +++++++++++-
12 1 file changed, 11 insertions(+), 1 deletion(-)
13
14 diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
15 index e3cf82b4b58f..6bcbe2e5a09f 100644
16 --- a/eclass/python-utils-r1.eclass
17 +++ b/eclass/python-utils-r1.eclass
18 @@ -1043,11 +1043,21 @@ python_wrapper_setup() {
19 nonsupp+=( 2to3 python-config "python${pyver}-config" )
20 fi
21
22 + # block all other interpreters as incompatible
23 + local orig_EPYTHON=${EPYTHON}
24 local x
25 + for x in "${_PYTHON_ALL_IMPLS[@]}"; do
26 + python_export "${x}" EPYTHON
27 + [[ ${EPYTHON} == ${orig_EPYTHON} ]] && continue
28 +
29 + nonsupp+=( "${EPYTHON}" )
30 + [[ ${EPYTHON} == python* ]] && nonsupp+=( "${EPYTHON}-config" )
31 + done
32 +
33 for x in "${nonsupp[@]}"; do
34 cat >"${workdir}"/bin/${x} <<-_EOF_ || die
35 #!/bin/sh
36 - echo "${ECLASS}: ${FUNCNAME}: ${x} is not supported by ${EPYTHON} (PYTHON_COMPAT)" >&2
37 + echo "${ECLASS}: ${FUNCNAME}: ${x} is not supported by ${orig_EPYTHON} (PYTHON_COMPAT)" >&2
38 exit 127
39 _EOF_
40 chmod +x "${workdir}"/bin/${x} || die
41 --
42 2.19.0.rc2