From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-python@lists.gentoo.org
Cc: python@gentoo.org, "Michał Górny" <mgorny@gentoo.org>
Subject: [gentoo-python] [PATCH distutils-r1 6/6] Run sub-phases in parallel.
Date: Thu, 29 Nov 2012 12:31:34 +0100 [thread overview]
Message-ID: <1354188694-7229-7-git-send-email-mgorny@gentoo.org> (raw)
In-Reply-To: <1354188694-7229-1-git-send-email-mgorny@gentoo.org>
This circumvents the distutils inability to build sources in parallel.
On 2-core CPU, dev-python/lxml-3.0.1 for py2.6+2.7+3.2+3.3:
- non-parallel: 11 min 23 sec
- parallel: 7 min 49 sec (with a bit of swapping)
- parallel w/ distcc: 3 min 40 sec
---
gx86/eclass/distutils-r1.eclass | 41 +++++++++++++++++++++++++++++++++++++++--
1 file changed, 39 insertions(+), 2 deletions(-)
diff --git a/gx86/eclass/distutils-r1.eclass b/gx86/eclass/distutils-r1.eclass
index c21ab30..5e962a4 100644
--- a/gx86/eclass/distutils-r1.eclass
+++ b/gx86/eclass/distutils-r1.eclass
@@ -57,7 +57,7 @@ esac
if [[ ! ${_DISTUTILS_R1} ]]; then
-inherit eutils python-r1
+inherit eutils multiprocessing python-r1
fi
@@ -130,6 +130,29 @@ DEPEND=${PYTHON_DEPS}
# 'build --build-base ${BUILD_DIR}' to enforce keeping & using built
# files in the specific root.
+# @ECLASS-VARIABLE: DISTUTILS_NO_PARALLEL_BUILD
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# If set to a non-null value, the parallel build feature will
+# be disabled.
+#
+# When parallel builds are used, the implementation-specific sub-phases
+# for selected Python implementation will be run in parallel. This will
+# increase build efficiency with distutils which does not do parallel
+# builds.
+#
+# This variable can be used to disable the afore-mentioned feature
+# in case it causes issues with the package.
+
+#
+# If in-source builds are used, the eclass will create a copy of package
+# sources for each Python implementation in python_prepare_all(),
+# and work on that copy afterwards.
+#
+# If out-of-source builds are used, the eclass will instead work
+# on the sources directly, prepending setup.py arguments with
+# 'build --build-base ${BUILD_DIR}' to enforce keeping & using built
+# files in the specific root.
# @ECLASS-VARIABLE: mydistutilsargs
# @DEFAULT_UNSET
# @DESCRIPTION:
@@ -356,7 +379,11 @@ distutils-r1_run_phase() {
export PYTHONPATH
fi
- "${@}" || die "${1} failed."
+ if [[ ${DISTUTILS_NO_PARALLEL_BUILD} ]]; then
+ "${@}" || die "${1} failed."
+ else
+ multijob_child_init "${@}" || die "${1} failed."
+ fi
if [[ ${DISTUTILS_IN_SOURCE_BUILD} ]]; then
popd &>/dev/null || die
@@ -373,19 +400,23 @@ distutils-r1_src_prepare() {
distutils-r1_python_prepare_all
fi
+ multijob_init
if declare -f python_prepare >/dev/null; then
python_foreach_impl distutils-r1_run_phase python_prepare
else
python_foreach_impl distutils-r1_run_phase distutils-r1_python_prepare
fi
+ multijob_finish
}
distutils-r1_src_configure() {
+ multijob_init
if declare -f python_configure >/dev/null; then
python_foreach_impl distutils-r1_run_phase python_configure
else
python_foreach_impl distutils-r1_run_phase distutils-r1_python_configure
fi
+ multijob_finish
if declare -f python_configure_all >/dev/null; then
python_configure_all
@@ -395,11 +426,13 @@ distutils-r1_src_configure() {
distutils-r1_src_compile() {
debug-print-function ${FUNCNAME} "${@}"
+ multijob_init
if declare -f python_compile >/dev/null; then
python_foreach_impl distutils-r1_run_phase python_compile
else
python_foreach_impl distutils-r1_run_phase distutils-r1_python_compile
fi
+ multijob_finish
if declare -f python_compile_all >/dev/null; then
python_compile_all
@@ -409,11 +442,13 @@ distutils-r1_src_compile() {
distutils-r1_src_test() {
debug-print-function ${FUNCNAME} "${@}"
+ multijob_init
if declare -f python_test >/dev/null; then
python_foreach_impl distutils-r1_run_phase python_test
else
python_foreach_impl distutils-r1_run_phase distutils-r1_python_test
fi
+ multijob_finish
if declare -f python_test_all >/dev/null; then
python_test_all
@@ -423,11 +458,13 @@ distutils-r1_src_test() {
distutils-r1_src_install() {
debug-print-function ${FUNCNAME} "${@}"
+ multijob_init
if declare -f python_install >/dev/null; then
python_foreach_impl distutils-r1_run_phase python_install
else
python_foreach_impl distutils-r1_run_phase distutils-r1_python_install
fi
+ multijob_finish
if declare -f python_install_all >/dev/null; then
python_install_all
--
1.8.0
next prev parent reply other threads:[~2012-11-29 11:30 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-29 11:31 [gentoo-python] distutils-r1: a bit of clean up + parallel builds Michał Górny
2012-11-29 11:31 ` [gentoo-python] [PATCH distutils-r1 1/6] Make distutils-r1_rename_scripts private Michał Górny
2012-11-29 11:31 ` [gentoo-python] [PATCH distutils-r1 2/6] Rename all Python executables in distutils-r1_rename_scripts Michał Górny
2012-11-29 11:31 ` [gentoo-python] [PATCH distutils-r1 3/6] _distutils-r1_rename_scripts: require explicit path Michał Górny
2012-11-29 11:31 ` [gentoo-python] [PATCH distutils-r1 4/6] Install files to intermediate root and merge afterwards Michał Górny
2012-11-29 11:31 ` [gentoo-python] [PATCH distutils-r1 5/6] Install the wrapper symlink in _distutils-r1_rename_scripts Michał Górny
2012-11-29 11:31 ` Michał Górny [this message]
2012-11-29 16:29 ` [gentoo-python] Re: distutils-r1: a bit of clean up + parallel builds Mike Gilbert
2012-11-29 16:40 ` Michał Górny
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1354188694-7229-7-git-send-email-mgorny@gentoo.org \
--to=mgorny@gentoo.org \
--cc=gentoo-python@lists.gentoo.org \
--cc=python@gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox