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 6AD591385CB for ; Mon, 21 Jan 2013 17:23:34 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 03360E06B1; Mon, 21 Jan 2013 17:23:33 +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 7589BE06B1 for ; Mon, 21 Jan 2013 17:23:32 +0000 (UTC) Received: from pomiocik.lan (213-238-105-25.adsl.inetia.pl [213.238.105.25]) (using TLSv1 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: mgorny) by smtp.gentoo.org (Postfix) with ESMTPSA id E7D6533D972; Mon, 21 Jan 2013 17:23:28 +0000 (UTC) Date: Mon, 21 Jan 2013 18:24:02 +0100 From: =?UTF-8?B?TWljaGHFgiBHw7Nybnk=?= To: Mike Gilbert Cc: gentoo-python@lists.gentoo.org, python@gentoo.org Subject: Re: [gentoo-python] Re: [PATCH] Validate PYTHON_COMPAT, support disabling implementations. Message-ID: <20130121182402.3986b8d7@pomiocik.lan> In-Reply-To: <50FD78AC.5050303@gentoo.org> References: <1358161411-16127-1-git-send-email-mgorny@gentoo.org> <50FD78AC.5050303@gentoo.org> Organization: Gentoo X-Mailer: Claws Mail 3.9.0 (GTK+ 2.24.14; 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-SHA256; boundary="Sig_/Le+aAo9uyLmkU=eUYZlKvaL"; protocol="application/pgp-signature" X-Archives-Salt: cb510e1a-1073-410c-8c8f-639e4411edba X-Archives-Hash: 82b5c15a1c2bf7b78e750ee06a1e2679 --Sig_/Le+aAo9uyLmkU=eUYZlKvaL Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Mon, 21 Jan 2013 12:19:40 -0500 Mike Gilbert wrote: > On 1/14/2013 6:03 AM, Micha=C5=82 G=C3=B3rny wrote: > > Now eclasses die with invalid implementations in PYTHON_COMPAT (well, > > except for python-any-r1 which barely looks at PYTHON_COMPAT and more > > relies on _PYTHON_ALL_IMPLS) and can omit the implementations which will > > be marked as 'removed' (for upcoming pypy1.8 cleanup). > > --- > > gx86/eclass/python-any-r1.eclass | 11 ++++----- > > gx86/eclass/python-r1.eclass | 49 +++++++++++++++++++++++++++++= -------- > > gx86/eclass/python-single-r1.eclass | 39 +++++++++++++++++++---------- > > gx86/eclass/python-utils-r1.eclass | 31 +++++++++++++++++++++++ > > 4 files changed, 101 insertions(+), 29 deletions(-) > >=20 > > diff --git a/gx86/eclass/python-any-r1.eclass b/gx86/eclass/python-any-= r1.eclass > > index 199602a..492ab27 100644 > > --- a/gx86/eclass/python-any-r1.eclass > > +++ b/gx86/eclass/python-any-r1.eclass > > @@ -134,13 +134,13 @@ _python_build_set_globals() { > > } > > _python_build_set_globals > > =20 > > -# @FUNCTION: _python_impl_supported > > +# @FUNCTION: _python_EPYTHON_supported > > # @USAGE: > > # @INTERNAL > > # @DESCRIPTION: > > # Check whether the specified implementation is supported by package > > # (specified in PYTHON_COMPAT). > > -_python_impl_supported() { > > +_python_EPYTHON_supported() { > > debug-print-function ${FUNCNAME} "${@}" > > =20 > > local i=3D${1/./_} > > @@ -153,6 +153,7 @@ _python_impl_supported() { > > ;; > > *) > > ewarn "Invalid EPYTHON: ${EPYTHON}" > > + return 1 > > ;; > > esac > > =20 > > @@ -173,7 +174,7 @@ python-any-r1_pkg_setup() { > > =20 > > # first, try ${EPYTHON}... maybe it's good enough for us. > > if [[ ${EPYTHON} ]]; then > > - if _python_impl_supported "${EPYTHON}"; then > > + if _python_EPYTHON_supported "${EPYTHON}"; then > > python_export EPYTHON PYTHON > > return > > fi > > @@ -187,7 +188,7 @@ python-any-r1_pkg_setup() { > > if [[ ! ${i} ]]; then > > # no eselect-python? > > break > > - elif _python_impl_supported "${i}"; then > > + elif _python_EPYTHON_supported "${i}"; then > > python_export "${i}" EPYTHON PYTHON > > return > > fi > > @@ -206,8 +207,6 @@ python-any-r1_pkg_setup() { > > python_export "${i}" PYTHON_PKG_DEP EPYTHON PYTHON > > ROOT=3D/ has_version "${PYTHON_PKG_DEP}" && return > > done > > - > > - die $EPYTHON > > } > > =20 > > _PYTHON_ANY_R1=3D1 > > diff --git a/gx86/eclass/python-r1.eclass b/gx86/eclass/python-r1.eclass > > index 8557727..5067931 100644 > > --- a/gx86/eclass/python-r1.eclass > > +++ b/gx86/eclass/python-r1.eclass > > @@ -132,7 +132,23 @@ fi > > # @CODE > > =20 > > _python_set_globals() { > > - local flags=3D( "${PYTHON_COMPAT[@]/#/python_targets_}" ) > > + local impls=3D() PYTHON_DEPS=3D >=20 > PYTHON_DEPS should be a global here. I pointed this out in IRC, just > stating it here for posterity. Fixed. > > + > > + local i PYTHON_PKG_DEP > > + for i in "${PYTHON_COMPAT[@]}"; do > > + _python_impl_supported "${i}" || continue > > + > > + python_export "${i}" PYTHON_PKG_DEP > > + PYTHON_DEPS+=3D"python_targets_${i}? ( ${PYTHON_PKG_DEP} ) " > > + > > + impls+=3D( "${i}" ) > > + done > > + > > + if [[ ${#impls[@]} -eq 0 ]]; then > > + die "No supported implementation in PYTHON_COMPAT." > > + fi > > + > > + local flags=3D( "${impls[@]/#/python_targets_}" ) > > local optflags=3D${flags[@]/%/?} > > =20 > > # A nice QA trick here. Since a python-single-r1 package has to have > > @@ -141,7 +157,7 @@ _python_set_globals() { > > # it should prevent developers from mistakenly depending on packages > > # not supporting multiple Python implementations. > > =20 > > - local flags_st=3D( "${PYTHON_COMPAT[@]/#/-python_single_target_}" ) > > + local flags_st=3D( "${impls[@]/#/-python_single_target_}" ) > > optflags+=3D,${flags_st[@]/%/(-)} > > =20 > > IUSE=3D${flags[*]} > > @@ -152,12 +168,7 @@ _python_set_globals() { > > # but no point in making this overcomplex, BDEP doesn't hurt anyone > > # 2) python-exec should be built with all targets forced anyway > > # but if new targets were added, we may need to force a rebuild > > - PYTHON_DEPS=3D"dev-python/python-exec[${PYTHON_USEDEP}]" > > - local i PYTHON_PKG_DEP > > - for i in "${PYTHON_COMPAT[@]}"; do > > - python_export "${i}" PYTHON_PKG_DEP > > - PYTHON_DEPS+=3D" python_targets_${i}? ( ${PYTHON_PKG_DEP} )" > > - done > > + PYTHON_DEPS+=3D"dev-python/python-exec[${PYTHON_USEDEP}]" > > } > > _python_set_globals > > =20 > > @@ -171,6 +182,8 @@ _python_validate_useflags() { > > local i > > =20 > > for i in "${PYTHON_COMPAT[@]}"; do > > + _python_impl_supported "${i}" || continue > > + >=20 > Just a style thing: The blank line in these 2 statement for loops seems > odd to me. Maybe your brain works differently. Well, I think I separated the general loop condition and the actual loop code ;). > > use "python_targets_${i}" && return 0 > > done > > =20 > > @@ -210,6 +223,8 @@ python_gen_usedep() { > > local matches=3D() > > =20 > > for impl in "${PYTHON_COMPAT[@]}"; do > > + _python_impl_supported "${impl}" || continue > > + > > for pattern; do > > if [[ ${impl} =3D=3D ${pattern} ]]; then > > matches+=3D( > > @@ -249,6 +264,8 @@ python_gen_useflags() { > > local matches=3D() > > =20 > > 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}" ) > > @@ -292,6 +309,8 @@ python_gen_cond_dep() { > > shift > > =20 > > 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}? ( ${dep} )" ) > > @@ -337,6 +356,8 @@ python_copy_sources() { > > einfo "Will copy sources from ${S}" > > # the order is irrelevant here > > for impl in "${PYTHON_COMPAT[@]}"; do > > + _python_impl_supported "${impl}" || continue > > + > > if use "python_targets_${impl}" > > then > > local BUILD_DIR=3D${bdir%%/}-${impl} > > @@ -369,6 +390,8 @@ _python_check_USE_PYTHON() { > > =20 > > local impl py2 py3 dis_py2 dis_py3 > > for impl in "${PYTHON_COMPAT[@]}"; do > > + _python_impl_supported "${impl}" || continue > > + > > if use "python_targets_${impl}"; then > > case "${impl}" in > > python2_*) > > @@ -480,6 +503,8 @@ _python_check_USE_PYTHON() { > > local impl old=3D${USE_PYTHON} new=3D() removed=3D() > > =20 > > for impl in "${PYTHON_COMPAT[@]}"; do > > + _python_impl_supported "${impl}" || continue > > + > > local abi > > case "${impl}" in > > python*) > > @@ -573,7 +598,9 @@ python_foreach_impl() { > > =20 > > debug-print "${FUNCNAME}: bdir =3D ${bdir}" > > for impl in "${_PYTHON_ALL_IMPLS[@]}"; do > > - if has "${impl}" "${PYTHON_COMPAT[@]}" && use "python_targets_${impl= }" > > + if has "${impl}" "${PYTHON_COMPAT[@]}" \ > > + && _python_impl_supported "${impl}" \ > > + && use "python_targets_${impl}" > > then > > local EPYTHON PYTHON > > python_export "${impl}" EPYTHON PYTHON > > @@ -601,7 +628,9 @@ python_export_best() { > > =20 > > local impl best > > for impl in "${_PYTHON_ALL_IMPLS[@]}"; do > > - if has "${impl}" "${PYTHON_COMPAT[@]}" && use "python_targets_${impl= }" > > + if has "${impl}" "${PYTHON_COMPAT[@]}" \ > > + && _python_impl_supported "${impl}" \ > > + && use "python_targets_${impl}" > > then > > best=3D${impl} > > fi > > diff --git a/gx86/eclass/python-single-r1.eclass b/gx86/eclass/python-s= ingle-r1.eclass > > index fe26251..774f43e 100644 > > --- a/gx86/eclass/python-single-r1.eclass > > +++ b/gx86/eclass/python-single-r1.eclass > > @@ -134,8 +134,31 @@ fi > > # @CODE > > =20 > > _python_single_set_globals() { > > - local flags_mt=3D( "${PYTHON_COMPAT[@]/#/python_targets_}" ) > > - local flags=3D( "${PYTHON_COMPAT[@]/#/python_single_target_}" ) > > + local impls=3D() > > + > > + PYTHON_DEPS=3D > > + local i PYTHON_PKG_DEP > > + for i in "${PYTHON_COMPAT[@]}"; do > > + _python_impl_supported "${i}" || continue > > + > > + # The chosen targets need to be in PYTHON_TARGETS as well. > > + # This is in order to enforce correct dependencies on packages > > + # supporting multiple implementations. > > + #REQUIRED_USE+=3D" python_single_target_${i}? ( python_targets_${i} = )" > > + > > + python_export "${i}" PYTHON_PKG_DEP > > + PYTHON_DEPS+=3D"python_single_target_${i}? ( ${PYTHON_PKG_DEP} ) " > > + > > + impls+=3D( "${i}" ) > > + done > > + > > + if [[ ${#impls[@]} -eq 0 ]]; then > > + die "No supported implementation in PYTHON_COMPAT." > > + fi > > + > > + local flags_mt=3D( "${impls[@]/#/python_targets_}" ) > > + local flags=3D( "${impls[@]/#/python_single_target_}" ) > > + > > local optflags=3D${flags_mt[@]/%/?} > > optflags+=3D,${flags[@]/%/(+)?} > > =20 > > @@ -147,17 +170,7 @@ _python_single_set_globals() { > > # but no point in making this overcomplex, BDEP doesn't hurt anyone > > # 2) python-exec should be built with all targets forced anyway > > # but if new targets were added, we may need to force a rebuild > > - PYTHON_DEPS=3D"dev-python/python-exec[${PYTHON_USEDEP}]" > > - local i PYTHON_PKG_DEP > > - for i in "${PYTHON_COMPAT[@]}"; do > > - # The chosen targets need to be in PYTHON_TARGETS as well. > > - # This is in order to enforce correct dependencies on packages > > - # supporting multiple implementations. > > - #REQUIRED_USE+=3D" python_single_target_${i}? ( python_targets_${i} = )" > > - > > - python_export "${i}" PYTHON_PKG_DEP > > - PYTHON_DEPS+=3D" python_single_target_${i}? ( ${PYTHON_PKG_DEP} )" > > - done > > + PYTHON_DEPS+=3D"dev-python/python-exec[${PYTHON_USEDEP}]" > > } > > _python_single_set_globals > > =20 > > diff --git a/gx86/eclass/python-utils-r1.eclass b/gx86/eclass/python-ut= ils-r1.eclass > > index ba270b5..ab72225 100644 > > --- a/gx86/eclass/python-utils-r1.eclass > > +++ b/gx86/eclass/python-utils-r1.eclass > > @@ -47,6 +47,37 @@ _PYTHON_ALL_IMPLS=3D( > > python2_5 python2_6 python2_7 > > ) > > =20 > > +# @FUNCTION: _python_impl_supported > > +# @USAGE: > > +# @INTERNAL > > +# @DESCRIPTION: > > +# Check whether the implementation (PYTHON_COMPAT-form) > > +# is still supported. > > +# > > +# Returns 0 if the implementation is valid and supported. If it is > > +# unsupported, returns 1 -- and the caller should ignore the entry. > > +# If it is invalid, dies with an appopriate error messages. > > +_python_impl_supported() { > > + debug-print-function ${FUNCNAME} "${@}" > > + > > + [[ ${#} -eq 1 ]] || die "${FUNCNAME}: takes exactly 1 argument (impl)= ." > > + > > + local impl=3D${1} > > + > > + # keep in sync with _PYTHON_ALL_IMPLS! > > + # (not using that list because inline patterns shall be faster) > > + case "${impl}" in > > + python2_[567]|python3_[123]|pypy1_[89]|pypy2_0|jython2_5) > > + return 0 > > + ;; > > +# pypy1_8) > > +# return 1 > > +# ;; > > + *) > > + die "Invalid implementation in PYTHON_COMPAT: ${impl}" > > + esac > > +} > > + > > # @ECLASS-VARIABLE: PYTHON > > # @DESCRIPTION: > > # The absolute path to the current Python interpreter. >=20 > Overall, looks good. It looks like you did a pretty thorough audit of > the eclasses for the necessary change sites, so I won't repeat that > unless you want me to. Thanks. I didn't add global-scope checks to python-any-r1 since it simply doesn't use PYTHON_COMPAT directly. --=20 Best regards, Micha=C5=82 G=C3=B3rny --Sig_/Le+aAo9uyLmkU=eUYZlKvaL Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (GNU/Linux) iJwEAQEIAAYFAlD9ebIACgkQfXuS5UK5QB04yAP/ffm1yeqZmufw8HPL7J4cLV3l LWcZzMri00R+jzgv6ed8DgHouW1r7MmM0QrrkMhaLQlCYqYkBVYf7Rk3mcOVSJO4 FEVWAuBwFrQYHya52GkwkcL1XSbdL+4AwoMgF98NgDPX2KHnUWAyTfuhzeC62krb ZXX43yupLwzQavLXvAQ= =wpSq -----END PGP SIGNATURE----- --Sig_/Le+aAo9uyLmkU=eUYZlKvaL--