Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH 4/6] Support PYTHON_COMPAT being an array.
Date: Wed, 19 Sep 2012 10:05:30
Message-Id: 1348048827-1290-4-git-send-email-mgorny@gentoo.org
In Reply to: [gentoo-dev] [PATCH 1/6] Drop pointless default S assignment. by "Michał Górny"
1 ---
2 gx86/eclass/python-distutils-ng.eclass | 27 ++++++++++++++++-----------
3 1 file changed, 16 insertions(+), 11 deletions(-)
4
5 diff --git a/gx86/eclass/python-distutils-ng.eclass b/gx86/eclass/python-distutils-ng.eclass
6 index 8427994..edc38a4 100644
7 --- a/gx86/eclass/python-distutils-ng.eclass
8 +++ b/gx86/eclass/python-distutils-ng.eclass
9 @@ -32,6 +32,9 @@
10 # This variable contains a space separated list of implementations (see above) a
11 # package is compatible to. It must be set before the `inherit' call. The
12 # default is to enable all implementations.
13 +#
14 +# PYTHON_COMPAT can be either a scalar or an array. If it's a scalar, the eclass
15 +# will implicitly convert it to an array.
16
17 if [[ -z "${PYTHON_COMPAT}" ]]; then
18 # Default: pure python, support all implementations
19 @@ -41,6 +44,8 @@ if [[ -z "${PYTHON_COMPAT}" ]]; then
20 PYTHON_COMPAT+=" pypy1_8 pypy1_9"
21 fi
22
23 +PYTHON_COMPAT=( ${PYTHON_COMPAT[@]} )
24 +
25 # @ECLASS-VARIABLE: PYTHON_DISABLE_COMPILATION
26 # @DEFAULT_UNSET
27 # @DESCRIPTION:
28 @@ -88,14 +93,14 @@ _python-distutils-ng_get_binary_for_implementation() {
29 }
30
31 required_use_str=""
32 -for impl in ${PYTHON_COMPAT}; do
33 +for impl in ${PYTHON_COMPAT[@]}; do
34 required_use_str+=" python_targets_${impl}"
35 done
36 required_use_str=" || ( ${required_use_str} )"
37 REQUIRED_USE+=" ${required_use_str}"
38 unset required_use_str
39
40 -for impl in ${PYTHON_COMPAT}; do
41 +for impl in ${PYTHON_COMPAT[@]}; do
42 IUSE+=" python_targets_${impl}"
43 dep_str="${impl/_/.}"
44 case "${dep_str}" in
45 @@ -147,8 +152,8 @@ _python-distutils-ng_run_for_impl() {
46 _python-distutils-ng_run_for_each_impl() {
47 local command="${1}"
48
49 - for impl in ${PYTHON_COMPAT}; do
50 - use "python_targets_${impl}" ${PYTHON_COMPAT} || continue
51 + for impl in ${PYTHON_COMPAT[@]}; do
52 + use "python_targets_${impl}" ${PYTHON_COMPAT[@]} || continue
53 _python-distutils-ng_run_for_impl "${impl}" "${command}"
54 done
55 }
56 @@ -247,7 +252,7 @@ python-distutils-ng_newscript() {
57 local destination_directory="/usr/bin"
58 [[ -n "${3}" ]] && destination_directory="${3}"
59
60 - for impl in ${PYTHON_COMPAT}; do
61 + for impl in ${PYTHON_COMPAT[@]}; do
62 use "python_targets_${impl}" || continue
63 enabled_impls=$((enabled_impls + 1))
64 done
65 @@ -274,8 +279,8 @@ python-distutils-ng_newscript() {
66 python-distutils-ng_rewrite_hashbang "${D}${destination_directory}/${destination_file}" "${default_impl}"
67 else
68 einfo "Installing ${source_file} for multiple implementations (default: ${default_impl}) in ${destination_directory}"
69 - for impl in ${PYTHON_COMPAT}; do
70 - use "python_targets_${impl}" ${PYTHON_COMPAT} || continue
71 + for impl in ${PYTHON_COMPAT[@]}; do
72 + use "python_targets_${impl}" ${PYTHON_COMPAT[@]} || continue
73
74 newins "${source_file}" "${destination_file}-${impl}"
75 fperms 755 "${destination_directory}/${destination_file}-${impl}"
76 @@ -289,8 +294,8 @@ python-distutils-ng_newscript() {
77 # Phase function: src_prepare
78 python-distutils-ng_src_prepare() {
79 # Try to run binary for each implementation:
80 - for impl in ${PYTHON_COMPAT}; do
81 - use "python_targets_${impl}" ${PYTHON_COMPAT} || continue
82 + for impl in ${PYTHON_COMPAT[@]}; do
83 + use "python_targets_${impl}" ${PYTHON_COMPAT[@]} || continue
84 $(_python-distutils-ng_get_binary_for_implementation "${impl}") \
85 -c "import sys" || die
86 done
87 @@ -302,8 +307,8 @@ python-distutils-ng_src_prepare() {
88 fi
89
90 # Create a copy of S for each implementation:
91 - for impl in ${PYTHON_COMPAT}; do
92 - use "python_targets_${impl}" ${PYTHON_COMPAT} || continue
93 + for impl in ${PYTHON_COMPAT[@]}; do
94 + use "python_targets_${impl}" ${PYTHON_COMPAT[@]} || continue
95
96 einfo "Creating copy for ${impl} in ${WORKDIR}/impl_${impl}"
97 mkdir -p "${WORKDIR}/impl_${impl}" || die
98 --
99 1.7.12