summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2013-01-27 16:39:23 +0000
committerMichał Górny <mgorny@gentoo.org>2013-01-27 16:39:23 +0000
commitd5207eab0ef69f621cfbc81f5d73acbfd7b44072 (patch)
treea08b09a7c38ac8f352545263a5fdb76e5ca086e8 /eclass
parentStable for amd64, wrt bug #451422 (diff)
downloadgentoo-2-d5207eab0ef69f621cfbc81f5d73acbfd7b44072.tar.gz
gentoo-2-d5207eab0ef69f621cfbc81f5d73acbfd7b44072.tar.bz2
gentoo-2-d5207eab0ef69f621cfbc81f5d73acbfd7b44072.zip
Support using distutils-r1 along with python-single-r1.
Diffstat (limited to 'eclass')
-rw-r--r--eclass/ChangeLog5
-rw-r--r--eclass/distutils-r1.eclass116
2 files changed, 94 insertions, 27 deletions
diff --git a/eclass/ChangeLog b/eclass/ChangeLog
index 3b2f22e9855c..a14d9b58c65b 100644
--- a/eclass/ChangeLog
+++ b/eclass/ChangeLog
@@ -1,6 +1,9 @@
# ChangeLog for eclass directory
# Copyright 1999-2013 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.649 2013/01/27 16:37:28 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.650 2013/01/27 16:39:23 mgorny Exp $
+
+ 27 Jan 2013; Michał Górny <mgorny@gentoo.org> distutils-r1.eclass:
+ Support using distutils-r1 along with python-single-r1.
27 Jan 2013; Michał Górny <mgorny@gentoo.org> distutils-r1.eclass:
Support making dependency and phase function enforcement optional.
diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index b5ab8e2570ff..27730f579244 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-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/distutils-r1.eclass,v 1.47 2013/01/27 16:37:28 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/distutils-r1.eclass,v 1.48 2013/01/27 16:39:23 mgorny Exp $
# @ECLASS: distutils-r1
# @MAINTAINER:
@@ -66,9 +66,26 @@ esac
# distutils-r1 default phase functions or call the build system
# manually.
+# @ECLASS-VARIABLE: DISTUTILS_SINGLE_IMPL
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# If set to a non-null value, the ebuild will support setting a single
+# Python implementation only. It will effectively replace the python-r1
+# eclass inherit with python-single-r1.
+#
+# Note that inheriting python-single-r1 will cause pkg_setup()
+# to be exported. It must be run in order for the eclass functions
+# to function properly.
+
if [[ ! ${_DISTUTILS_R1} ]]; then
-inherit eutils multiprocessing python-r1
+inherit eutils
+
+if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then
+ inherit multiprocessing python-r1
+else
+ inherit python-single-r1
+fi
fi
@@ -237,7 +254,8 @@ distutils-r1_python_prepare_all() {
fi
fi
- if [[ ${DISTUTILS_IN_SOURCE_BUILD} ]]; then
+ if [[ ${DISTUTILS_IN_SOURCE_BUILD} && ! ${DISTUTILS_SINGLE_IMPL} ]]
+ then
# create source copies for each implementation
python_copy_sources
fi
@@ -345,11 +363,14 @@ distutils-r1_python_install() {
addpredict /usr/lib/portage/pym
local root=${D}/_${EPYTHON}
+ [[ ${DISTUTILS_SINGLE_IMPL} ]] && root=${D}
esetup.py install "${flags[@]}" --root="${root}" "${@}"
- _distutils-r1_rename_scripts "${root}"
- _distutils-r1_merge_root "${root}" "${D}"
+ if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then
+ _distutils-r1_rename_scripts "${root}"
+ _distutils-r1_merge_root "${root}" "${D}"
+ fi
}
# @FUNCTION: distutils-r1_merge_root
@@ -431,7 +452,9 @@ distutils-r1_run_phase() {
debug-print-function ${FUNCNAME} "${@}"
if [[ ${DISTUTILS_IN_SOURCE_BUILD} ]]; then
- pushd "${BUILD_DIR}" >/dev/null || die
+ if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then
+ pushd "${BUILD_DIR}" >/dev/null || die
+ fi
else
local PYTHONPATH="${BUILD_DIR}/lib:${PYTHONPATH}"
export PYTHONPATH
@@ -441,7 +464,8 @@ distutils-r1_run_phase() {
mkdir -p "${TMPDIR}" || die
- if [[ ${DISTUTILS_NO_PARALLEL_BUILD} ]]; then
+ if [[ ${DISTUTILS_NO_PARALLEL_BUILD} || ${DISTUTILS_SINGLE_IMPL} ]]
+ then
"${@}" 2>&1 | tee -a "${T}/build-${EPYTHON}.log"
else
(
@@ -451,7 +475,8 @@ distutils-r1_run_phase() {
multijob_post_fork
fi
- if [[ ${DISTUTILS_IN_SOURCE_BUILD} ]]; then
+ if [[ ${DISTUTILS_IN_SOURCE_BUILD} && ! ${DISTUTILS_SINGLE_IMPL} ]]
+ then
popd >/dev/null || die
fi
@@ -487,14 +512,53 @@ _distutils-r1_run_common_phase() {
_distutils-r1_multijob_init() {
debug-print-function ${FUNCNAME} "${@}"
- local opts
- if [[ ${DISTUTILS_JOBS} ]]; then
- opts=-j${DISTUTILS_JOBS}
- else
- opts=${MAKEOPTS}
+ if [[ ! ${DISTUTILS_NO_PARALLEL_BUILD} && ! ${DISTUTILS_SINGLE_IMPL} ]]
+ then
+ local opts
+ if [[ ${DISTUTILS_JOBS} ]]; then
+ opts=-j${DISTUTILS_JOBS}
+ else
+ opts=${MAKEOPTS}
+ fi
+
+ multijob_init "${opts}"
fi
+}
- multijob_init "${opts}"
+# @FUNCTION: _distutils-r1_multijob_finish
+# @INTERNAL
+# @DESCRIPTION:
+# Finish multijob if used.
+_distutils-r1_multijob_finish() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ if [[ ! ${DISTUTILS_NO_PARALLEL_BUILD} && ! ${DISTUTILS_SINGLE_IMPL} ]]
+ then
+ multijob_finish
+ fi
+}
+
+# @FUNCTION: _distutils-r1_run_foreach_impl
+# @INTERNAL
+# @DESCRIPTION:
+# Run the given phase for each implementation if multiple implementations
+# are enabled, once otherwise.
+_distutils-r1_run_foreach_impl() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ set -- distutils-r1_run_phase "${@}"
+
+ if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then
+ python_foreach_impl "${@}"
+ else
+ if [[ ! ${EPYTHON} ]]; then
+ die "EPYTHON unset, python-single-r1_pkg_setup not called?!"
+ fi
+ local BUILD_DIR=${BUILD_DIR:-${S}}
+ BUILD_DIR=${BUILD_DIR%%/}_${EPYTHON}
+
+ "${@}"
+ fi
}
distutils-r1_src_prepare() {
@@ -509,17 +573,17 @@ distutils-r1_src_prepare() {
_distutils-r1_multijob_init
if declare -f python_prepare >/dev/null; then
- python_foreach_impl distutils-r1_run_phase python_prepare
+ _distutils-r1_run_foreach_impl python_prepare
fi
- multijob_finish
+ _distutils-r1_multijob_finish
}
distutils-r1_src_configure() {
_distutils-r1_multijob_init
if declare -f python_configure >/dev/null; then
- python_foreach_impl distutils-r1_run_phase python_configure
+ _distutils-r1_run_foreach_impl python_configure
fi
- multijob_finish
+ _distutils-r1_multijob_finish
if declare -f python_configure_all >/dev/null; then
_distutils-r1_run_common_phase python_configure_all
@@ -531,11 +595,11 @@ distutils-r1_src_compile() {
_distutils-r1_multijob_init
if declare -f python_compile >/dev/null; then
- python_foreach_impl distutils-r1_run_phase python_compile
+ _distutils-r1_run_foreach_impl python_compile
else
- python_foreach_impl distutils-r1_run_phase distutils-r1_python_compile
+ _distutils-r1_run_foreach_impl distutils-r1_python_compile
fi
- multijob_finish
+ _distutils-r1_multijob_finish
if declare -f python_compile_all >/dev/null; then
_distutils-r1_run_common_phase python_compile_all
@@ -547,9 +611,9 @@ distutils-r1_src_test() {
_distutils-r1_multijob_init
if declare -f python_test >/dev/null; then
- python_foreach_impl distutils-r1_run_phase python_test
+ _distutils-r1_run_foreach_impl python_test
fi
- multijob_finish
+ _distutils-r1_multijob_finish
if declare -f python_test_all >/dev/null; then
_distutils-r1_run_common_phase python_test_all
@@ -561,11 +625,11 @@ distutils-r1_src_install() {
_distutils-r1_multijob_init
if declare -f python_install >/dev/null; then
- python_foreach_impl distutils-r1_run_phase python_install
+ _distutils-r1_run_foreach_impl python_install
else
- python_foreach_impl distutils-r1_run_phase distutils-r1_python_install
+ _distutils-r1_run_foreach_impl distutils-r1_python_install
fi
- multijob_finish
+ _distutils-r1_multijob_finish
if declare -f python_install_all >/dev/null; then
_distutils-r1_run_common_phase python_install_all