1 |
Refactor the --install-scripts rewriting logic |
2 |
in distutils-r1_python_install to be less horrid. Instead of using |
3 |
variable indirection, just inline the mydistutilsargs logic |
4 |
from esetup.py and rewrite the combined argument array. |
5 |
|
6 |
Signed-off-by: Michał Górny <mgorny@g.o> |
7 |
--- |
8 |
eclass/distutils-r1.eclass | 43 +++++++++++++++++++------------------- |
9 |
1 file changed, 21 insertions(+), 22 deletions(-) |
10 |
|
11 |
diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass |
12 |
index 53eee173a262..217f457d6bf3 100644 |
13 |
--- a/eclass/distutils-r1.eclass |
14 |
+++ b/eclass/distutils-r1.eclass |
15 |
@@ -836,7 +836,17 @@ distutils-r1_python_test() { |
16 |
distutils-r1_python_install() { |
17 |
debug-print-function ${FUNCNAME} "${@}" |
18 |
|
19 |
- local args=( "${@}" ) |
20 |
+ local root=${D%/}/_${EPYTHON} |
21 |
+ [[ ${DISTUTILS_SINGLE_IMPL} ]] && root=${D%/} |
22 |
+ |
23 |
+ # inline mydistutilsargs logic from esetup.py in order to make |
24 |
+ # argv overwriting easier |
25 |
+ local args=( |
26 |
+ "${mydistutilsargs[@]}" |
27 |
+ install --skip-build --root="${root}" "${args[@]}" |
28 |
+ "${@}" |
29 |
+ ) |
30 |
+ local mydistutilsargs=() |
31 |
|
32 |
# enable compilation for the install phase. |
33 |
local -x PYTHONDONTWRITEBYTECODE= |
34 |
@@ -852,42 +862,31 @@ distutils-r1_python_install() { |
35 |
if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then |
36 |
# user may override --install-scripts |
37 |
# note: this is poor but distutils argv parsing is dumb |
38 |
- local mydistutilsargs=( "${mydistutilsargs[@]}" ) |
39 |
local scriptdir=${EPREFIX}/usr/bin |
40 |
|
41 |
- # construct a list of mydistutilsargs[0] args[0] args[1]... |
42 |
- local arg arg_vars |
43 |
- [[ ${mydistutilsargs[@]} ]] && eval arg_vars+=( |
44 |
- 'mydistutilsargs['{0..$(( ${#mydistutilsargs[@]} - 1 ))}']' |
45 |
- ) |
46 |
- [[ ${args[@]} ]] && eval arg_vars+=( |
47 |
- 'args['{0..$(( ${#args[@]} - 1 ))}']' |
48 |
- ) |
49 |
- |
50 |
- set -- "${arg_vars[@]}" |
51 |
+ # rewrite all the arguments |
52 |
+ set -- "${args[@]}" |
53 |
+ args=() |
54 |
while [[ ${@} ]]; do |
55 |
- local arg_var=${1} |
56 |
+ local a=${1} |
57 |
shift |
58 |
- local a=${!arg_var} |
59 |
|
60 |
- case "${a}" in |
61 |
+ case ${a} in |
62 |
--install-scripts=*) |
63 |
scriptdir=${a#--install-scripts=} |
64 |
- unset "${arg_var}" |
65 |
;; |
66 |
--install-scripts) |
67 |
- scriptdir=${!1} |
68 |
- unset "${arg_var}" "${1}" |
69 |
+ scriptdir=${1} |
70 |
shift |
71 |
;; |
72 |
+ *) |
73 |
+ args+=( "${a}" ) |
74 |
+ ;; |
75 |
esac |
76 |
done |
77 |
fi |
78 |
|
79 |
- local root=${D%/}/_${EPYTHON} |
80 |
- [[ ${DISTUTILS_SINGLE_IMPL} ]] && root=${D%/} |
81 |
- |
82 |
- esetup.py install --skip-build --root="${root}" "${args[@]}" |
83 |
+ esetup.py "${args[@]}" |
84 |
|
85 |
local forbidden_package_names=( |
86 |
examples test tests |
87 |
-- |
88 |
2.32.0 |