From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 52D39138334 for ; Sat, 30 Nov 2019 12:42:20 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A27D3E09E8; Sat, 30 Nov 2019 12:41:56 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 38AD2E09E4 for ; Sat, 30 Nov 2019 12:41:56 +0000 (UTC) Received: from localhost.localdomain (c134-66.icpnet.pl [85.221.134.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mgorny) by smtp.gentoo.org (Postfix) with ESMTPSA id 6DA5534D5ED; Sat, 30 Nov 2019 12:41:54 +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/7] python-single-r1.eclass: Introduce PYTHON_{SINGLE,MULTI}_USEDEP API Date: Sat, 30 Nov 2019 13:41:20 +0100 Message-Id: <20191130124126.169871-2-mgorny@gentoo.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191130124126.169871-1-mgorny@gentoo.org> References: <20191130124126.169871-1-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-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Archives-Salt: bff98045-47cc-461f-a865-664d444b8d50 X-Archives-Hash: c732eb84133b11e7ee75f5082b828e55 Introduce a new API that replaces PYTHON_USEDEP with PYTHON_SINGLE_USEDEP variable and PYTHON_MULTI_USEDEP placeholder. The former can be used directly (or via python_gen_cond_dep) when depending on other python-single-r1 packages, the latter can be used via python_gen_cond_dep when depending on python-r1 packages. Long term, the new API will enable us to remove redundant PYTHON_TARGETS flags from python-single-r1 packages. Signed-off-by: Michał Górny --- eclass/python-single-r1.eclass | 109 ++++++++++++++++++++++++++++----- 1 file changed, 93 insertions(+), 16 deletions(-) diff --git a/eclass/python-single-r1.eclass b/eclass/python-single-r1.eclass index f42c0fb6197a..ad7e39558cf1 100644 --- a/eclass/python-single-r1.eclass +++ b/eclass/python-single-r1.eclass @@ -12,12 +12,17 @@ # @DESCRIPTION: # An extension of the python-r1 eclass suite for packages which # don't support being installed for multiple Python implementations. -# This mostly includes tools embedding Python. +# This mostly includes tools embedding Python and packages using foreign +# build systems. # -# This eclass extends the IUSE and REQUIRED_USE set by python-r1 -# to request the PYTHON_SINGLE_TARGET when the inheriting ebuild -# can be supported by more than one Python implementation. It also -# replaces PYTHON_USEDEP and PYTHON_DEPS with a more suitable form. +# This eclass sets correct IUSE. It also provides PYTHON_DEPS +# and PYTHON_REQUIRED_USE that need to be added to appropriate ebuild +# metadata variables. +# +# The eclass exports PYTHON_SINGLE_USEDEP that is suitable for depending +# on other packages using the eclass. Dependencies on packages using +# python-r1 should be created via python_gen_cond_dep() function, +# using PYTHON_MULTI_USEDEP placeholder. # # Please note that packages support multiple Python implementations # (using python-r1 eclass) can not depend on packages not supporting @@ -136,6 +141,9 @@ EXPORT_FUNCTIONS pkg_setup # @ECLASS-VARIABLE: PYTHON_USEDEP # @DESCRIPTION: +# DEPRECATED. Use PYTHON_SINGLE_USEDEP or python_gen_cond_dep with +# PYTHON_MULTI_USEDEP placeholder instead. +# # This is an eclass-generated USE-dependency string which can be used to # depend on another Python package being built for the same Python # implementations. @@ -154,6 +162,43 @@ EXPORT_FUNCTIONS pkg_setup # python_targets_python2_7(-)?,python_single_target_python3_4(+)? # @CODE +# @ECLASS-VARIABLE: PYTHON_SINGLE_USEDEP +# @DESCRIPTION: +# This is an eclass-generated USE-dependency string which can be used to +# depend on another python-single-r1 package being built for the same +# Python implementations. +# +# If you need to depend on a multi-impl (python-r1) package, use +# python_gen_cond_dep with PYTHON_MULTI_USEDEP placeholder instead. +# +# Example use: +# @CODE +# RDEPEND="dev-python/foo[${PYTHON_SINGLE_USEDEP}]" +# @CODE +# +# Example value: +# @CODE +# python_single_target_python3_4(-)? +# @CODE + +# @ECLASS-VARIABLE: PYTHON_MULTI_USEDEP +# @DESCRIPTION: +# This is a placeholder variable supported by python_gen_cond_dep, +# in order to depend on python-r1 packages built for the same Python +# implementations. +# +# Example use: +# @CODE +# RDEPEND="$(python_gen_cond_dep ' +# dev-python/foo[${PYTHON_MULTI_USEDEP}] +# ')" +# @CODE +# +# Example value: +# @CODE +# python_targets_python3_4(-) +# @CODE + # @ECLASS-VARIABLE: PYTHON_REQUIRED_USE # @DESCRIPTION: # This is an eclass-generated required-use expression which ensures the following @@ -194,6 +239,8 @@ _python_single_set_globals() { local requse="^^ ( ${flags[*]} )" local optflags="${flags_mt[@]/%/(-)?},${unflags[@]/%/(-)},${flags[@]/%/(+)?}" local usedep="${optflags// /,}" + local single_flags="${flags[@]/%/(-)?}" + local single_usedep=${single_flags// /,} local deps= i PYTHON_PKG_DEP for i in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do @@ -234,11 +281,20 @@ _python_single_set_globals() { eerror "Now : ${usedep}" die "PYTHON_USEDEP integrity check failed" fi + + if [[ ${PYTHON_SINGLE_USEDEP} != "${single_usedep}" ]]; then + eerror "PYTHON_SINGLE_USEDEP have changed between inherits!" + eerror "Before: ${PYTHON_SINGLE_USEDEP}" + eerror "Now : ${single_usedep}" + die "PYTHON_SINGLE_USEDEP integrity check failed" + fi else PYTHON_DEPS=${deps} PYTHON_REQUIRED_USE=${requse} PYTHON_USEDEP=${usedep} - readonly PYTHON_DEPS PYTHON_REQUIRED_USE PYTHON_USEDEP + PYTHON_SINGLE_USEDEP=${single_usedep} + readonly PYTHON_DEPS PYTHON_REQUIRED_USE PYTHON_USEDEP \ + PYTHON_SINGLE_USEDEP fi } _python_single_set_globals @@ -248,12 +304,15 @@ if [[ ! ${_PYTHON_SINGLE_R1} ]]; then # @FUNCTION: _python_gen_usedep # @INTERNAL -# @USAGE: [...] +# @USAGE: <-s|-u> [...] # @DESCRIPTION: # Output a USE dependency string for Python implementations which # are both in PYTHON_COMPAT and match any of the patterns passed # as parameters to the function. # +# The first argument specifies USE-dependency type: '-s' for new-style +# PYTHON_SINGLE_USEDEP, '-u' for backwards-compatible PYTHON_USEDEP. +# # The patterns can be either fnmatch-style patterns (matched via bash # == operator against PYTHON_COMPAT values) or '-2' / '-3' to indicate # appropriately all enabled Python 2/3 implementations (alike @@ -265,14 +324,25 @@ if [[ ! ${_PYTHON_SINGLE_R1} ]]; then _python_gen_usedep() { debug-print-function ${FUNCNAME} "${@}" + local mode=${1} + shift local impl matches=() for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do if _python_impl_matches "${impl}" "${@}"; then - matches+=( - "python_targets_${impl}(-)?" - "python_single_target_${impl}(+)?" - ) + case ${mode} in + -s) + matches+=( + "python_single_target_${impl}(-)?" + ) + ;; + -u) + matches+=( + "python_targets_${impl}(-)?" + "python_single_target_${impl}(+)?" + ) + ;; + esac fi done @@ -319,7 +389,7 @@ python_gen_usedep() { if [[ ${EBUILD_PHASE} == setup ]]; then eqawarn "python_gen_usedep() is deprecated. Please use python_gen_cond_dep instead." fi - _python_gen_usedep "${@}" + _python_gen_usedep -u "${@}" } # @FUNCTION: python_gen_useflags @@ -373,7 +443,8 @@ python_gen_useflags() { # to prevent accidental shell filename expansion. # # In order to enforce USE constraints on the packages, verbatim -# '${PYTHON_USEDEP}' (quoted!) may be placed in the dependency +# '${PYTHON_USEDEP}', '${PYTHON_SINGLE_USEDEP}' +# and '${PYTHON_MULTI_USEDEP}' (quoted!) may be placed in the dependency # specification. It will get expanded within the function into a proper # USE dependency string. # @@ -381,7 +452,7 @@ python_gen_useflags() { # @CODE # PYTHON_COMPAT=( python{2_7,3_{3,4}} pypy ) # RDEPEND="$(python_gen_cond_dep \ -# 'dev-python/unittest2[${PYTHON_USEDEP}]' python2_7 pypy )" +# 'dev-python/unittest2[${PYTHON_MULTI_USEDEP}]' python2_7 pypy )" # @CODE # # It will cause the variable to look like: @@ -405,11 +476,17 @@ python_gen_cond_dep() { # (since python_gen_usedep() will not return ${PYTHON_USEDEP} # the code is run at most once) if [[ ${dep} == *'${PYTHON_USEDEP}'* ]]; then - local usedep=$(_python_gen_usedep "${@}") + local usedep=$(_python_gen_usedep -u "${@}") dep=${dep//\$\{PYTHON_USEDEP\}/${usedep}} fi + if [[ ${dep} == *'${PYTHON_SINGLE_USEDEP}'* ]]; then + local usedep=$(_python_gen_usedep -s "${@}") + dep=${dep//\$\{PYTHON_SINGLE_USEDEP\}/${usedep}} + fi + local multi_usedep="python_targets_${impl}(-)" - matches+=( "python_single_target_${impl}? ( ${dep} )" ) + matches+=( "python_single_target_${impl}? ( + ${dep//\$\{PYTHON_MULTI_USEDEP\}/${multi_usedep}} )" ) fi done -- 2.24.0