summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2021-06-20 11:20:46 +0200
committerMichał Górny <mgorny@gentoo.org>2021-06-23 23:44:22 +0200
commit7f4b4348f0527146f74f0478764618fc62a5a777 (patch)
tree9cc97287cbec001f407510ad377eca1f03b61884 /eclass/distutils-r1.eclass
parentpython-r1.eclass: Enable EAPI 8 (diff)
downloadgentoo-7f4b4348f0527146f74f0478764618fc62a5a777.tar.gz
gentoo-7f4b4348f0527146f74f0478764618fc62a5a777.tar.bz2
gentoo-7f4b4348f0527146f74f0478764618fc62a5a777.zip
distutils-r1.eclass: Refactor --install-scripts rewriting logic
Refactor the --install-scripts rewriting logic in distutils-r1_python_install to be less horrid. Instead of using variable indirection, just inline the mydistutilsargs logic from esetup.py and rewrite the combined argument array. Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'eclass/distutils-r1.eclass')
-rw-r--r--eclass/distutils-r1.eclass43
1 files changed, 21 insertions, 22 deletions
diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index 53eee173a262..217f457d6bf3 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -836,7 +836,17 @@ distutils-r1_python_test() {
distutils-r1_python_install() {
debug-print-function ${FUNCNAME} "${@}"
- local args=( "${@}" )
+ local root=${D%/}/_${EPYTHON}
+ [[ ${DISTUTILS_SINGLE_IMPL} ]] && root=${D%/}
+
+ # inline mydistutilsargs logic from esetup.py in order to make
+ # argv overwriting easier
+ local args=(
+ "${mydistutilsargs[@]}"
+ install --skip-build --root="${root}" "${args[@]}"
+ "${@}"
+ )
+ local mydistutilsargs=()
# enable compilation for the install phase.
local -x PYTHONDONTWRITEBYTECODE=
@@ -852,42 +862,31 @@ distutils-r1_python_install() {
if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then
# user may override --install-scripts
# note: this is poor but distutils argv parsing is dumb
- local mydistutilsargs=( "${mydistutilsargs[@]}" )
local scriptdir=${EPREFIX}/usr/bin
- # construct a list of mydistutilsargs[0] args[0] args[1]...
- local arg arg_vars
- [[ ${mydistutilsargs[@]} ]] && eval arg_vars+=(
- 'mydistutilsargs['{0..$(( ${#mydistutilsargs[@]} - 1 ))}']'
- )
- [[ ${args[@]} ]] && eval arg_vars+=(
- 'args['{0..$(( ${#args[@]} - 1 ))}']'
- )
-
- set -- "${arg_vars[@]}"
+ # rewrite all the arguments
+ set -- "${args[@]}"
+ args=()
while [[ ${@} ]]; do
- local arg_var=${1}
+ local a=${1}
shift
- local a=${!arg_var}
- case "${a}" in
+ case ${a} in
--install-scripts=*)
scriptdir=${a#--install-scripts=}
- unset "${arg_var}"
;;
--install-scripts)
- scriptdir=${!1}
- unset "${arg_var}" "${1}"
+ scriptdir=${1}
shift
;;
+ *)
+ args+=( "${a}" )
+ ;;
esac
done
fi
- local root=${D%/}/_${EPYTHON}
- [[ ${DISTUTILS_SINGLE_IMPL} ]] && root=${D%/}
-
- esetup.py install --skip-build --root="${root}" "${args[@]}"
+ esetup.py "${args[@]}"
local forbidden_package_names=(
examples test tests