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 BAFFA1389E2 for ; Sun, 28 Dec 2014 18:29:32 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 70A59E0817; Sun, 28 Dec 2014 18:29:30 +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 F0F5FE0817 for ; Sun, 28 Dec 2014 18:29:29 +0000 (UTC) Received: from pomiot.lan (mgorny-1-pt.tunnel.tserv28.waw1.ipv6.he.net [IPv6:2001:470:70:353::2]) (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 4B2E8340603; Sun, 28 Dec 2014 18:29:28 +0000 (UTC) Date: Sun, 28 Dec 2014 18:41:32 +0100 From: =?UTF-8?B?TWljaGHFgiBHw7Nybnk=?= To: gentoo-python Subject: [gentoo-python] [PATCH] python-single-r1: add python_gen_* functions Message-ID: <20141228184132.2fd0dbf0@pomiot.lan> Organization: Gentoo X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.25; x86_64-pc-linux-gnu) 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 MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; boundary="Sig_/NbXMH21Nc17JF_tfiG9biHl"; protocol="application/pgp-signature" X-Archives-Salt: 86d48bdc-a30f-464b-9926-7a261a9a229f X-Archives-Hash: dfced5b1dda638c03e7c61477a27beae --Sig_/NbXMH21Nc17JF_tfiG9biHl Content-Type: multipart/mixed; boundary="MP_/GP2xbbMA+hknKiOieLutESr" --MP_/GP2xbbMA+hknKiOieLutESr Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi, A quick patch that adds python_gen_usedep, python_gen_useflags and python_gen_cond_dep. It's pretty much copy-paste from python-r1 with the small changes necessary for python-single-r1 :). Please review quickly so that we can fill in the API gaps. --=20 Best regards, Micha=C5=82 G=C3=B3rny --MP_/GP2xbbMA+hknKiOieLutESr Content-Type: text/x-patch Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename=python-single-r1.eclass.diff Index: python-single-r1.eclass =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /var/cvsroot/gentoo-x86/eclass/python-single-r1.eclass,v retrieving revision 1.29 diff -u -B -r1.29 python-single-r1.eclass --- python-single-r1.eclass 7 Nov 2014 18:11:58 -0000 1.29 +++ python-single-r1.eclass 28 Dec 2014 17:40:21 -0000 @@ -228,6 +228,150 @@ } _python_single_set_globals =20 +# @FUNCTION: python_gen_usedep +# @USAGE: [...] +# @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. +# +# Remember to escape or quote the patterns to premature evaluation +# as a file name glob. +# +# When all implementations are requested, please use ${PYTHON_USEDEP} +# instead. Please also remember to set an appropriate REQUIRED_USE +# to avoid ineffective USE flags. +# +# Example: +# @CODE +# PYTHON_COMPAT=3D( python{2_7,3_4} ) +# DEPEND=3D"doc? ( dev-python/epydoc[$(python_gen_usedep 'python2*')] )" +# @CODE +# +# It will cause the dependency to look like: +# @CODE +# DEPEND=3D"doc? ( dev-python/epydoc[python_targets_python2_7(-)?,...] )" +# @CODE +python_gen_usedep() { + debug-print-function ${FUNCNAME} "${@}" + + local impl pattern + local matches=3D() + + for impl in "${PYTHON_COMPAT[@]}"; do + _python_impl_supported "${impl}" || continue + + for pattern; do + if [[ ${impl} =3D=3D ${pattern} ]]; then + matches+=3D( + "python_targets_${impl}(-)?" + "python_single_target_${impl}(+)?" + ) + break + fi + done + done + + [[ ${matches[@]} ]] || die "No supported implementations match python_gen= _usedep patterns: ${@}" + + local out=3D${matches[@]} + echo "${out// /,}" +} + +# @FUNCTION: python_gen_useflags +# @USAGE: [...] +# @DESCRIPTION: +# Output a list of USE flags for Python implementations which +# are both in PYTHON_COMPAT and match any of the patterns passed +# as parameters to the function. +# +# Example: +# @CODE +# PYTHON_COMPAT=3D( python{2_7,3_4} ) +# REQUIRED_USE=3D"doc? ( ^^ ( $(python_gen_useflags 'python2*') ) )" +# @CODE +# +# It will cause the variable to look like: +# @CODE +# REQUIRED_USE=3D"doc? ( ^^ ( python_single_target_python2_7 ) )" +# @CODE +python_gen_useflags() { + debug-print-function ${FUNCNAME} "${@}" + + local impl pattern + local matches=3D() + + for impl in "${PYTHON_COMPAT[@]}"; do + _python_impl_supported "${impl}" || continue + + for pattern; do + if [[ ${impl} =3D=3D ${pattern} ]]; then + matches+=3D( "python_single_target_${impl}" ) + break + fi + done + done + + echo "${matches[@]}" +} + +# @FUNCTION: python_gen_cond_dep +# @USAGE: [...] +# @DESCRIPTION: +# Output a list of -ies made conditional to USE flags +# of Python implementations which are both in PYTHON_COMPAT and match +# any of the patterns passed as the remaining parameters. +# +# In order to enforce USE constraints on the packages, verbatim +# '${PYTHON_USEDEP}' (quoted!) may be placed in the dependency +# specification. It will get expanded within the function into a proper +# USE dependency string. +# +# Example: +# @CODE +# PYTHON_COMPAT=3D( python{2_5,2_6,2_7} ) +# RDEPEND=3D"$(python_gen_cond_dep \ +# 'dev-python/unittest2[${PYTHON_USEDEP}]' python{2_5,2_6})" +# @CODE +# +# It will cause the variable to look like: +# @CODE +# RDEPEND=3D"python_single_target_python2_5? ( +# dev-python/unittest2[python_targets_python2_5(-)?,...] ) +# python_single_target_python2_6? ( +# dev-python/unittest2[python_targets_python2_6(-)?,...] )" +# @CODE +python_gen_cond_dep() { + debug-print-function ${FUNCNAME} "${@}" + + local impl pattern + local matches=3D() + + local dep=3D${1} + shift + + for impl in "${PYTHON_COMPAT[@]}"; do + _python_impl_supported "${impl}" || continue + + for pattern; do + if [[ ${impl} =3D=3D ${pattern} ]]; then + # substitute ${PYTHON_USEDEP} if used + # (since python_gen_usedep() will not return ${PYTHON_USEDEP} + # the code is run at most once) + if [[ ${dep} =3D=3D *'${PYTHON_USEDEP}'* ]]; then + local PYTHON_USEDEP=3D$(python_gen_usedep "${@}") + dep=3D${dep//\$\{PYTHON_USEDEP\}/${PYTHON_USEDEP}} + fi + + matches+=3D( "python_single_target_${impl}? ( ${dep} )" ) + break + fi + done + done + + echo "${matches[@]}" +} + # @FUNCTION: python_setup # @DESCRIPTION: # Determine what the selected Python implementation is and set --MP_/GP2xbbMA+hknKiOieLutESr-- --Sig_/NbXMH21Nc17JF_tfiG9biHl Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQJ8BAEBCgBmBQJUoEDMXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQ2REJCMDdDQzRGMERBRDA2RUEwQUZFNDFC MDdBMUFFQUVGQjQ0NjRFAAoJELB6GurvtEZO620P/3TszgHrFe3gf+J4udJoKw87 Zb3noFqnaoLpa0xOMLyLmuKlQXs8UfgmD3FoAZotC41hbM3tVGgkj+XELnqRUCVw s0JQ+QhOcT2W14p10BE0pbgwu6S2+hxV8JzqyYlZgO/Gyx+q/wrxteCzM5TxWfbQ /pws8Qz59cCJH6pC+Re60ln7l9zrFGN4Doly0E2BtXCv6BlVneoCTK5eNFA7JUws DUQi4JCLlCwRxZX/wvoUQXMjjcoTao0XYX3B2eOGD9O1sqoh0Skc87aGv0RGwyja HYvrktC8Td2CbDcPdRD2SRihIEGbuockJYnt7xHWb0Yp+o7h5SqUFmPAWu7Dz1/O 5gHYEncekrdqcjKdBACDV1k+soTca0zEFM5ENDWZlYbRltS48x3vcflRQzLh7/4j iTKU0WE8eChOSk0okD+XbZ/yp5Dk6XanN7YQmM+5ITHlbZyXyhksULSie25WEjrX 8DriZzqJ8jdoP2rd9LDFhUbfkO558+HVW5L9oyUzZLbG7SYKLZsqU6zpSHUllQ2V 1nbNRzChYT8khFDCOo5bmxgTzeQ7RhplCxKOR3LNmNaxa8HMEuSPl6Oy2ml8sA7j F6jCQ4b8zOQjk7enPIFPZI4lhQ7czaRfSoHovhQ4f1Hw+DaAGw2XYtinXkzWmwuy grCvAYcoisHJF2DzaN3k =7gXy -----END PGP SIGNATURE----- --Sig_/NbXMH21Nc17JF_tfiG9biHl--