summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--eclass/ChangeLog5
-rw-r--r--eclass/python-utils-r1.eclass24
2 files changed, 23 insertions, 6 deletions
diff --git a/eclass/ChangeLog b/eclass/ChangeLog
index c1337db91bec..c002177ee407 100644
--- a/eclass/ChangeLog
+++ b/eclass/ChangeLog
@@ -1,6 +1,9 @@
# ChangeLog for eclass directory
# Copyright 1999-2013 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.940 2013/08/28 21:28:33 tomwij Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.941 2013/08/28 22:04:16 mgorny Exp $
+
+ 28 Aug 2013; Michał Górny <mgorny@gentoo.org> python-utils-r1.eclass:
+ Introduce python_is_python3() to replace the common checks.
28 Aug 2013; Tom Wijsman <TomWij@gentoo.org> ant-tasks.eclass:
Made ant-tasks.eclass support newer versions of the 1.9 branch.
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 5814a137dfb6..a16d52852feb 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -1,6 +1,6 @@
# Copyright 1999-2013 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.30 2013/07/27 11:17:44 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python-utils-r1.eclass,v 1.31 2013/08/28 22:04:16 mgorny Exp $
# @ECLASS: python-utils-r1
# @MAINTAINER:
@@ -532,8 +532,8 @@ _python_rewrite_shebang() {
die "${FUNCNAME}: ${f} does not seem to have a valid shebang"
fi
- if [[ ${from} == python2 && ${impl} == python3*
- || ${from} == python3 && ${impl} != python3* ]]; then
+ if { [[ ${from} == python2 ]] && python_is_python3 "${impl}"; } \
+ || { [[ ${from} == python3 ]] && ! python_is_python3 "${impl}"; } then
eerror "A file does have shebang not supporting requested impl:"
eerror " file: ${f}"
eerror " shebang: ${shebang}"
@@ -883,9 +883,9 @@ python_wrapper_setup() {
python_export "${impl}" EPYTHON PYTHON
local pyver
- if [[ ${EPYTHON} == python3* ]]; then
+ if python_is_python3; then
pyver=3
- else # includes pypy & jython
+ else
pyver=2
fi
@@ -942,5 +942,19 @@ __EOF__
fi
}
+# @FUNCTION: python_is_python3
+# @USAGE: [<impl>]
+# @DESCRIPTION:
+# Check whether <impl> (or ${EPYTHON}) is a Python3k variant
+# (i.e. uses syntax and stdlib of Python 3.*).
+#
+# Returns 0 (true) if it is, 1 (false) otherwise.
+python_is_python3() {
+ local impl=${1:-${EPYTHON}}
+ [[ ${impl} ]] || die "python_is_python3: no impl nor EPYTHON"
+
+ [[ ${impl} == python3* ]]
+}
+
_PYTHON_UTILS_R1=1
fi