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 017341381F3 for ; Mon, 22 Apr 2013 10:51:47 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 8D4B9E0B1C; Mon, 22 Apr 2013 10:51:46 +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 28648E0B1C for ; Mon, 22 Apr 2013 10:51:46 +0000 (UTC) Received: from pomiocik.localdomain (s241.wifi.put.poznan.pl [150.254.132.242]) (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 56E9533DE92; Mon, 22 Apr 2013 10:51:44 +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 4/4] Add python_check_deps() to support testing supported impls. Date: Mon, 22 Apr 2013 12:52:58 +0200 Message-Id: <1366627978-8571-4-git-send-email-mgorny@gentoo.org> X-Mailer: git-send-email 1.8.1.5 In-Reply-To: <20130422125150.5a2396e6@pomiocik> References: <20130422125150.5a2396e6@pomiocik> 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: a8c4db82-32f1-48e7-b166-00ae9d8d74ed X-Archives-Hash: 459e82a0ddb33c4b2a0e6561cebc55d1 Now ebuilds can declare python_check_deps() function. It will be called with EPYTHON and PYTHON_USEDEP set for the impl, and it can do whatever to check whether the impl in question is fine with them, then return an appropriate boolean status. --- gx86/eclass/python-any-r1.eclass | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/gx86/eclass/python-any-r1.eclass b/gx86/eclass/python-any-r1.eclass index d222155..88b5752 100644 --- a/gx86/eclass/python-any-r1.eclass +++ b/gx86/eclass/python-any-r1.eclass @@ -20,6 +20,14 @@ # pkg_setup() which finds the best supported implementation and sets it # as the active one. # +# Optionally, you can define a python_check_deps() function. It will +# be called by the eclass with EPYTHON set to each matching Python +# implementation and it is expected to check whether the implementation +# fulfills the package requirements. You can use the locally exported +# PYTHON_USEDEP to check USE-dependencies of relevant packages. It +# should return a true value (0) if the Python implementation fulfills +# the requirements, a false value (non-zero) otherwise. +# # Please note that python-any-r1 will always inherit python-utils-r1 # as well. Thus, all the functions defined there can be used in the # packages using python-any-r1, and there is no need ever to inherit @@ -134,16 +142,38 @@ _python_build_set_globals() { } _python_build_set_globals +# @ECLASS-VARIABLE: PYTHON_USEDEP +# @DESCRIPTION: +# An eclass-generated USE-dependency string for the currently tested +# implementation. It is set locally for python_check_deps() call. +# +# The generate USE-flag list is compatible with packages using python-r1, +# python-single-r1 and python-distutils-ng eclasses. It must not be used +# on packages using python.eclass. +# +# Example use: +# @CODE +# python_check_deps() { +# has_version "dev-python/foo[${PYTHON_USEDEP}]" +# } +# @CODE +# +# Example value: +# @CODE +# python_targets_python2_7(-)?,python_single_target_python2_7(+)? +# @CODE + # @FUNCTION: _python_EPYTHON_supported # @USAGE: # @INTERNAL # @DESCRIPTION: # Check whether the specified implementation is supported by package -# (specified in PYTHON_COMPAT). +# (specified in PYTHON_COMPAT). Calls python_check_deps() if declared. _python_EPYTHON_supported() { debug-print-function ${FUNCNAME} "${@}" - local i=${1/./_} + local EPYTHON=${1} + local i=${EPYTHON/./_} case "${i}" in python*|jython*) @@ -161,6 +191,12 @@ _python_EPYTHON_supported() { local PYTHON_PKG_DEP python_export "${i}" PYTHON_PKG_DEP if ROOT=/ has_version "${PYTHON_PKG_DEP}"; then + if declare -f python_check_deps >/dev/null; then + local PYTHON_USEDEP="python_targets_${i}(-),python_single_target_${i}(+)" + python_check_deps + return ${?} + fi + return 0 fi elif ! has "${i}" "${_PYTHON_ALL_IMPLS[@]}"; then -- 1.8.1.5