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 9CB541381F3 for ; Sun, 20 Oct 2013 07:36:43 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 2EADFE0BC1; Sun, 20 Oct 2013 07:36:43 +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 46530E0BC1 for ; Sun, 20 Oct 2013 07:36:42 +0000 (UTC) Received: from pomiot.lan (77-255-21-180.adsl.inetia.pl [77.255.21.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: mgorny) by smtp.gentoo.org (Postfix) with ESMTPSA id A617933F188; Sun, 20 Oct 2013 07:36:40 +0000 (UTC) From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= To: gentoo-python@lists.gentoo.org Cc: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Subject: [gentoo-python] [PATCH] Introduce python_setup() as a common name for Python setup function. Date: Sun, 20 Oct 2013 09:36:46 +0200 Message-Id: <1382254606-26643-1-git-send-email-mgorny@gentoo.org> X-Mailer: git-send-email 1.8.4 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: 88bba913-2117-4481-866b-770a894f1171 X-Archives-Hash: 35104564437ffd815ff9496f2fcafd95 As described in the ml, the new function does: * in python-any-r1, choose and set up the best installed impl, * in python-single-r1, read PYTHON_SINGLE_TARGET and set it up, * in python-r1, call python_export_best + python_wrapper_setup. In other words, it's a common way of getting Python build environment set up in the ebuild scope. --- eclass/python-any-r1.eclass | 24 +++++++++++++++++------- eclass/python-r1.eclass | 15 +++++++++++++++ eclass/python-single-r1.eclass | 17 +++++++++++++---- 3 files changed, 45 insertions(+), 11 deletions(-) diff --git a/eclass/python-any-r1.eclass b/eclass/python-any-r1.eclass index 760e8e7..109c4ee 100644 --- a/eclass/python-any-r1.eclass +++ b/eclass/python-any-r1.eclass @@ -259,17 +259,15 @@ _python_EPYTHON_supported() { return 1 } -# @FUNCTION: python-any-r1_pkg_setup +# @FUNCTION: python_setup # @DESCRIPTION: # Determine what the best installed (and supported) Python -# implementation is and set EPYTHON and PYTHON accordingly. -python-any-r1_pkg_setup() { +# implementation is, and set the Python build environment up for it. +# +# This function will call python_check_deps() if defined. +python_setup() { debug-print-function ${FUNCNAME} "${@}" - # avoid looking up Python for binary package install. - # if you need Python during pkg_preinst/_postinst, please let us know. - [[ ${MERGE_TYPE} == binary ]] && return 0 - # first, try ${EPYTHON}... maybe it's good enough for us. if [[ ${EPYTHON} ]]; then if _python_EPYTHON_supported "${EPYTHON}"; then @@ -317,5 +315,17 @@ python-any-r1_pkg_setup() { die "No supported Python implementation installed." } +# @FUNCTION: python-any-r1_pkg_setup +# @DESCRIPTION: +# Runs python_setup during from-source installs. +# +# In a binary package installs is a no-op. If you need Python in pkg_* +# phases of a binary package, call python_setup directly. +python-any-r1_pkg_setup() { + debug-print-function ${FUNCNAME} "${@}" + + [[ ${MERGE_TYPE} != binary ]] && python_setup +} + _PYTHON_ANY_R1=1 fi diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass index 750fa91..1a04d5b 100644 --- a/eclass/python-r1.eclass +++ b/eclass/python-r1.eclass @@ -712,6 +712,21 @@ python_parallel_foreach_impl() { multibuild_parallel_foreach_variant _python_multibuild_wrapper "${@}" } +# @FUNCTION: python_setup +# @DESCRIPTION: +# Find the best (most preferred) Python implementation enabled +# and set the Python build environment up for it. +# +# This function needs to be used when Python is being called outside +# of python_foreach_impl calls (e.g. for shared processes like doc +# building). python_foreach_impl sets up the build environment itself. +python_setup() { + debug-print-function ${FUNCNAME} "${@}" + + python_export_best + python_wrapper_setup +} + # @FUNCTION: python_export_best # @USAGE: [...] # @DESCRIPTION: diff --git a/eclass/python-single-r1.eclass b/eclass/python-single-r1.eclass index 30bbab4..5ff3d40 100644 --- a/eclass/python-single-r1.eclass +++ b/eclass/python-single-r1.eclass @@ -202,11 +202,11 @@ _python_single_set_globals() { } _python_single_set_globals -# @FUNCTION: python-single-r1_pkg_setup +# @FUNCTION: python_setup # @DESCRIPTION: -# Determine what the selected Python implementation is and set EPYTHON -# and PYTHON accordingly. -python-single-r1_pkg_setup() { +# Determine what the selected Python implementation is and set +# the Python build environment up for it. +python_setup() { debug-print-function ${FUNCNAME} "${@}" unset EPYTHON @@ -250,6 +250,15 @@ python-single-r1_pkg_setup() { fi } +# @FUNCTION: python-single-r1_pkg_setup +# @DESCRIPTION: +# Runs python_setup. +python-single-r1_pkg_setup() { + debug-print-function ${FUNCNAME} "${@}" + + python_setup +} + # @FUNCTION: python_fix_shebang # @USAGE: ... # @DESCRIPTION: -- 1.8.4