summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2012-12-01 09:29:24 +0000
committerMichał Górny <mgorny@gentoo.org>2012-12-01 09:29:24 +0000
commita5d00d252f35324b8a418c7abbdfb88dcd3cbf42 (patch)
treef82b8b504b8cc8ba12c6aa50bac330e8279954ce /eclass
parentFix CVE-2012-4405 (diff)
downloadgentoo-2-a5d00d252f35324b8a418c7abbdfb88dcd3cbf42.tar.gz
gentoo-2-a5d00d252f35324b8a418c7abbdfb88dcd3cbf42.tar.bz2
gentoo-2-a5d00d252f35324b8a418c7abbdfb88dcd3cbf42.zip
Introduce python-any-r1, to handle packages satisfied by any Python implementation installed (e.g. strictly build-time dependent).
Diffstat (limited to 'eclass')
-rw-r--r--eclass/ChangeLog7
-rw-r--r--eclass/python-any-r1.eclass174
-rw-r--r--eclass/python-r1.eclass4
-rw-r--r--eclass/python-single-r1.eclass4
4 files changed, 186 insertions, 3 deletions
diff --git a/eclass/ChangeLog b/eclass/ChangeLog
index bb0bbf715066..96e6f2a7479b 100644
--- a/eclass/ChangeLog
+++ b/eclass/ChangeLog
@@ -1,6 +1,11 @@
# ChangeLog for eclass directory
# Copyright 1999-2012 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.532 2012/11/30 22:57:26 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.533 2012/12/01 09:29:24 mgorny Exp $
+
+ 01 Dec 2012; Michał Górny <mgorny@gentoo.org> +python-any-r1.eclass,
+ python-r1.eclass, python-single-r1.eclass:
+ Introduce python-any-r1, to handle packages satisfied by any Python
+ implementation installed (e.g. strictly build-time dependent).
30 Nov 2012; Michał Górny <mgorny@gentoo.org> python-single-r1.eclass:
Add missing REQUIRED_USE constraints to enforce PYTHON_SINGLE_TARGET being in
diff --git a/eclass/python-any-r1.eclass b/eclass/python-any-r1.eclass
new file mode 100644
index 000000000000..7f48f20a0e19
--- /dev/null
+++ b/eclass/python-any-r1.eclass
@@ -0,0 +1,174 @@
+# Copyright 1999-2012 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.1 2012/12/01 09:29:24 mgorny Exp $
+
+# @ECLASS: python-any-r1
+# @MAINTAINER:
+# Michał Górny <mgorny@gentoo.org>
+# Python herd <python@gentoo.org>
+# @AUTHOR:
+# Author: Michał Górny <mgorny@gentoo.org>
+# Based on work of: Krzysztof Pawlik <nelchael@gentoo.org>
+# @BLURB: An eclass for packages having build-time dependency on Python.
+# @DESCRIPTION:
+# A minimal eclass for packages which need any Python interpreter
+# installed without a need for explicit choice and invariability.
+# This usually involves packages requiring Python at build-time
+# but having no other relevance to it.
+#
+# This eclass provides a minimal PYTHON_DEPS variable with a dependency
+# string on any of the supported Python implementations. It also exports
+# pkg_setup() which finds the best supported implementation and sets it
+# as the active one.
+#
+# Please note that python-any-r1 will always inherit python-utils-r1
+# as well. Thus, all the functions defined there can be used in the
+# packages using python-any-r1, and there is no need ever to inherit
+# both.
+#
+# For more information, please see the python-r1 Developer's Guide:
+# http://www.gentoo.org/proj/en/Python/python-r1/dev-guide.xml
+
+case "${EAPI:-0}" in
+ 0|1|2|3|4|5)
+ # EAPI=4 needed by python-r1
+ ;;
+ *)
+ die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}"
+ ;;
+esac
+
+if [[ ! ${_PYTHON_ANY_R1} ]]; then
+
+if [[ ${_PYTHON_R1} ]]; then
+ die 'python-any-r1.eclass can not be used with python-r1.eclass.'
+elif [[ ${_PYTHON_SINGLE_R1} ]]; then
+ die 'python-any-r1.eclass can not be used with python-single-r1.eclass.'
+fi
+
+inherit python-utils-r1
+
+fi
+
+EXPORT_FUNCTIONS pkg_setup
+
+if [[ ! ${_PYTHON_ANY_R1} ]]; then
+
+# @ECLASS-VARIABLE: PYTHON_COMPAT
+# @REQUIRED
+# @DESCRIPTION:
+# This variable contains a list of Python implementations the package
+# supports. It must be set before the `inherit' call. It has to be
+# an array.
+#
+# Example:
+# @CODE
+# PYTHON_COMPAT=( python{2_5,2_6,2_7} )
+# @CODE
+if ! declare -p PYTHON_COMPAT &>/dev/null; then
+ die 'PYTHON_COMPAT not declared.'
+fi
+
+# @ECLASS-VARIABLE: PYTHON_REQ_USE
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# The list of USEflags required to be enabled on the Python
+# implementations, formed as a USE-dependency string. It should be valid
+# for all implementations in PYTHON_COMPAT, so it may be necessary to
+# use USE defaults.
+#
+# Example:
+# @CODE
+# PYTHON_REQ_USE="gdbm,ncurses(-)?"
+# @CODE
+#
+# It will cause the Python dependencies to look like:
+# @CODE
+# || ( dev-lang/python:X.Y[gdbm,ncurses(-)?] ... )
+# @CODE
+
+# @ECLASS-VARIABLE: PYTHON_DEPS
+# @DESCRIPTION:
+# This is an eclass-generated Python dependency string for all
+# implementations listed in PYTHON_COMPAT.
+#
+# Any of the supported interpreters will satisfy the dependency.
+#
+# Example use:
+# @CODE
+# DEPEND="${RDEPEND}
+# ${PYTHON_DEPS}"
+# @CODE
+#
+# Example value:
+# @CODE
+# || ( dev-lang/python:2.7[gdbm]
+# dev-lang/python:2.6[gdbm] )
+# @CODE
+
+_python_build_set_globals() {
+ local usestr
+ [[ ${PYTHON_REQ_USE} ]] && usestr="[${PYTHON_REQ_USE}]"
+
+ PYTHON_DEPS=
+ local i
+ for i in "${_PYTHON_ALL_IMPLS[@]}"; do
+ if has "${i}" "${PYTHON_COMPAT[@]}"
+ then
+ local d
+ case ${i} in
+ python*)
+ d='dev-lang/python';;
+ jython*)
+ d='dev-java/jython';;
+ pypy*)
+ d='dev-python/pypy';;
+ *)
+ die "Invalid implementation: ${i}"
+ esac
+
+ local v=${i##*[a-z]}
+ PYTHON_DEPS="${d}:${v/_/.}${usestr} ${PYTHON_DEPS}"
+ fi
+ done
+ PYTHON_DEPS="|| ( ${PYTHON_DEPS})"
+}
+_python_build_set_globals
+
+# @FUNCTION: python-any-r1_pkg_setup
+# @DESCRIPTION:
+# Determine what the best installed (and supported) Python
+# implementation is and set EPYTHON and PYTHON accordingly.
+python-any-r1_pkg_setup() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ local i rev_impls=()
+ for i in "${_PYTHON_ALL_IMPLS[@]}"; do
+ if has "${i}" "${PYTHON_COMPAT[@]}"; then
+ rev_impls=( "${i}" "${rev_impls[@]}" )
+ fi
+ done
+
+ for i in "${rev_impls[@]}"; do
+ local d
+ case "${i}" in
+ python*)
+ d='dev-lang/python';;
+ jython*)
+ d='dev-java/jython';;
+ pypy*)
+ d='dev-python/pypy';;
+ *)
+ die "Invalid implementation: ${i}"
+ esac
+ local v=${i##*[a-z]}
+
+ if has_version "${d}:${v/_/.}${usestr}"; then
+ python_export "${i}" EPYTHON PYTHON
+ break
+ fi
+ done
+}
+
+_PYTHON_ANY_R1=1
+fi
diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass
index 3e1a4d2240ed..39de7f2f27eb 100644
--- a/eclass/python-r1.eclass
+++ b/eclass/python-r1.eclass
@@ -1,6 +1,6 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python-r1.eclass,v 1.24 2012/11/30 11:40:15 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python-r1.eclass,v 1.25 2012/12/01 09:29:24 mgorny Exp $
# @ECLASS: python-r1
# @MAINTAINER:
@@ -44,6 +44,8 @@ if [[ ! ${_PYTHON_R1} ]]; then
if [[ ${_PYTHON_SINGLE_R1} ]]; then
die 'python-r1.eclass can not be used with python-single-r1.eclass.'
+elif [[ ${_PYTHON_ANY_R1} ]]; then
+ die 'python-r1.eclass can not be used with python-any-r1.eclass.'
fi
inherit python-utils-r1
diff --git a/eclass/python-single-r1.eclass b/eclass/python-single-r1.eclass
index 66915a1b2256..51807f2725ad 100644
--- a/eclass/python-single-r1.eclass
+++ b/eclass/python-single-r1.eclass
@@ -1,6 +1,6 @@
# Copyright 1999-2012 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.6 2012/11/30 22:57:26 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python-single-r1.eclass,v 1.7 2012/12/01 09:29:24 mgorny Exp $
# @ECLASS: python-single-r1
# @MAINTAINER:
@@ -47,6 +47,8 @@ if [[ ! ${_PYTHON_SINGLE_R1} ]]; then
if [[ ${_PYTHON_R1} ]]; then
die 'python-single-r1.eclass can not be used with python-r1.eclass.'
+elif [[ ${_PYTHON_ANY_R1} ]]; then
+ die 'python-single-r1.eclass can not be used with python-any-r1.eclass.'
fi
inherit python-utils-r1