Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Gentoo Development (http://www.linux-archive.org/gentoo-development/)
-   -   Support PYTHON_COMPAT being an array. (http://www.linux-archive.org/gentoo-development/705448-support-python_compat-being-array.html)

Michał Górny 09-19-2012 10:00 AM

Support PYTHON_COMPAT being an array.
 
---
gx86/eclass/python-distutils-ng.eclass | 27 ++++++++++++++++-----------
1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/gx86/eclass/python-distutils-ng.eclass b/gx86/eclass/python-distutils-ng.eclass
index 8427994..edc38a4 100644
--- a/gx86/eclass/python-distutils-ng.eclass
+++ b/gx86/eclass/python-distutils-ng.eclass
@@ -32,6 +32,9 @@
# This variable contains a space separated list of implementations (see above) a
# package is compatible to. It must be set before the `inherit' call. The
# default is to enable all implementations.
+#
+# PYTHON_COMPAT can be either a scalar or an array. If it's a scalar, the eclass
+# will implicitly convert it to an array.

if [[ -z "${PYTHON_COMPAT}" ]]; then
# Default: pure python, support all implementations
@@ -41,6 +44,8 @@ if [[ -z "${PYTHON_COMPAT}" ]]; then
PYTHON_COMPAT+=" pypy1_8 pypy1_9"
fi

+PYTHON_COMPAT=( ${PYTHON_COMPAT[@]} )
+
# @ECLASS-VARIABLE: PYTHON_DISABLE_COMPILATION
# @DEFAULT_UNSET
# @DESCRIPTION:
@@ -88,14 +93,14 @@ _python-distutils-ng_get_binary_for_implementation() {
}

required_use_str=""
-for impl in ${PYTHON_COMPAT}; do
+for impl in ${PYTHON_COMPAT[@]}; do
required_use_str+=" python_targets_${impl}"
done
required_use_str=" || ( ${required_use_str} )"
REQUIRED_USE+=" ${required_use_str}"
unset required_use_str

-for impl in ${PYTHON_COMPAT}; do
+for impl in ${PYTHON_COMPAT[@]}; do
IUSE+=" python_targets_${impl}"
dep_str="${impl/_/.}"
case "${dep_str}" in
@@ -147,8 +152,8 @@ _python-distutils-ng_run_for_impl() {
_python-distutils-ng_run_for_each_impl() {
local command="${1}"

- for impl in ${PYTHON_COMPAT}; do
- use "python_targets_${impl}" ${PYTHON_COMPAT} || continue
+ for impl in ${PYTHON_COMPAT[@]}; do
+ use "python_targets_${impl}" ${PYTHON_COMPAT[@]} || continue
_python-distutils-ng_run_for_impl "${impl}" "${command}"
done
}
@@ -247,7 +252,7 @@ python-distutils-ng_newscript() {
local destination_directory="/usr/bin"
[[ -n "${3}" ]] && destination_directory="${3}"

- for impl in ${PYTHON_COMPAT}; do
+ for impl in ${PYTHON_COMPAT[@]}; do
use "python_targets_${impl}" || continue
enabled_impls=$((enabled_impls + 1))
done
@@ -274,8 +279,8 @@ python-distutils-ng_newscript() {
python-distutils-ng_rewrite_hashbang "${D}${destination_directory}/${destination_file}" "${default_impl}"
else
einfo "Installing ${source_file} for multiple implementations (default: ${default_impl}) in ${destination_directory}"
- for impl in ${PYTHON_COMPAT}; do
- use "python_targets_${impl}" ${PYTHON_COMPAT} || continue
+ for impl in ${PYTHON_COMPAT[@]}; do
+ use "python_targets_${impl}" ${PYTHON_COMPAT[@]} || continue

newins "${source_file}" "${destination_file}-${impl}"
fperms 755 "${destination_directory}/${destination_file}-${impl}"
@@ -289,8 +294,8 @@ python-distutils-ng_newscript() {
# Phase function: src_prepare
python-distutils-ng_src_prepare() {
# Try to run binary for each implementation:
- for impl in ${PYTHON_COMPAT}; do
- use "python_targets_${impl}" ${PYTHON_COMPAT} || continue
+ for impl in ${PYTHON_COMPAT[@]}; do
+ use "python_targets_${impl}" ${PYTHON_COMPAT[@]} || continue
$(_python-distutils-ng_get_binary_for_implementation "${impl}")
-c "import sys" || die
done
@@ -302,8 +307,8 @@ python-distutils-ng_src_prepare() {
fi

# Create a copy of S for each implementation:
- for impl in ${PYTHON_COMPAT}; do
- use "python_targets_${impl}" ${PYTHON_COMPAT} || continue
+ for impl in ${PYTHON_COMPAT[@]}; do
+ use "python_targets_${impl}" ${PYTHON_COMPAT[@]} || continue

einfo "Creating copy for ${impl} in ${WORKDIR}/impl_${impl}"
mkdir -p "${WORKDIR}/impl_${impl}" || die
--
1.7.12


All times are GMT. The time now is 04:29 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.