summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2012-11-24 20:53:53 +0000
committerMichał Górny <mgorny@gentoo.org>2012-11-24 20:53:53 +0000
commit858c89984ef310d6d6b51fa9b6c3f6fa8ba0d7f7 (patch)
tree90265888d76869088e6bb742232be50e6e6b4594
parentMove common Python functions to python-utils-r1. (diff)
downloadgentoo-2-858c89984ef310d6d6b51fa9b6c3f6fa8ba0d7f7.tar.gz
gentoo-2-858c89984ef310d6d6b51fa9b6c3f6fa8ba0d7f7.tar.bz2
gentoo-2-858c89984ef310d6d6b51fa9b6c3f6fa8ba0d7f7.zip
Introduce python-single-r1 to handle Python packages not supporting multiple implementations.
-rw-r--r--eclass/python-single-r1.eclass96
1 files changed, 96 insertions, 0 deletions
diff --git a/eclass/python-single-r1.eclass b/eclass/python-single-r1.eclass
new file mode 100644
index 000000000000..263849b88cd8
--- /dev/null
+++ b/eclass/python-single-r1.eclass
@@ -0,0 +1,96 @@
+# 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.1 2012/11/24 20:53:53 mgorny Exp $
+
+# @ECLASS: python-single-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 Python packages not installed for multiple implementations.
+# @DESCRIPTION:
+# An extension of the python-r1 eclass suite for packages which
+# don't support being installed for multiple Python implementations.
+# This mostly includes tools embedding Python.
+#
+# This eclass extends the IUSE and REQUIRED_USE set by python-r1
+# to request correct PYTHON_SINGLE_TARGET. It also replaces
+# PYTHON_USEDEP and PYTHON_DEPS with a more suitable form.
+#
+# Please note that packages support multiple Python implementations
+# (using python-r1 eclass) can not depend on packages not supporting
+# them (using this eclass).
+#
+# Also, please note that python-single-r1 will always inherit python-r1
+# as well. Thus, all the variables defined there are relevant
+# to the packages using python-single-r1.
+#
+# 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}" in
+ 0|1|2|3)
+ die "Unsupported EAPI=${EAPI} (too old) for ${ECLASS}"
+ ;;
+ 4|5)
+ # EAPI=4 needed by python-r1
+ ;;
+ *)
+ die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}"
+ ;;
+esac
+
+inherit python-r1
+
+EXPORT_FUNCTIONS pkg_setup
+
+_python_single_set_globals() {
+ local flags=( "${PYTHON_COMPAT[@]/#/python_single_target_}" )
+ local optflags=${flags[@]/%/(+)?}
+
+ IUSE=${flags[*]}
+ REQUIRED_USE="^^ ( ${flags[*]} )"
+ PYTHON_USEDEP+=,${optflags// /,}
+
+ local usestr
+ [[ ${PYTHON_REQ_USE} ]] && usestr="[${PYTHON_REQ_USE}]"
+
+ # 1) well, python-exec would suffice as an RDEP
+ # 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
+ for i in "${PYTHON_COMPAT[@]}"; 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]}
+ PYTHON_DEPS+=" python_single_target_${i}? ( ${d}:${v/_/.}${usestr} )"
+ done
+}
+_python_single_set_globals
+
+python-single-r1_pkg_setup() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ for impl in "${_PYTHON_ALL_IMPLS[@]}"; do
+ if has "${impl}" "${PYTHON_COMPAT[@]}" \
+ && use "python_single_target_${impl}"
+ then
+ python_export "${impl}" EPYTHON PYTHON
+ break
+ fi
+ done
+}