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