From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 9D914198005 for ; Thu, 21 Feb 2013 22:09:59 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 32D59E01DC; Thu, 21 Feb 2013 22:09:59 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id C1252E01DC for ; Thu, 21 Feb 2013 22:09:58 +0000 (UTC) Received: from pomiocik.lan (unknown [213.195.173.220]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: mgorny) by smtp.gentoo.org (Postfix) with ESMTPSA id EBDD033E0B9; Thu, 21 Feb 2013 22:09:56 +0000 (UTC) From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= To: gentoo-python@lists.gentoo.org Cc: python@gentoo.org, =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Subject: [gentoo-python] [PATCH 2/5] Introduce python_parallel_foreach_impl(). Date: Thu, 21 Feb 2013 23:10:02 +0100 Message-Id: <1361484605-13363-2-git-send-email-mgorny@gentoo.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <20130221230724.15b66f86@pomiocik.lan> References: <20130221230724.15b66f86@pomiocik.lan> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Discussions centering around the Python ecosystem in Gentoo Linux X-BeenThere: gentoo-python@gentoo.org X-BeenThere: gentoo-python@lists.gentoo.org X-Archives-Salt: 7a6e56d1-fbbe-49d3-b210-caf541f17582 X-Archives-Hash: a2c8bc8981b72e3bfbb2183332b862e5 A parallel variant of python_foreach_impl. Also, move DISTUTILS_JOBS to python-r1 then. --- gx86/eclass/distutils-r1.eclass | 8 ------ gx86/eclass/python-r1.eclass | 54 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 8 deletions(-) diff --git a/gx86/eclass/distutils-r1.eclass b/gx86/eclass/distutils-r1.eclass index e662fa2..8457fd2 100644 --- a/gx86/eclass/distutils-r1.eclass +++ b/gx86/eclass/distutils-r1.eclass @@ -100,14 +100,6 @@ if [[ ! ${DISTUTILS_OPTIONAL} ]]; then DEPEND=${PYTHON_DEPS} fi -# @ECLASS-VARIABLE: DISTUTILS_JOBS -# @DEFAULT_UNSET -# @DESCRIPTION: -# The number of parallel jobs to run for distutils-r1 parallel builds. -# If unset, the job-count in ${MAKEOPTS} will be used. -# -# This variable is intended to be set in make.conf. - # @ECLASS-VARIABLE: PATCHES # @DEFAULT_UNSET # @DESCRIPTION: diff --git a/gx86/eclass/python-r1.eclass b/gx86/eclass/python-r1.eclass index 083157c..09e6417 100644 --- a/gx86/eclass/python-r1.eclass +++ b/gx86/eclass/python-r1.eclass @@ -173,6 +173,14 @@ _python_set_globals() { } _python_set_globals +# @ECLASS-VARIABLE: DISTUTILS_JOBS +# @DEFAULT_UNSET +# @DESCRIPTION: +# The number of parallel jobs to run for distutils-r1 parallel builds. +# If unset, the job-count in ${MAKEOPTS} will be used. +# +# This variable is intended to be set in make.conf. + # @FUNCTION: _python_validate_useflags # @INTERNAL # @DESCRIPTION: @@ -623,6 +631,52 @@ python_foreach_impl() { return ${ret} } +# @FUNCTION: python_parallel_foreach_impl +# @USAGE: [...] +# @DESCRIPTION: +# Run the given command for each of the enabled Python implementations. +# If additional parameters are passed, they will be passed through +# to the command. +# +# The function will return 0 status if all invocations succeed. +# Otherwise, the return code from first failing invocation will +# be returned. +# +# For each command being run, EPYTHON, PYTHON and BUILD_DIR are set +# locally, and the former two are exported to the command environment. +# +# Multiple invocations of the command will be run in parallel, up to +# DISTUTILS_JOBS (defaulting to '-j' option argument from MAKEOPTS). +python_parallel_foreach_impl() { + debug-print-function ${FUNCNAME} "${@}" + + local ret lret + + _python_parallel() { + ( + multijob_child_init + "${@}" + ) & + multijob_post_fork + } + + local opts + if [[ ${DISTUTILS_JOBS} ]]; then + opts=-j${DISTUTILS_JOBS} + else + opts=${MAKEOPTS} + fi + + multijob_init "${opts}" + python_foreach_impl _python_parallel "${@}" + ret=${?} + multijob_finish + lret=${?} + + [[ ${ret} -eq 0 ]] && ret=${lret} + return ${ret} +} + # @FUNCTION: python_export_best # @USAGE: [...] # @DESCRIPTION: -- 1.8.1.2