diff options
author | Mart Raudsepp <leio@gentoo.org> | 2021-06-23 11:33:28 +0300 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2021-08-12 19:04:20 +0200 |
commit | c412d29682a0f03291bfb8222ba315e35fe1e230 (patch) | |
tree | 0db6125f0f141088cc478320376c8eef75fba46f /eclass/python-utils-r1.eclass | |
parent | python-utils-r1.eclass: Enable hardlinking of identical pyc files for py3.9+ (diff) | |
download | gentoo-c412d29682a0f03291bfb8222ba315e35fe1e230.tar.gz gentoo-c412d29682a0f03291bfb8222ba315e35fe1e230.tar.bz2 gentoo-c412d29682a0f03291bfb8222ba315e35fe1e230.zip |
python-utils-r1.eclass: Enable parallel bytecompile compilation
Python 3.5 added support for compileall to run parallel workers for
performing bytecode compilation. Make use of it to the extent
possible without refactoring the code too much to get different
paths into the same call for best possible parallelization.
Signed-off-by: Mart Raudsepp <leio@gentoo.org>
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'eclass/python-utils-r1.eclass')
-rw-r--r-- | eclass/python-utils-r1.eclass | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass index ddd1a25e6def..a2b5b6d5d41a 100644 --- a/eclass/python-utils-r1.eclass +++ b/eclass/python-utils-r1.eclass @@ -35,7 +35,7 @@ fi if [[ ! ${_PYTHON_UTILS_R1} ]]; then [[ ${EAPI} == [67] ]] && inherit eapi8-dosym -inherit toolchain-funcs +inherit multiprocessing toolchain-funcs # @ECLASS-VARIABLE: _PYTHON_ALL_IMPLS # @INTERNAL @@ -590,6 +590,9 @@ python_optimize() { debug-print "${FUNCNAME}: using sys.path: ${*/%/;}" fi + local jobs=$(makeopts_jobs "${MAKEOPTS}" INF) + [[ ${jobs} == INF ]] && jobs=$(get_nproc) + local d for d; do # make sure to get a nice path without // @@ -603,12 +606,12 @@ python_optimize() { ;; python3.[5678]|pypy3) # both levels of optimization are separate since 3.5 - "${PYTHON}" -m compileall -q -f -d "${instpath}" "${d}" - "${PYTHON}" -O -m compileall -q -f -d "${instpath}" "${d}" - "${PYTHON}" -OO -m compileall -q -f -d "${instpath}" "${d}" + "${PYTHON}" -m compileall -j "${jobs}" -q -f -d "${instpath}" "${d}" + "${PYTHON}" -O -m compileall -j "${jobs}" -q -f -d "${instpath}" "${d}" + "${PYTHON}" -OO -m compileall -j "${jobs}" -q -f -d "${instpath}" "${d}" ;; python*) - "${PYTHON}" -m compileall -o 0 -o 1 -o 2 --hardlink-dupes -q -f -d "${instpath}" "${d}" + "${PYTHON}" -m compileall -j "${jobs}" -o 0 -o 1 -o 2 --hardlink-dupes -q -f -d "${instpath}" "${d}" ;; *) "${PYTHON}" -m compileall -q -f -d "${instpath}" "${d}" |