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 1/7] python-utils-r1.eclass: Initial EAPI 7 support
Date: Thu, 03 May 2018 14:13:29
Message-Id: 20180503141248.26762-2-mgorny@gentoo.org
In Reply to: [gentoo-dev] [PATCH 0/7] Initial support for EAPI 7 for python-r1 suite by "Michał Górny"
1 Add initial EAPI 7 support. Handle trailing slash in D/ED correctly.
2 Support new has_version switches.
3
4 This does not provide proper cross support. In particular, the PYTHON
5 variable (full path to the interpreter) is used both in contexts
6 of BDEPEND and DEPEND, so we need to clean the uses first.
7 ---
8 eclass/python-utils-r1.eclass | 43 ++++++++++++++++++++++-------------
9 1 file changed, 27 insertions(+), 16 deletions(-)
10
11 diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
12 index 68fb9ba2578d..3a462e34614a 100644
13 --- a/eclass/python-utils-r1.eclass
14 +++ b/eclass/python-utils-r1.eclass
15 @@ -1,4 +1,4 @@
16 -# Copyright 1999-2017 Gentoo Foundation
17 +# Copyright 1999-2018 Gentoo Foundation
18 # Distributed under the terms of the GNU General Public License v2
19
20 # @ECLASS: python-utils-r1.eclass
21 @@ -19,7 +19,7 @@
22 # https://wiki.gentoo.org/wiki/Project:Python/python-utils-r1
23
24 case "${EAPI:-0}" in
25 - 0|1|2|3|4|5|6)
26 + 0|1|2|3|4|5|6|7)
27 ;;
28 *)
29 die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}"
30 @@ -688,8 +688,8 @@ python_optimize() {
31 # 2) skip paths which do not exist
32 # (python2.6 complains about them verbosely)
33
34 - if [[ ${f} == /* && -d ${D}${f} ]]; then
35 - set -- "${D}${f}" "${@}"
36 + if [[ ${f} == /* && -d ${D%/}${f} ]]; then
37 + set -- "${D%/}${f}" "${@}"
38 fi
39 done < <("${PYTHON}" -c 'import sys; print("\0".join(sys.path))' || die)
40
41 @@ -699,7 +699,7 @@ python_optimize() {
42 local d
43 for d; do
44 # make sure to get a nice path without //
45 - local instpath=${d#${D}}
46 + local instpath=${d#${D%/}}
47 instpath=/${instpath##/}
48
49 case "${EPYTHON}" in
50 @@ -924,7 +924,7 @@ python_domodule() {
51 doins -r "${@}" || return ${?}
52 )
53
54 - python_optimize "${ED}/${d}"
55 + python_optimize "${ED%/}/${d}"
56 }
57
58 # @FUNCTION: python_doheader
59 @@ -1086,9 +1086,20 @@ python_is_python3() {
60 python_is_installed() {
61 local impl=${1:-${EPYTHON}}
62 [[ ${impl} ]] || die "${FUNCNAME}: no impl nor EPYTHON"
63 + local hasv_args=()
64 +
65 + case ${EAPI:-0} in
66 + 0|1|2|3|4)
67 + local -x ROOT=/
68 + ;;
69 + 5|6)
70 + hasv_args+=( --host-root )
71 + ;;
72 + *)
73 + hasv_args+=( -b )
74 + ;;
75 + esac
76
77 - # for has_version
78 - local -x ROOT=/
79 case "${impl}" in
80 pypy|pypy3)
81 local append=
82 @@ -1097,13 +1108,13 @@ python_is_installed() {
83 fi
84
85 # be happy with just the interpeter, no need for the virtual
86 - has_version "dev-python/${impl}${append}" \
87 - || has_version "dev-python/${impl}-bin${append}"
88 + has_version "${hasv_args[@]}" "dev-python/${impl}${append}" \
89 + || has_version "${hasv_args[@]}" "dev-python/${impl}-bin${append}"
90 ;;
91 *)
92 local PYTHON_PKG_DEP
93 python_export "${impl}" PYTHON_PKG_DEP
94 - has_version "${PYTHON_PKG_DEP}"
95 + has_version "${hasv_args[@]}" "${PYTHON_PKG_DEP}"
96 ;;
97 esac
98 }
99 @@ -1167,7 +1178,7 @@ python_fix_shebang() {
100 for i in "${split_shebang[@]}"; do
101 case "${i}" in
102 *"${EPYTHON}")
103 - debug-print "${FUNCNAME}: in file ${f#${D}}"
104 + debug-print "${FUNCNAME}: in file ${f#${D%/}}"
105 debug-print "${FUNCNAME}: shebang matches EPYTHON: ${shebang}"
106
107 # Nothing to do, move along.
108 @@ -1176,7 +1187,7 @@ python_fix_shebang() {
109 break
110 ;;
111 *python|*python[23])
112 - debug-print "${FUNCNAME}: in file ${f#${D}}"
113 + debug-print "${FUNCNAME}: in file ${f#${D%/}}"
114 debug-print "${FUNCNAME}: rewriting shebang: ${shebang}"
115
116 if [[ ${i} == *python2 ]]; then
117 @@ -1226,7 +1237,7 @@ python_fix_shebang() {
118 fi
119
120 if [[ ! ${quiet} ]]; then
121 - einfo "Fixing shebang in ${f#${D}}."
122 + einfo "Fixing shebang in ${f#${D%/}}."
123 fi
124
125 if [[ ! ${error} ]]; then
126 @@ -1240,7 +1251,7 @@ python_fix_shebang() {
127 any_fixed=1
128 else
129 eerror "The file has incompatible shebang:"
130 - eerror " file: ${f#${D}}"
131 + eerror " file: ${f#${D%/}}"
132 eerror " current shebang: ${shebang}"
133 eerror " requested impl: ${EPYTHON}"
134 die "${FUNCNAME}: conversion of incompatible shebang requested"
135 @@ -1251,7 +1262,7 @@ python_fix_shebang() {
136 local cmd=eerror
137 [[ ${EAPI:-0} == [012345] ]] && cmd=eqawarn
138
139 - "${cmd}" "QA warning: ${FUNCNAME}, ${path#${D}} did not match any fixable files."
140 + "${cmd}" "QA warning: ${FUNCNAME}, ${path#${D%/}} did not match any fixable files."
141 if [[ ${any_correct} ]]; then
142 "${cmd}" "All files have ${EPYTHON} shebang already."
143 else
144 --
145 2.17.0