Move the has_version checks on installed implementations to python_is_installed(...
authorMichał Górny <mgorny@gentoo.org>
Sun, 9 Nov 2014 22:27:58 +0000 (22:27 +0000)
committerMichał Górny <mgorny@gentoo.org>
Sun, 9 Nov 2014 22:27:58 +0000 (22:27 +0000)
eclass/ChangeLog
eclass/python-any-r1.eclass
eclass/python-utils-r1.eclass

index c2bfbcaa891fe0ce4cb891ba8683420630c57367..ac124807284d01d4df646692a21d3221e12561b4 100644 (file)
@@ -1,6 +1,12 @@
 # ChangeLog for eclass directory
 # Copyright 1999-2014 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.1411 2014/11/09 21:34:29 dilfridge Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.1412 2014/11/09 22:27:58 mgorny Exp $
+
+  09 Nov 2014; Michał Górny <mgorny@gentoo.org> python-any-r1.eclass,
+  python-utils-r1.eclass:
+  Move the has_version checks on installed implementations to
+  python_is_installed() function. Accept PyPy when the implementation is
+  installed, even if the virtual is not.
 
   09 Nov 2014; Andreas K. Huettel <dilfridge@gentoo.org> perl-module.eclass:
   Add docs and deprecate perlinfo and fixlocalpod
index 76a82710d1b33f9cb9e89eae2c4fd6bfe874a363..42fd3c7f57e8188ff341e56e46e5b2eb6d8988c4 100644 (file)
@@ -1,6 +1,6 @@
 # Copyright 1999-2014 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python-any-r1.eclass,v 1.17 2014/04/08 16:05:30 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python-any-r1.eclass,v 1.18 2014/11/09 22:27:58 mgorny Exp $
 
 # @ECLASS: python-any-r1
 # @MAINTAINER:
@@ -239,9 +239,7 @@ _python_EPYTHON_supported() {
        esac
 
        if has "${i}" "${PYTHON_COMPAT[@]}"; then
-               local PYTHON_PKG_DEP
-               python_export "${i}" PYTHON_PKG_DEP
-               if ROOT=/ has_version "${PYTHON_PKG_DEP}"; then
+               if python_is_installed "${i}"; then
                        if declare -f python_check_deps >/dev/null; then
                                local PYTHON_USEDEP="python_targets_${i}(-),python_single_target_${i}(+)"
                                python_check_deps
index 82419c630a4ef991e95d21c4d9a3083dc28fc507..e517ca1eec188103e7310cf02da489b754ddeb84 100644 (file)
@@ -1,6 +1,6 @@
 # Copyright 1999-2014 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python-utils-r1.eclass,v 1.63 2014/11/05 23:03:01 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python-utils-r1.eclass,v 1.64 2014/11/09 22:27:58 mgorny Exp $
 
 # @ECLASS: python-utils-r1
 # @MAINTAINER:
@@ -919,6 +919,38 @@ python_is_python3() {
        [[ ${impl} == python3* || ${impl} == pypy3 ]]
 }
 
+# @FUNCTION: python_is_installed
+# @USAGE: [<impl>]
+# @DESCRIPTION:
+# Check whether the interpreter for <impl> (or ${EPYTHON}) is installed.
+# Uses has_version with a proper dependency string.
+#
+# Returns 0 (true) if it is, 1 (false) otherwise.
+python_is_installed() {
+       local impl=${1:-${EPYTHON}}
+       [[ ${impl} ]] || die "${FUNCNAME}: no impl nor EPYTHON"
+
+       # for has_version
+       local -x ROOT=/
+       case "${impl}" in
+               pypy|pypy3)
+                       local append=
+                       if [[ ${PYTHON_REQ_USE} ]]; then
+                               append=[${PYTHON_REQ_USE}]
+                       fi
+
+                       # be happy with just the interpeter, no need for the virtual
+                       has_version "dev-python/${impl}${append}" \
+                               || has_version "dev-python/${impl}-bin${append}"
+                       ;;
+               *)
+                       local PYTHON_PKG_DEP
+                       python_export "${impl}" PYTHON_PKG_DEP
+                       has_version "${PYTHON_PKG_DEP}"
+                       ;;
+       esac
+}
+
 # @FUNCTION: python_fix_shebang
 # @USAGE: [-f|--force] [-q|--quiet] <path>...
 # @DESCRIPTION: