Gentoo Archives: gentoo-python

From: "Michał Górny" <mgorny@g.o>
To: gentoo-python@l.g.o
Cc: python@g.o, "Michał Górny" <mgorny@g.o>
Subject: [gentoo-python] [PATCH distutils-r1 6/6] Run sub-phases in parallel.
Date: Thu, 29 Nov 2012 11:30:37
Message-Id: 1354188694-7229-7-git-send-email-mgorny@gentoo.org
In Reply to: [gentoo-python] distutils-r1: a bit of clean up + parallel builds by "Michał Górny"
1 This circumvents the distutils inability to build sources in parallel.
2
3 On 2-core CPU, dev-python/lxml-3.0.1 for py2.6+2.7+3.2+3.3:
4
5 - non-parallel: 11 min 23 sec
6
7 - parallel: 7 min 49 sec (with a bit of swapping)
8
9 - parallel w/ distcc: 3 min 40 sec
10 ---
11 gx86/eclass/distutils-r1.eclass | 41 +++++++++++++++++++++++++++++++++++++++--
12 1 file changed, 39 insertions(+), 2 deletions(-)
13
14 diff --git a/gx86/eclass/distutils-r1.eclass b/gx86/eclass/distutils-r1.eclass
15 index c21ab30..5e962a4 100644
16 --- a/gx86/eclass/distutils-r1.eclass
17 +++ b/gx86/eclass/distutils-r1.eclass
18 @@ -57,7 +57,7 @@ esac
19
20 if [[ ! ${_DISTUTILS_R1} ]]; then
21
22 -inherit eutils python-r1
23 +inherit eutils multiprocessing python-r1
24
25 fi
26
27 @@ -130,6 +130,29 @@ DEPEND=${PYTHON_DEPS}
28 # 'build --build-base ${BUILD_DIR}' to enforce keeping & using built
29 # files in the specific root.
30
31 +# @ECLASS-VARIABLE: DISTUTILS_NO_PARALLEL_BUILD
32 +# @DEFAULT_UNSET
33 +# @DESCRIPTION:
34 +# If set to a non-null value, the parallel build feature will
35 +# be disabled.
36 +#
37 +# When parallel builds are used, the implementation-specific sub-phases
38 +# for selected Python implementation will be run in parallel. This will
39 +# increase build efficiency with distutils which does not do parallel
40 +# builds.
41 +#
42 +# This variable can be used to disable the afore-mentioned feature
43 +# in case it causes issues with the package.
44 +
45 +#
46 +# If in-source builds are used, the eclass will create a copy of package
47 +# sources for each Python implementation in python_prepare_all(),
48 +# and work on that copy afterwards.
49 +#
50 +# If out-of-source builds are used, the eclass will instead work
51 +# on the sources directly, prepending setup.py arguments with
52 +# 'build --build-base ${BUILD_DIR}' to enforce keeping & using built
53 +# files in the specific root.
54 # @ECLASS-VARIABLE: mydistutilsargs
55 # @DEFAULT_UNSET
56 # @DESCRIPTION:
57 @@ -356,7 +379,11 @@ distutils-r1_run_phase() {
58 export PYTHONPATH
59 fi
60
61 - "${@}" || die "${1} failed."
62 + if [[ ${DISTUTILS_NO_PARALLEL_BUILD} ]]; then
63 + "${@}" || die "${1} failed."
64 + else
65 + multijob_child_init "${@}" || die "${1} failed."
66 + fi
67
68 if [[ ${DISTUTILS_IN_SOURCE_BUILD} ]]; then
69 popd &>/dev/null || die
70 @@ -373,19 +400,23 @@ distutils-r1_src_prepare() {
71 distutils-r1_python_prepare_all
72 fi
73
74 + multijob_init
75 if declare -f python_prepare >/dev/null; then
76 python_foreach_impl distutils-r1_run_phase python_prepare
77 else
78 python_foreach_impl distutils-r1_run_phase distutils-r1_python_prepare
79 fi
80 + multijob_finish
81 }
82
83 distutils-r1_src_configure() {
84 + multijob_init
85 if declare -f python_configure >/dev/null; then
86 python_foreach_impl distutils-r1_run_phase python_configure
87 else
88 python_foreach_impl distutils-r1_run_phase distutils-r1_python_configure
89 fi
90 + multijob_finish
91
92 if declare -f python_configure_all >/dev/null; then
93 python_configure_all
94 @@ -395,11 +426,13 @@ distutils-r1_src_configure() {
95 distutils-r1_src_compile() {
96 debug-print-function ${FUNCNAME} "${@}"
97
98 + multijob_init
99 if declare -f python_compile >/dev/null; then
100 python_foreach_impl distutils-r1_run_phase python_compile
101 else
102 python_foreach_impl distutils-r1_run_phase distutils-r1_python_compile
103 fi
104 + multijob_finish
105
106 if declare -f python_compile_all >/dev/null; then
107 python_compile_all
108 @@ -409,11 +442,13 @@ distutils-r1_src_compile() {
109 distutils-r1_src_test() {
110 debug-print-function ${FUNCNAME} "${@}"
111
112 + multijob_init
113 if declare -f python_test >/dev/null; then
114 python_foreach_impl distutils-r1_run_phase python_test
115 else
116 python_foreach_impl distutils-r1_run_phase distutils-r1_python_test
117 fi
118 + multijob_finish
119
120 if declare -f python_test_all >/dev/null; then
121 python_test_all
122 @@ -423,11 +458,13 @@ distutils-r1_src_test() {
123 distutils-r1_src_install() {
124 debug-print-function ${FUNCNAME} "${@}"
125
126 + multijob_init
127 if declare -f python_install >/dev/null; then
128 python_foreach_impl distutils-r1_run_phase python_install
129 else
130 python_foreach_impl distutils-r1_run_phase distutils-r1_python_install
131 fi
132 + multijob_finish
133
134 if declare -f python_install_all >/dev/null; then
135 python_install_all
136 --
137 1.8.0