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 D804A1384B4 for ; Wed, 23 Dec 2015 16:45:17 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 91B7AE08F7; Wed, 23 Dec 2015 16:44:52 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 61E40E08A6 for ; Wed, 23 Dec 2015 16:44:51 +0000 (UTC) Received: from localhost.localdomain (d202-251.icpnet.pl [109.173.202.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mgorny) by smtp.gentoo.org (Postfix) with ESMTPSA id B6F4134084C; Wed, 23 Dec 2015 16:44:49 +0000 (UTC) From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= To: gentoo-dev@lists.gentoo.org Cc: python@gentoo.org, =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Subject: [gentoo-dev] [PATCH 1/5] python-r1.eclass: Introduce python_gen_impl_dep Date: Wed, 23 Dec 2015 17:44:36 +0100 Message-Id: <1450889080-1920-2-git-send-email-mgorny@gentoo.org> X-Mailer: git-send-email 2.6.4 In-Reply-To: <1450889080-1920-1-git-send-email-mgorny@gentoo.org> References: <1450889080-1920-1-git-send-email-mgorny@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Archives-Salt: 1f1e052f-1aed-4274-af38-e162c980e99e X-Archives-Hash: 30eeb303d6b7d5b680528641664cd605 Add a python_gen_impl_dep() that serves the purpose of generating custom dependencies on the Python interpreter (like PYTHON_DEPS). The function provides ability to request dependencies with another USE dependency string (different than global PYTHON_REQ_USE) and limit the dependencies to subset of supported implementations. --- eclass/python-r1.eclass | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass index 76fd944..6106577 100644 --- a/eclass/python-r1.eclass +++ b/eclass/python-r1.eclass @@ -383,6 +383,58 @@ python_gen_cond_dep() { echo "${matches[@]}" } +# @FUNCTION: python_gen_impl_dep +# @USAGE: [ [...]] +# @DESCRIPTION: +# Output a dependency on Python implementations with the specified USE +# dependency string appended, or no USE dependency string if called +# without the argument (or with empty argument). If any implementation +# patterns are passed, the output dependencies will be generated only +# for the implementations matching them. +# +# Use this function when you need to request different USE flags +# on the Python interpreter depending on package's USE flags. If you +# only need a single set of interpreter USE flags, just set +# PYTHON_REQ_USE and use ${PYTHON_DEPS} globally. +# +# Example: +# @CODE +# PYTHON_COMPAT=( python{2_7,3_{3,4}} pypy ) +# RDEPEND="foo? ( $(python_gen_impl_dep 'xml(+)') )" +# @CODE +# +# It will cause the variable to look like: +# @CODE +# RDEPEND="foo? ( +# python_targets_python2_7? ( +# dev-lang/python:2.7[xml(+)] ) +# python_targets_pypy? ( +# dev-python/pypy[xml(+)] ) )" +# @CODE +python_gen_impl_dep() { + debug-print-function ${FUNCNAME} "${@}" + + local impl pattern + local matches=() + + local PYTHON_REQ_USE=${1} + shift + + local patterns=( "${@-*}" ) + for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do + for pattern in "${patterns[@]}"; do + if [[ ${impl} == ${pattern} ]]; then + local PYTHON_PKG_DEP + python_export "${impl}" PYTHON_PKG_DEP + matches+=( "python_targets_${impl}? ( ${PYTHON_PKG_DEP} )" ) + break + fi + done + done + + echo "${matches[@]}" +} + # @ECLASS-VARIABLE: BUILD_DIR # @DESCRIPTION: # The current build directory. In global scope, it is supposed to -- 2.6.4