From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-python+bounces-278-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	by finch.gentoo.org (Postfix) with ESMTP id B47E71381F3
	for <garchives@archives.gentoo.org>; Thu,  6 Dec 2012 17:22:10 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id A965B21C03E;
	Thu,  6 Dec 2012 17:22:04 +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 066C721C03E
	for <gentoo-python@lists.gentoo.org>; Thu,  6 Dec 2012 17:22:03 +0000 (UTC)
Received: from mail-ie0-f177.google.com (mail-ie0-f177.google.com [209.85.223.177])
	(using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits))
	(No client certificate requested)
	(Authenticated sender: floppym)
	by smtp.gentoo.org (Postfix) with ESMTPSA id 123E833D96B
	for <gentoo-python@lists.gentoo.org>; Thu,  6 Dec 2012 17:22:03 +0000 (UTC)
Received: by mail-ie0-f177.google.com with SMTP id k13so10590958iea.36
        for <gentoo-python@lists.gentoo.org>; Thu, 06 Dec 2012 09:22:01 -0800 (PST)
Precedence: bulk
List-Post: <mailto:gentoo-python@lists.gentoo.org>
List-Help: <mailto:gentoo-python+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-python+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-python+subscribe@lists.gentoo.org>
List-Id: Discussions centering around the Python ecosystem in Gentoo Linux <gentoo-python.gentoo.org>
X-BeenThere: gentoo-python@gentoo.org
X-BeenThere: gentoo-python@lists.gentoo.org
MIME-Version: 1.0
Received: by 10.50.184.232 with SMTP id ex8mr6435699igc.30.1354814521194; Thu,
 06 Dec 2012 09:22:01 -0800 (PST)
Received: by 10.64.7.3 with HTTP; Thu, 6 Dec 2012 09:22:00 -0800 (PST)
In-Reply-To: <1354401695-14926-1-git-send-email-mgorny@gentoo.org>
References: <1354401695-14926-1-git-send-email-mgorny@gentoo.org>
Date: Thu, 6 Dec 2012 12:22:00 -0500
Message-ID: <CAJ0EP43LZa_+H9YehWPuG4yGszUBHq8MNYoLkL9_AAW2BOocEQ@mail.gmail.com>
Subject: [gentoo-python] Re: [PATCH] Respect user preferences in python-any-r1 if possible.
From: Mike Gilbert <floppym@gentoo.org>
To: =?UTF-8?B?TWljaGHFgiBHw7Nybnk=?= <mgorny@gentoo.org>
Cc: gentoo-python@lists.gentoo.org, python@gentoo.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-Archives-Salt: 79bc862b-67d6-454a-9a3b-3ea02500cd91
X-Archives-Hash: dfe11d9d2a8be6c498da5d768bce1f3c

On Sat, Dec 1, 2012 at 5:41 PM, Micha=C5=82 G=C3=B3rny <mgorny@gentoo.org> =
wrote:
> ---
>  gx86/eclass/python-any-r1.eclass | 55 ++++++++++++++++++++++++++++++++++=
+++++-
>  1 file changed, 54 insertions(+), 1 deletion(-)
>
> diff --git a/gx86/eclass/python-any-r1.eclass b/gx86/eclass/python-any-r1=
.eclass
> index 7f48f20..ca97e14 100644
> --- a/gx86/eclass/python-any-r1.eclass
> +++ b/gx86/eclass/python-any-r1.eclass
> @@ -135,6 +135,36 @@ _python_build_set_globals() {
>  }
>  _python_build_set_globals
>
> +# @FUNCTION: _python_impl_supported
> +# @USAGE: <epython>
> +# @INTERNAL
> +# @DESCRIPTION:
> +# Check whether the specified implementation is supported by package
> +# (specified in PYTHON_COMPAT).
> +_python_impl_supported() {
> +       debug-print-function ${FUNCNAME} "${@}"
> +
> +       local i=3D${1/./_}
> +
> +       case "${i}" in
> +               python*|jython*)
> +                       ;;
> +               pypy-c*)
> +                       i=3D${i/-c/}
> +                       ;;
> +               *)
> +                       ewarn "Invalid EPYTHON: ${EPYTHON}"
> +                       ;;
> +       esac
> +
> +       if has "${i}" "${PYTHON_COMPAT[@]}"; then
> +               return 0
> +       elif ! has "${i}" "${_PYTHON_ALL_IMPLS[@]}"; then
> +               ewarn "Invalid EPYTHON: ${EPYTHON}"
> +       fi
> +       return 1
> +}
> +
>  # @FUNCTION: python-any-r1_pkg_setup
>  # @DESCRIPTION:
>  # Determine what the best installed (and supported) Python
> @@ -142,7 +172,30 @@ _python_build_set_globals
>  python-any-r1_pkg_setup() {
>         debug-print-function ${FUNCNAME} "${@}"
>
> -       local i rev_impls=3D()
> +       # first, try ${EPYTHON}... maybe it's good enough for us.
> +       if [[ ${EPYTHON} ]]; then
> +               if _python_impl_supported "${EPYTHON}"; then
> +                       python_export EPYTHON PYTHON
> +                       return
> +               fi
> +       fi
> +
> +       # then, try eselect-python
> +       local variant i
> +       for variant in '' '--python2' '--python3'; do
> +               i=3D$(eselect python --show ${variant} 2>/dev/null)
> +
> +               if [[ ! ${i} ]]; then
> +                       # no eselect-python?
> +                       break
> +               elif _python_impl_supported "${i}"; then
> +                       python_export "${i}" EPYTHON PYTHON
> +                       return
> +               fi
> +       done
> +
> +       # fallback to best installed impl.
> +       local rev_impls=3D()
>         for i in "${_PYTHON_ALL_IMPLS[@]}"; do
>                 if has "${i}" "${PYTHON_COMPAT[@]}"; then
>                         rev_impls=3D( "${i}" "${rev_impls[@]}" )
> --
> 1.8.0
>

Looks ok.