public inbox for gentoo-python@lists.gentoo.org
 help / color / mirror / Atom feed
From: Mike Gilbert <floppym@gentoo.org>
To: "Michał Górny" <mgorny@gentoo.org>
Cc: gentoo-python@lists.gentoo.org, python@gentoo.org
Subject: [gentoo-python] Re: [PATCH] Respect user preferences in python-any-r1 if possible.
Date: Thu, 6 Dec 2012 12:22:00 -0500	[thread overview]
Message-ID: <CAJ0EP43LZa_+H9YehWPuG4yGszUBHq8MNYoLkL9_AAW2BOocEQ@mail.gmail.com> (raw)
In-Reply-To: <1354401695-14926-1-git-send-email-mgorny@gentoo.org>

On Sat, Dec 1, 2012 at 5:41 PM, Michał Górny <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=${1/./_}
> +
> +       case "${i}" in
> +               python*|jython*)
> +                       ;;
> +               pypy-c*)
> +                       i=${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=()
> +       # 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=$(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=()
>         for i in "${_PYTHON_ALL_IMPLS[@]}"; do
>                 if has "${i}" "${PYTHON_COMPAT[@]}"; then
>                         rev_impls=( "${i}" "${rev_impls[@]}" )
> --
> 1.8.0
>

Looks ok.


      reply	other threads:[~2012-12-06 17:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-01 22:41 [gentoo-python] [PATCH] Respect user preferences in python-any-r1 if possible Michał Górny
2012-12-06 17:22 ` Mike Gilbert [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAJ0EP43LZa_+H9YehWPuG4yGszUBHq8MNYoLkL9_AAW2BOocEQ@mail.gmail.com \
    --to=floppym@gentoo.org \
    --cc=gentoo-python@lists.gentoo.org \
    --cc=mgorny@gentoo.org \
    --cc=python@gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox