summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2013-01-21 19:28:16 +0000
committerMichał Górny <mgorny@gentoo.org>2013-01-21 19:28:16 +0000
commit52f73ea7141b46bb1e40ca00e0471b10d0b5097b (patch)
tree8064d24e046548f63820318c03114ba556639859 /eclass
parentold (diff)
downloadhistorical-52f73ea7141b46bb1e40ca00e0471b10d0b5097b.tar.gz
historical-52f73ea7141b46bb1e40ca00e0471b10d0b5097b.tar.bz2
historical-52f73ea7141b46bb1e40ca00e0471b10d0b5097b.zip
Check PYTHON_COMPAT for validity, and support disabling implementations in the eclass.
Diffstat (limited to 'eclass')
-rw-r--r--eclass/ChangeLog7
-rw-r--r--eclass/python-any-r1.eclass13
-rw-r--r--eclass/python-r1.eclass52
-rw-r--r--eclass/python-single-r1.eclass41
-rw-r--r--eclass/python-utils-r1.eclass33
5 files changed, 112 insertions, 34 deletions
diff --git a/eclass/ChangeLog b/eclass/ChangeLog
index 1d6a9a8fa56a..abe458b051fd 100644
--- a/eclass/ChangeLog
+++ b/eclass/ChangeLog
@@ -1,6 +1,11 @@
# ChangeLog for eclass directory
# Copyright 1999-2013 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.630 2013/01/21 19:22:25 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.631 2013/01/21 19:28:16 mgorny Exp $
+
+ 21 Jan 2013; Michał Górny <mgorny@gentoo.org> python-any-r1.eclass,
+ python-r1.eclass, python-single-r1.eclass, python-utils-r1.eclass:
+ Check PYTHON_COMPAT for validity, and support disabling implementations in
+ the eclass.
21 Jan 2013; Michał Górny <mgorny@gentoo.org> multilib.eclass:
Set PKG_CONFIG_{LIBDIR,PATH} for multilib builds. Approved by vapier in bug
diff --git a/eclass/python-any-r1.eclass b/eclass/python-any-r1.eclass
index 199602a2e00a..5d9a3d1e5955 100644
--- a/eclass/python-any-r1.eclass
+++ b/eclass/python-any-r1.eclass
@@ -1,6 +1,6 @@
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python-any-r1.eclass,v 1.5 2013/01/02 21:12:44 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python-any-r1.eclass,v 1.6 2013/01/21 19:28:16 mgorny Exp $
# @ECLASS: python-any-r1
# @MAINTAINER:
@@ -134,13 +134,13 @@ _python_build_set_globals() {
}
_python_build_set_globals
-# @FUNCTION: _python_impl_supported
+# @FUNCTION: _python_EPYTHON_supported
# @USAGE: <epython>
# @INTERNAL
# @DESCRIPTION:
# Check whether the specified implementation is supported by package
# (specified in PYTHON_COMPAT).
-_python_impl_supported() {
+_python_EPYTHON_supported() {
debug-print-function ${FUNCNAME} "${@}"
local i=${1/./_}
@@ -153,6 +153,7 @@ _python_impl_supported() {
;;
*)
ewarn "Invalid EPYTHON: ${EPYTHON}"
+ return 1
;;
esac
@@ -173,7 +174,7 @@ python-any-r1_pkg_setup() {
# first, try ${EPYTHON}... maybe it's good enough for us.
if [[ ${EPYTHON} ]]; then
- if _python_impl_supported "${EPYTHON}"; then
+ if _python_EPYTHON_supported "${EPYTHON}"; then
python_export EPYTHON PYTHON
return
fi
@@ -187,7 +188,7 @@ python-any-r1_pkg_setup() {
if [[ ! ${i} ]]; then
# no eselect-python?
break
- elif _python_impl_supported "${i}"; then
+ elif _python_EPYTHON_supported "${i}"; then
python_export "${i}" EPYTHON PYTHON
return
fi
@@ -206,8 +207,6 @@ python-any-r1_pkg_setup() {
python_export "${i}" PYTHON_PKG_DEP EPYTHON PYTHON
ROOT=/ has_version "${PYTHON_PKG_DEP}" && return
done
-
- die $EPYTHON
}
_PYTHON_ANY_R1=1
diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass
index 855772716c08..63dc556b3497 100644
--- a/eclass/python-r1.eclass
+++ b/eclass/python-r1.eclass
@@ -1,6 +1,6 @@
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python-r1.eclass,v 1.36 2013/01/08 16:36:16 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python-r1.eclass,v 1.37 2013/01/21 19:28:16 mgorny Exp $
# @ECLASS: python-r1
# @MAINTAINER:
@@ -132,7 +132,24 @@ fi
# @CODE
_python_set_globals() {
- local flags=( "${PYTHON_COMPAT[@]/#/python_targets_}" )
+ local impls=()
+
+ PYTHON_DEPS=
+ local i PYTHON_PKG_DEP
+ for i in "${PYTHON_COMPAT[@]}"; do
+ _python_impl_supported "${i}" || continue
+
+ python_export "${i}" PYTHON_PKG_DEP
+ PYTHON_DEPS+="python_targets_${i}? ( ${PYTHON_PKG_DEP} ) "
+
+ impls+=( "${i}" )
+ done
+
+ if [[ ${#impls[@]} -eq 0 ]]; then
+ die "No supported implementation in PYTHON_COMPAT."
+ fi
+
+ local flags=( "${impls[@]/#/python_targets_}" )
local optflags=${flags[@]/%/?}
# A nice QA trick here. Since a python-single-r1 package has to have
@@ -141,7 +158,7 @@ _python_set_globals() {
# it should prevent developers from mistakenly depending on packages
# not supporting multiple Python implementations.
- local flags_st=( "${PYTHON_COMPAT[@]/#/-python_single_target_}" )
+ local flags_st=( "${impls[@]/#/-python_single_target_}" )
optflags+=,${flags_st[@]/%/(-)}
IUSE=${flags[*]}
@@ -152,12 +169,7 @@ _python_set_globals() {
# but no point in making this overcomplex, BDEP doesn't hurt anyone
# 2) python-exec should be built with all targets forced anyway
# but if new targets were added, we may need to force a rebuild
- PYTHON_DEPS="dev-python/python-exec[${PYTHON_USEDEP}]"
- local i PYTHON_PKG_DEP
- for i in "${PYTHON_COMPAT[@]}"; do
- python_export "${i}" PYTHON_PKG_DEP
- PYTHON_DEPS+=" python_targets_${i}? ( ${PYTHON_PKG_DEP} )"
- done
+ PYTHON_DEPS+="dev-python/python-exec[${PYTHON_USEDEP}]"
}
_python_set_globals
@@ -171,6 +183,8 @@ _python_validate_useflags() {
local i
for i in "${PYTHON_COMPAT[@]}"; do
+ _python_impl_supported "${i}" || continue
+
use "python_targets_${i}" && return 0
done
@@ -210,6 +224,8 @@ python_gen_usedep() {
local matches=()
for impl in "${PYTHON_COMPAT[@]}"; do
+ _python_impl_supported "${impl}" || continue
+
for pattern; do
if [[ ${impl} == ${pattern} ]]; then
matches+=(
@@ -249,6 +265,8 @@ python_gen_useflags() {
local matches=()
for impl in "${PYTHON_COMPAT[@]}"; do
+ _python_impl_supported "${impl}" || continue
+
for pattern; do
if [[ ${impl} == ${pattern} ]]; then
matches+=( "python_targets_${impl}" )
@@ -292,6 +310,8 @@ python_gen_cond_dep() {
shift
for impl in "${PYTHON_COMPAT[@]}"; do
+ _python_impl_supported "${impl}" || continue
+
for pattern; do
if [[ ${impl} == ${pattern} ]]; then
matches+=( "python_targets_${impl}? ( ${dep} )" )
@@ -337,6 +357,8 @@ python_copy_sources() {
einfo "Will copy sources from ${S}"
# the order is irrelevant here
for impl in "${PYTHON_COMPAT[@]}"; do
+ _python_impl_supported "${impl}" || continue
+
if use "python_targets_${impl}"
then
local BUILD_DIR=${bdir%%/}-${impl}
@@ -369,6 +391,8 @@ _python_check_USE_PYTHON() {
local impl py2 py3 dis_py2 dis_py3
for impl in "${PYTHON_COMPAT[@]}"; do
+ _python_impl_supported "${impl}" || continue
+
if use "python_targets_${impl}"; then
case "${impl}" in
python2_*)
@@ -480,6 +504,8 @@ _python_check_USE_PYTHON() {
local impl old=${USE_PYTHON} new=() removed=()
for impl in "${PYTHON_COMPAT[@]}"; do
+ _python_impl_supported "${impl}" || continue
+
local abi
case "${impl}" in
python*)
@@ -573,7 +599,9 @@ python_foreach_impl() {
debug-print "${FUNCNAME}: bdir = ${bdir}"
for impl in "${_PYTHON_ALL_IMPLS[@]}"; do
- if has "${impl}" "${PYTHON_COMPAT[@]}" && use "python_targets_${impl}"
+ if has "${impl}" "${PYTHON_COMPAT[@]}" \
+ && _python_impl_supported "${impl}" \
+ && use "python_targets_${impl}"
then
local EPYTHON PYTHON
python_export "${impl}" EPYTHON PYTHON
@@ -601,7 +629,9 @@ python_export_best() {
local impl best
for impl in "${_PYTHON_ALL_IMPLS[@]}"; do
- if has "${impl}" "${PYTHON_COMPAT[@]}" && use "python_targets_${impl}"
+ if has "${impl}" "${PYTHON_COMPAT[@]}" \
+ && _python_impl_supported "${impl}" \
+ && use "python_targets_${impl}"
then
best=${impl}
fi
diff --git a/eclass/python-single-r1.eclass b/eclass/python-single-r1.eclass
index fe2625169022..76dea7aa4d67 100644
--- a/eclass/python-single-r1.eclass
+++ b/eclass/python-single-r1.eclass
@@ -1,6 +1,6 @@
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python-single-r1.eclass,v 1.13 2013/01/08 20:18:38 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python-single-r1.eclass,v 1.14 2013/01/21 19:28:16 mgorny Exp $
# @ECLASS: python-single-r1
# @MAINTAINER:
@@ -134,8 +134,31 @@ fi
# @CODE
_python_single_set_globals() {
- local flags_mt=( "${PYTHON_COMPAT[@]/#/python_targets_}" )
- local flags=( "${PYTHON_COMPAT[@]/#/python_single_target_}" )
+ local impls=()
+
+ PYTHON_DEPS=
+ local i PYTHON_PKG_DEP
+ for i in "${PYTHON_COMPAT[@]}"; do
+ _python_impl_supported "${i}" || continue
+
+ # The chosen targets need to be in PYTHON_TARGETS as well.
+ # This is in order to enforce correct dependencies on packages
+ # supporting multiple implementations.
+ #REQUIRED_USE+=" python_single_target_${i}? ( python_targets_${i} )"
+
+ python_export "${i}" PYTHON_PKG_DEP
+ PYTHON_DEPS+="python_single_target_${i}? ( ${PYTHON_PKG_DEP} ) "
+
+ impls+=( "${i}" )
+ done
+
+ if [[ ${#impls[@]} -eq 0 ]]; then
+ die "No supported implementation in PYTHON_COMPAT."
+ fi
+
+ local flags_mt=( "${impls[@]/#/python_targets_}" )
+ local flags=( "${impls[@]/#/python_single_target_}" )
+
local optflags=${flags_mt[@]/%/?}
optflags+=,${flags[@]/%/(+)?}
@@ -147,17 +170,7 @@ _python_single_set_globals() {
# but no point in making this overcomplex, BDEP doesn't hurt anyone
# 2) python-exec should be built with all targets forced anyway
# but if new targets were added, we may need to force a rebuild
- PYTHON_DEPS="dev-python/python-exec[${PYTHON_USEDEP}]"
- local i PYTHON_PKG_DEP
- for i in "${PYTHON_COMPAT[@]}"; do
- # The chosen targets need to be in PYTHON_TARGETS as well.
- # This is in order to enforce correct dependencies on packages
- # supporting multiple implementations.
- #REQUIRED_USE+=" python_single_target_${i}? ( python_targets_${i} )"
-
- python_export "${i}" PYTHON_PKG_DEP
- PYTHON_DEPS+=" python_single_target_${i}? ( ${PYTHON_PKG_DEP} )"
- done
+ PYTHON_DEPS+="dev-python/python-exec[${PYTHON_USEDEP}]"
}
_python_single_set_globals
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index ba270b52d774..474ac08a9d21 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -1,6 +1,6 @@
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python-utils-r1.eclass,v 1.13 2013/01/05 10:01:20 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python-utils-r1.eclass,v 1.14 2013/01/21 19:28:16 mgorny Exp $
# @ECLASS: python-utils-r1
# @MAINTAINER:
@@ -47,6 +47,37 @@ _PYTHON_ALL_IMPLS=(
python2_5 python2_6 python2_7
)
+# @FUNCTION: _python_impl_supported
+# @USAGE: <impl>
+# @INTERNAL
+# @DESCRIPTION:
+# Check whether the implementation <impl> (PYTHON_COMPAT-form)
+# is still supported.
+#
+# Returns 0 if the implementation is valid and supported. If it is
+# unsupported, returns 1 -- and the caller should ignore the entry.
+# If it is invalid, dies with an appopriate error messages.
+_python_impl_supported() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ [[ ${#} -eq 1 ]] || die "${FUNCNAME}: takes exactly 1 argument (impl)."
+
+ local impl=${1}
+
+ # keep in sync with _PYTHON_ALL_IMPLS!
+ # (not using that list because inline patterns shall be faster)
+ case "${impl}" in
+ python2_[567]|python3_[123]|pypy1_[89]|pypy2_0|jython2_5)
+ return 0
+ ;;
+# pypy1_8)
+# return 1
+# ;;
+ *)
+ die "Invalid implementation in PYTHON_COMPAT: ${impl}"
+ esac
+}
+
# @ECLASS-VARIABLE: PYTHON
# @DESCRIPTION:
# The absolute path to the current Python interpreter.