1 |
commit: 45df9e6b42511ed01a367ab2552b761682730c01 |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Dec 30 16:09:59 2019 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Dec 30 16:09:59 2019 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=45df9e6b |
7 |
|
8 |
metadata/install-qa-check.d/60python-pyc: Add EAPI guard |
9 |
|
10 |
Closes: https://bugs.gentoo.org/704286 |
11 |
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> |
12 |
|
13 |
metadata/install-qa-check.d/60python-pyc | 135 ++++++++++++++++--------------- |
14 |
1 file changed, 69 insertions(+), 66 deletions(-) |
15 |
|
16 |
diff --git a/metadata/install-qa-check.d/60python-pyc b/metadata/install-qa-check.d/60python-pyc |
17 |
index ef668aed995..644c27243cd 100644 |
18 |
--- a/metadata/install-qa-check.d/60python-pyc |
19 |
+++ b/metadata/install-qa-check.d/60python-pyc |
20 |
@@ -4,81 +4,84 @@ |
21 |
# QA check: ensure that Python modules are compiled after installing |
22 |
# Maintainer: Python project <python@g.o> |
23 |
|
24 |
-inherit python-utils-r1 |
25 |
+if [[ ${EAPI} == [5-7] ]]; then |
26 |
+ inherit python-utils-r1 |
27 |
|
28 |
-python_pyc_check() { |
29 |
- local impl missing=() outdated=() |
30 |
- for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do |
31 |
- python_export "${impl}" EPYTHON PYTHON |
32 |
- [[ -x ${PYTHON} ]] || continue |
33 |
- local sitedir=$(python_get_sitedir "${impl}") |
34 |
+ python_pyc_check() { |
35 |
+ local impl missing=() outdated=() |
36 |
+ for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do |
37 |
+ python_export "${impl}" EPYTHON PYTHON |
38 |
+ [[ -x ${PYTHON} ]] || continue |
39 |
+ local sitedir=$(python_get_sitedir "${impl}") |
40 |
|
41 |
- if [[ -d ${D}${sitedir} ]]; then |
42 |
- local suffixes=() subdir= |
43 |
- case ${EPYTHON} in |
44 |
- python2*) |
45 |
- suffixes=( .py{c,o} ) |
46 |
- ;; |
47 |
- pypy) |
48 |
- suffixes=( .pyc ) |
49 |
- ;; |
50 |
- python3*|pypy3*) |
51 |
- local tag=$("${PYTHON}" -c 'import sys; print(sys.implementation.cache_tag)') |
52 |
- suffixes=( ".${tag}"{,.opt-{1,2}}.pyc ) |
53 |
- subdir=__pycache__/ |
54 |
- ;; |
55 |
- *) |
56 |
- # skip testing unknown impl |
57 |
- continue |
58 |
- ;; |
59 |
- esac |
60 |
+ if [[ -d ${D}${sitedir} ]]; then |
61 |
+ local suffixes=() subdir= |
62 |
+ case ${EPYTHON} in |
63 |
+ python2*) |
64 |
+ suffixes=( .py{c,o} ) |
65 |
+ ;; |
66 |
+ pypy) |
67 |
+ suffixes=( .pyc ) |
68 |
+ ;; |
69 |
+ python3*|pypy3*) |
70 |
+ local tag=$("${PYTHON}" -c 'import sys; print(sys.implementation.cache_tag)') |
71 |
+ suffixes=( ".${tag}"{,.opt-{1,2}}.pyc ) |
72 |
+ subdir=__pycache__/ |
73 |
+ ;; |
74 |
+ *) |
75 |
+ # skip testing unknown impl |
76 |
+ continue |
77 |
+ ;; |
78 |
+ esac |
79 |
|
80 |
- einfo "Verifying compiled files in ${sitedir}" |
81 |
- local f s |
82 |
- while read -d $'\0' -r f; do |
83 |
- local dir=${f%/*} |
84 |
- local basename=${f##*/} |
85 |
- basename=${basename%.py} |
86 |
+ einfo "Verifying compiled files in ${sitedir}" |
87 |
+ local f s |
88 |
+ while read -d $'\0' -r f; do |
89 |
+ local dir=${f%/*} |
90 |
+ local basename=${f##*/} |
91 |
+ basename=${basename%.py} |
92 |
|
93 |
- for s in "${suffixes[@]}"; do |
94 |
- local cache=${dir}/${subdir}${basename}${s} |
95 |
- if [[ ! -f ${cache} ]]; then |
96 |
- missing+=( "${cache}" ) |
97 |
- elif [[ ${f} -nt ${cache} ]]; then |
98 |
- outdated+=( "${cache}" ) |
99 |
- fi |
100 |
- done |
101 |
- done < <(find "${D}${sitedir}" -name '*.py' -print0) |
102 |
+ for s in "${suffixes[@]}"; do |
103 |
+ local cache=${dir}/${subdir}${basename}${s} |
104 |
+ if [[ ! -f ${cache} ]]; then |
105 |
+ missing+=( "${cache}" ) |
106 |
+ elif [[ ${f} -nt ${cache} ]]; then |
107 |
+ outdated+=( "${cache}" ) |
108 |
+ fi |
109 |
+ done |
110 |
+ done < <(find "${D}${sitedir}" -name '*.py' -print0) |
111 |
+ fi |
112 |
+ done |
113 |
+ |
114 |
+ if [[ ${missing[@]} ]]; then |
115 |
+ eqawarn |
116 |
+ eqawarn "This package installs one or more Python modules that are not byte-compiled." |
117 |
+ eqawarn "The following files are missing:" |
118 |
+ eqawarn |
119 |
+ eqatag -v python-pyc.missing "${missing[@]#${D}}" |
120 |
fi |
121 |
- done |
122 |
|
123 |
- if [[ ${missing[@]} ]]; then |
124 |
- eqawarn |
125 |
- eqawarn "This package installs one or more Python modules that are not byte-compiled." |
126 |
- eqawarn "The following files are missing:" |
127 |
- eqawarn |
128 |
- eqatag -v python-pyc.missing "${missing[@]#${D}}" |
129 |
- fi |
130 |
+ if [[ ${outdated[@]} ]]; then |
131 |
+ eqawarn |
132 |
+ eqawarn "This package installs one or more compiled Python modules that have older" |
133 |
+ eqawarn "timestamps than the corresponding source files:" |
134 |
+ eqawarn |
135 |
+ eqatag -v python-pyc.outdated "${outdated[@]#${D}}" |
136 |
+ fi |
137 |
|
138 |
- if [[ ${outdated[@]} ]]; then |
139 |
- eqawarn |
140 |
- eqawarn "This package installs one or more compiled Python modules that have older" |
141 |
- eqawarn "timestamps than the corresponding source files:" |
142 |
- eqawarn |
143 |
- eqatag -v python-pyc.outdated "${outdated[@]#${D}}" |
144 |
- fi |
145 |
+ if [[ ${missing[@]} || ${outdated[@]} ]]; then |
146 |
+ eqawarn |
147 |
+ eqawarn "Please either fix the upstream build system to byte-compile Python modules" |
148 |
+ eqawarn "correctly, or call python_optimize after installing them. For more" |
149 |
+ eqawarn "information, see:" |
150 |
+ eqawarn "https://wiki.gentoo.org/wiki/Project:Python/Byte_compiling" |
151 |
+ eqawarn |
152 |
+ fi |
153 |
+ } |
154 |
|
155 |
- if [[ ${missing[@]} || ${outdated[@]} ]]; then |
156 |
- eqawarn |
157 |
- eqawarn "Please either fix the upstream build system to byte-compile Python modules" |
158 |
- eqawarn "correctly, or call python_optimize after installing them. For more" |
159 |
- eqawarn "information, see:" |
160 |
- eqawarn "https://wiki.gentoo.org/wiki/Project:Python/Byte_compiling" |
161 |
- eqawarn |
162 |
- fi |
163 |
-} |
164 |
+ python_pyc_check |
165 |
+fi |
166 |
|
167 |
-python_pyc_check |
168 |
: # guarantee successful exit |
169 |
|
170 |
# vim:ft=ebuild |