Gentoo Archives: gentoo-commits

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