FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Gentoo > Gentoo Development

 
 
LinkBack Thread Tools
 
Old 09-24-2012, 09:49 PM
Michał Górny
 
Default p-d-ng: split out default impl selection logic.

Move the logic out of doscript() to make it reusable. Also, use
_PYTHON_ALL_IMPLS[@] instead of hardcoding the preference list.
---
gx86/eclass/python-distutils-ng.eclass | 38 +++++++++++++++++++++-------------
1 file changed, 24 insertions(+), 14 deletions(-)

diff --git a/gx86/eclass/python-distutils-ng.eclass b/gx86/eclass/python-distutils-ng.eclass
index 33d183c..ab13ffc 100644
--- a/gx86/eclass/python-distutils-ng.eclass
+++ b/gx86/eclass/python-distutils-ng.eclass
@@ -160,6 +160,29 @@ python-distutils-ng_doscript() {
python-distutils-ng_newscript "${1}" "$(basename "${1}")" "${2}"
}

+# Get the preferred implementation for the symlink.
+_python-distutils-ng_get_best_impl() {
+ local defimpl=${PYTHON_DEFAULT_IMPLEMENTATION}
+
+ if [[ ${defimpl} ]]; then
+ if use ${defimpl}; then
+ echo ${defimpl}
+ else
+ die "default implementation ${defimpl} not enabled."
+ fi
+ else
+ local impl
+ for impl in ${_PYTHON_ALL_IMPLS[@]}; do
+ if use python_targets_${impl}; then
+ echo "${impl}"
+ return
+ fi
+ done
+ fi
+
+ die "unable to find a default Python implementation."
+}
+
# @FUNCTION: python-distutils-ng_newscript
# @USAGE: script_file_name new_file_name [destination_directory]
# @DESCRIPTION:
@@ -184,7 +207,7 @@ python-distutils-ng_newscript() {
[[ -n "${2}" ]] || die "Missing destination file name"
local source_file="${1}"
local destination_file="${2}"
- local default_impl="${PYTHON_DEFAULT_IMPLEMENTATION}"
+ local default_impl=$(_python-distutils-ng_get_best_impl)
local enabled_impls=0
local destination_directory="/usr/bin"
[[ -n "${3}" ]] && destination_directory="${3}"
@@ -194,19 +217,6 @@ python-distutils-ng_newscript() {
enabled_impls=$((enabled_impls + 1))
done

- if [[ -z "${default_impl}" ]]; then
- for impl in python{2_7,2_6,2_5,3_2,3_1} pypy{1_9,1_8,1_7} jython2_5; do
- use "python_targets_${impl}" || continue
- default_impl="${impl}"
- break
- done
- else
- use "python_targets_${default_impl}" ||
- die "default implementation ${default_impl} not enabled"
- fi
-
- [[ -n "${default_impl}" ]] || die "Could not select default implementation"
-
dodir "${destination_directory}"
insinto "${destination_directory}"
if [[ "${enabled_impls}" = "1" ]]; then
--
1.7.12
 

Thread Tools




All times are GMT. The time now is 04:33 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org