public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2008-03-28  7:11 Ali Polatel (hawking)
  0 siblings, 0 replies; 108+ messages in thread
From: Ali Polatel (hawking) @ 2008-03-28  7:11 UTC (permalink / raw
  To: gentoo-commits

hawking     08/03/28 07:11:57

  Modified:             python.eclass
  Log:
  Add quoting for find, thanks to Yanik Gleyzer, bug 214830

Revision  Changes    Path
1.34                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.34&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.34&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.33&r2=1.34

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- python.eclass	28 Feb 2008 20:20:32 -0000	1.33
+++ python.eclass	28 Mar 2008 07:11:57 -0000	1.34
@@ -1,6 +1,6 @@
 # Copyright 1999-2008 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.33 2008/02/28 20:20:32 dev-zero Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.34 2008/03/28 07:11:57 hawking Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -214,7 +214,7 @@
 
 	for path in ${SEARCH_PATH}; do
 		einfo "Cleaning orphaned Python bytecode from ${path} .."
-		for obj in $(find ${path} -name *.py[co]); do
+		for obj in $(find ${path} -name '*.py[co]'); do
 			src_py="${obj%[co]}"
 			if [ ! -f "${src_py}" ]; then
 				einfo "Purging ${src_py}[co]"



-- 
gentoo-commits@lists.gentoo.org mailing list



^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2008-05-29 14:10 Ali Polatel (hawking)
  0 siblings, 0 replies; 108+ messages in thread
From: Ali Polatel (hawking) @ 2008-05-29 14:10 UTC (permalink / raw
  To: gentoo-commits

hawking     08/05/29 14:10:48

  Modified:             python.eclass
  Log:
  python_mod_compile is now ROOT aware and can accept more than one files as argument.

Revision  Changes    Path
1.35                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.35&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.35&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.34&r2=1.35

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- python.eclass	28 Mar 2008 07:11:57 -0000	1.34
+++ python.eclass	29 May 2008 14:10:48 -0000	1.35
@@ -1,6 +1,6 @@
 # Copyright 1999-2008 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.34 2008/03/28 07:11:57 hawking Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.35 2008/05/29 14:10:48 hawking Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -124,15 +124,16 @@
 }
 
 # @FUNCTION: python_mod_compile
-# @USAGE: < file >
+# @USAGE: < file > [more files ...]
 # @DESCRIPTION:
-# Given a filename, it will pre-compile the module's .pyc and .pyo.
+# Given filenames, it will pre-compile the module's .pyc and .pyo.
 # should only be run in pkg_postinst()
 #
 # Example:
-#         python_mod_compile ${ROOT}usr/lib/python2.3/site-packages/pygoogle.py
+#         python_mod_compile /usr/lib/python2.3/site-packages/pygoogle.py
 #
 python_mod_compile() {
+	local f myroot
 	# allow compiling for older python versions
 	if [ -n "${PYTHON_OVERRIDE_PYVER}" ]; then
 		PYVER=${PYTHON_OVERRIDE_PYVER}
@@ -140,13 +141,19 @@
 		python_version
 	fi
 
-	if [ -f "$1" ]; then
-		python${PYVER} -c "import py_compile; py_compile.compile('${1}')" || \
-			ewarn "Failed to compile ${1}"
-		python${PYVER} -O -c "import py_compile; py_compile.compile('${1}')" || \
-			ewarn "Failed to compile ${1}"
+	# strip trailing slash
+	myroot="${ROOT%/}"
+
+	# respect ROOT
+	for f in $@; do
+		[ -f "${myroot}/${f}" ] && myfiles="${myfiles} ${myroot}/${f}"
+	done
+
+	if [ -n "${myfiles}" ]; then
+		python${PYVER} ${myroot}/usr/$(get_libdir)/python${PYVER}/py_compile.py ${myfiles}
+		python${PYVER} -O ${myroot}/usr/$(get_libdir)/python${PYVER}/py_compile.py ${myfiles}
 	else
-		ewarn "Unable to find ${1}"
+		ewarn "No files to compile!"
 	fi
 }
 



-- 
gentoo-commits@lists.gentoo.org mailing list



^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2008-05-29 15:24 Ali Polatel (hawking)
  0 siblings, 0 replies; 108+ messages in thread
From: Ali Polatel (hawking) @ 2008-05-29 15:24 UTC (permalink / raw
  To: gentoo-commits

hawking     08/05/29 15:24:35

  Modified:             python.eclass
  Log:
  Make python_mod_optimize ROOT aware.

Revision  Changes    Path
1.36                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.36&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.36&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.35&r2=1.36

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- python.eclass	29 May 2008 14:10:48 -0000	1.35
+++ python.eclass	29 May 2008 15:24:35 -0000	1.36
@@ -1,6 +1,6 @@
 # Copyright 1999-2008 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.35 2008/05/29 14:10:48 hawking Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.36 2008/05/29 15:24:35 hawking Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -168,12 +168,20 @@
 # in the supplied directory
 #
 # Example:
-#         python_mod_optimize ${ROOT}usr/share/codegen
+#         python_mod_optimize /usr/share/codegen
 python_mod_optimize() {
-	local myroot
+	local mydirs myfiles myroot path
 	# strip trailing slash
 	myroot="${ROOT%/}"
 
+	# respect ROOT
+	for path in $@; do
+		[ ! -e "${myroot}/${path}" ] && ewarn "${myroot}/${path} doesn't exist!"
+		[ -d "${myroot}/${path#/}" ] && mydirs="${mydirs} ${myroot}/${path#/}"
+		# Files are passed to python_mod_compile which is ROOT-aware
+		[ -f "${myroot}/${path}" ] && myfiles="${myfiles} ${path}"
+	done
+
 	# allow compiling for older python versions
 	if [ -n "${PYTHON_OVERRIDE_PYVER}" ]; then
 		PYVER=${PYTHON_OVERRIDE_PYVER}
@@ -189,8 +197,19 @@
 	fi
 
 	ebegin "Byte compiling python modules for python-${PYVER} .."
-	python${PYVER} ${myroot}/usr/$(get_libdir)/python${PYVER}/compileall.py ${compileopts} $@
-	python${PYVER} -O ${myroot}/usr/$(get_libdir)/python${PYVER}/compileall.py ${compileopts} $@
+	if [ -n "${mydirs}" ]; then
+		python${PYVER} \
+			${myroot}/usr/$(get_libdir)/python${PYVER}/compileall.py \
+			${compileopts} ${mydirs}
+		python${PYVER} -O \
+			${myroot}/usr/$(get_libdir)/python${PYVER}/compileall.py \
+			${compileopts} ${mydirs}
+	fi
+
+	if [ -n "${myfiles}" ]; then
+		python_mod_compile ${myfiles}
+	fi
+
 	eend $?
 }
 



-- 
gentoo-commits@lists.gentoo.org mailing list



^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2008-05-29 18:36 Ali Polatel (hawking)
  0 siblings, 0 replies; 108+ messages in thread
From: Ali Polatel (hawking) @ 2008-05-29 18:36 UTC (permalink / raw
  To: gentoo-commits

hawking     08/05/29 18:36:20

  Modified:             python.eclass
  Log:
  Make sure python_mod* functions are run in required phases, die otherwise.

Revision  Changes    Path
1.37                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.37&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.37&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.36&r2=1.37

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- python.eclass	29 May 2008 15:24:35 -0000	1.36
+++ python.eclass	29 May 2008 18:36:20 -0000	1.37
@@ -1,6 +1,6 @@
 # Copyright 1999-2008 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.36 2008/05/29 15:24:35 hawking Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.37 2008/05/29 18:36:20 hawking Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -127,13 +127,18 @@
 # @USAGE: < file > [more files ...]
 # @DESCRIPTION:
 # Given filenames, it will pre-compile the module's .pyc and .pyo.
-# should only be run in pkg_postinst()
+# This function should only be run in pkg_postinst()
 #
 # Example:
 #         python_mod_compile /usr/lib/python2.3/site-packages/pygoogle.py
 #
 python_mod_compile() {
 	local f myroot
+
+	# Check if phase is pkg_postinst()
+	[[ ${EBUILD_PHASE} != postinst ]] &&\
+		die "${FUNCNAME} should only be run in pkg_postinst()"
+
 	# allow compiling for older python versions
 	if [ -n "${PYTHON_OVERRIDE_PYVER}" ]; then
 		PYVER=${PYTHON_OVERRIDE_PYVER}
@@ -166,11 +171,17 @@
 #
 # If supplied with arguments, it will recompile all modules recursively
 # in the supplied directory
+# This function should only be run in pkg_postinst()
 #
 # Example:
 #         python_mod_optimize /usr/share/codegen
 python_mod_optimize() {
 	local mydirs myfiles myroot path
+
+	# Check if phase is pkg_postinst()
+	[[ ${EBUILD_PHASE} != postinst ]] &&\
+		die "${FUNCNAME} should only be run in pkg_postinst()"
+
 	# strip trailing slash
 	myroot="${ROOT%/}"
 
@@ -222,9 +233,15 @@
 # It will recursively scan all compiled python modules in the directories
 # and determine if they are orphaned (eg. their corresponding .py is missing.)
 # if they are, then it will remove their corresponding .pyc and .pyo
+#
+# This function should only be run in pkg_postrm()
 python_mod_cleanup() {
 	local SEARCH_PATH myroot
 
+	# Check if phase is pkg_postinst()
+	[[ ${EBUILD_PHASE} != postrm ]] &&\
+		die "${FUNCNAME} should only be run in pkg_postrm()"
+
 	# strip trailing slash
 	myroot="${ROOT%/}"
 



-- 
gentoo-commits@lists.gentoo.org mailing list



^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2008-05-29 20:01 Ali Polatel (hawking)
  0 siblings, 0 replies; 108+ messages in thread
From: Ali Polatel (hawking) @ 2008-05-29 20:01 UTC (permalink / raw
  To: gentoo-commits

hawking     08/05/29 20:01:56

  Modified:             python.eclass
  Log:
  Fixed typo in python_mod_cleanup.

Revision  Changes    Path
1.38                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.38&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.38&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.37&r2=1.38

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- python.eclass	29 May 2008 18:36:20 -0000	1.37
+++ python.eclass	29 May 2008 20:01:55 -0000	1.38
@@ -1,6 +1,6 @@
 # Copyright 1999-2008 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.37 2008/05/29 18:36:20 hawking Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.38 2008/05/29 20:01:55 hawking Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -238,7 +238,7 @@
 python_mod_cleanup() {
 	local SEARCH_PATH myroot
 
-	# Check if phase is pkg_postinst()
+	# Check if phase is pkg_postrm()
 	[[ ${EBUILD_PHASE} != postrm ]] &&\
 		die "${FUNCNAME} should only be run in pkg_postrm()"
 



-- 
gentoo-commits@lists.gentoo.org mailing list



^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2008-05-29 21:19 Ali Polatel (hawking)
  0 siblings, 0 replies; 108+ messages in thread
From: Ali Polatel (hawking) @ 2008-05-29 21:19 UTC (permalink / raw
  To: gentoo-commits

hawking     08/05/29 21:19:20

  Modified:             python.eclass
  Log:
  Pass options given to python_mod_optimize to compileall.py ,thanks to Remy Blank, #224137. Fixed typos.

Revision  Changes    Path
1.39                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.39&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.39&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.38&r2=1.39

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- python.eclass	29 May 2008 20:01:55 -0000	1.38
+++ python.eclass	29 May 2008 21:19:19 -0000	1.39
@@ -1,6 +1,6 @@
 # Copyright 1999-2008 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.38 2008/05/29 20:01:55 hawking Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.39 2008/05/29 21:19:19 hawking Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -137,7 +137,7 @@
 
 	# Check if phase is pkg_postinst()
 	[[ ${EBUILD_PHASE} != postinst ]] &&\
-		die "${FUNCNAME} should only be run in pkg_postinst()"
+		die "${FUNCNAME} should only be run in pkg_postinst()"
 
 	# allow compiling for older python versions
 	if [ -n "${PYTHON_OVERRIDE_PYVER}" ]; then
@@ -173,24 +173,44 @@
 # in the supplied directory
 # This function should only be run in pkg_postinst()
 #
+# Options passed to this function are passed to compileall.py
+#
 # Example:
 #         python_mod_optimize /usr/share/codegen
 python_mod_optimize() {
-	local mydirs myfiles myroot path
+	local mydirs myfiles myroot myopts path
 
 	# Check if phase is pkg_postinst()
 	[[ ${EBUILD_PHASE} != postinst ]] &&\
-		die "${FUNCNAME} should only be run in pkg_postinst()"
+		die "${FUNCNAME} should only be run in pkg_postinst()"
 
 	# strip trailing slash
 	myroot="${ROOT%/}"
 
-	# respect ROOT
-	for path in $@; do
-		[ ! -e "${myroot}/${path}" ] && ewarn "${myroot}/${path} doesn't exist!"
-		[ -d "${myroot}/${path#/}" ] && mydirs="${mydirs} ${myroot}/${path#/}"
-		# Files are passed to python_mod_compile which is ROOT-aware
-		[ -f "${myroot}/${path}" ] && myfiles="${myfiles} ${path}"
+	# respect ROOT and options passed to compileall.py
+	while [ $# -gt 0 ]; do
+		case $1 in
+			-l|-f|-q)
+				myopts="${myopts} $1"
+				;;
+			-d|-x)
+				# -x takes regexp as argument so quoting is necessary.
+				myopts="${myopts} $1 \"$2\""
+				shift
+				;;
+			-*)
+				ewarn "${FUNCNAME}: Ignoring compile option $1"
+				;;
+			*)
+				for path in $@; do
+					[ ! -e "${myroot}/${path}" ] && ewarn "${myroot}/${path} doesn't exist!"
+					[ -d "${myroot}/${path#/}" ] && mydirs="${mydirs} ${myroot}/${path#/}"
+					# Files are passed to python_mod_compile which is ROOT-aware
+					[ -f "${myroot}/${path}" ] && myfiles="${myfiles} ${path}"
+				done
+				;;
+		esac
+		shift
 	done
 
 	# allow compiling for older python versions
@@ -211,10 +231,10 @@
 	if [ -n "${mydirs}" ]; then
 		python${PYVER} \
 			${myroot}/usr/$(get_libdir)/python${PYVER}/compileall.py \
-			${compileopts} ${mydirs}
+			${compileopts} ${myopts} ${mydirs}
 		python${PYVER} -O \
 			${myroot}/usr/$(get_libdir)/python${PYVER}/compileall.py \
-			${compileopts} ${mydirs}
+			${compileopts} ${myopts} ${mydirs}
 	fi
 
 	if [ -n "${myfiles}" ]; then
@@ -240,7 +260,7 @@
 
 	# Check if phase is pkg_postrm()
 	[[ ${EBUILD_PHASE} != postrm ]] &&\
-		die "${FUNCNAME} should only be run in pkg_postrm()"
+		die "${FUNCNAME} should only be run in pkg_postrm()"
 
 	# strip trailing slash
 	myroot="${ROOT%/}"



-- 
gentoo-commits@lists.gentoo.org mailing list



^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2008-05-29 22:03 Ali Polatel (hawking)
  0 siblings, 0 replies; 108+ messages in thread
From: Ali Polatel (hawking) @ 2008-05-29 22:03 UTC (permalink / raw
  To: gentoo-commits

hawking     08/05/29 22:03:59

  Modified:             python.eclass
  Log:
  Fix last commit. Thanks to Remy Blank.

Revision  Changes    Path
1.40                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.40&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.40&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.39&r2=1.40

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- python.eclass	29 May 2008 21:19:19 -0000	1.39
+++ python.eclass	29 May 2008 22:03:59 -0000	1.40
@@ -1,6 +1,6 @@
 # Copyright 1999-2008 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.39 2008/05/29 21:19:19 hawking Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.40 2008/05/29 22:03:59 hawking Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -178,7 +178,7 @@
 # Example:
 #         python_mod_optimize /usr/share/codegen
 python_mod_optimize() {
-	local mydirs myfiles myroot myopts path
+	local mydirs myfiles myroot myopts
 
 	# Check if phase is pkg_postinst()
 	[[ ${EBUILD_PHASE} != postinst ]] &&\
@@ -202,12 +202,10 @@
 				ewarn "${FUNCNAME}: Ignoring compile option $1"
 				;;
 			*)
-				for path in $@; do
-					[ ! -e "${myroot}/${path}" ] && ewarn "${myroot}/${path} doesn't exist!"
-					[ -d "${myroot}/${path#/}" ] && mydirs="${mydirs} ${myroot}/${path#/}"
-					# Files are passed to python_mod_compile which is ROOT-aware
-					[ -f "${myroot}/${path}" ] && myfiles="${myfiles} ${path}"
-				done
+				[ ! -e "${myroot}/${1}" ] && ewarn "${myroot}/${1} doesn't exist!"
+				[ -d "${myroot}/${1#/}" ] && mydirs="${mydirs} ${myroot}/${1#/}"
+				# Files are passed to python_mod_compile which is ROOT-aware
+				[ -f "${myroot}/${1}" ] && myfiles="${myfiles} ${1}"
 				;;
 		esac
 		shift



-- 
gentoo-commits@lists.gentoo.org mailing list



^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2008-05-30  9:58 Ali Polatel (hawking)
  0 siblings, 0 replies; 108+ messages in thread
From: Ali Polatel (hawking) @ 2008-05-30  9:58 UTC (permalink / raw
  To: gentoo-commits

hawking     08/05/30 09:58:28

  Modified:             python.eclass
  Log:
  Second try to fix passing additional options to python_mod_optimize.

Revision  Changes    Path
1.41                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.41&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.41&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.40&r2=1.41

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- python.eclass	29 May 2008 22:03:59 -0000	1.40
+++ python.eclass	30 May 2008 09:58:28 -0000	1.41
@@ -1,6 +1,6 @@
 # Copyright 1999-2008 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.40 2008/05/29 22:03:59 hawking Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.41 2008/05/30 09:58:28 hawking Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -194,8 +194,7 @@
 				myopts="${myopts} $1"
 				;;
 			-d|-x)
-				# -x takes regexp as argument so quoting is necessary.
-				myopts="${myopts} $1 \"$2\""
+				myopts="${myopts} $1 $2"
 				shift
 				;;
 			-*)
@@ -218,21 +217,17 @@
 		python_version
 	fi
 
-	# set opts
-	if [ "${PYVER}" = "2.2" ]; then
-		compileopts=""
-	else
-		compileopts="-q"
-	fi
+	# set additional opts
+	myopts="${myopts} -q"
 
 	ebegin "Byte compiling python modules for python-${PYVER} .."
 	if [ -n "${mydirs}" ]; then
 		python${PYVER} \
 			${myroot}/usr/$(get_libdir)/python${PYVER}/compileall.py \
-			${compileopts} ${myopts} ${mydirs}
+			${myopts} ${mydirs}
 		python${PYVER} -O \
 			${myroot}/usr/$(get_libdir)/python${PYVER}/compileall.py \
-			${compileopts} ${myopts} ${mydirs}
+			${myopts} ${mydirs}
 	fi
 
 	if [ -n "${myfiles}" ]; then



-- 
gentoo-commits@lists.gentoo.org mailing list



^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2008-07-28 21:56 Rob Cakebread (pythonhead)
  0 siblings, 0 replies; 108+ messages in thread
From: Rob Cakebread (pythonhead) @ 2008-07-28 21:56 UTC (permalink / raw
  To: gentoo-commits

pythonhead    08/07/28 21:56:40

  Modified:             python.eclass
  Log:
  Added get_python_libdir and get_python_sitedir functions bug 232575

Revision  Changes    Path
1.42                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.42&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.42&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.41&r2=1.42

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- python.eclass	30 May 2008 09:58:28 -0000	1.41
+++ python.eclass	28 Jul 2008 21:56:40 -0000	1.42
@@ -1,6 +1,6 @@
 # Copyright 1999-2008 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.41 2008/05/30 09:58:28 hawking Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.42 2008/07/28 21:56:40 pythonhead Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -80,6 +80,21 @@
 	__python_version_extract $PYVER_ALL
 }
 
+# @FUNCTION: get_python_libdir
+# @DESCRIPTION: 
+# Run without arguments, returns the python library dir
+get_python_libdir() {
+	python_version
+	echo "/usr/$(get_libdir)/python${PYVER}"
+}
+
+# @FUNCTION: get_python_sitedir
+# @DESCRIPTION: 
+# Run without arguments, returns the python site-packages dir
+get_python_sitedir() {
+	echo "$(get_python_libdir)/site-packages"
+}
+
 # @FUNCTION: python_makesym
 # @DESCRIPTION:
 # Run without arguments, it will create the /usr/bin/python symlinks






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2008-08-01 22:22 Rob Cakebread (pythonhead)
  0 siblings, 0 replies; 108+ messages in thread
From: Rob Cakebread (pythonhead) @ 2008-08-01 22:22 UTC (permalink / raw
  To: gentoo-commits

pythonhead    08/08/01 22:22:21

  Modified:             python.eclass
  Log:
  Renamed get_python_ funcs to python_get_

Revision  Changes    Path
1.43                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.43&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.43&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.42&r2=1.43

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- python.eclass	28 Jul 2008 21:56:40 -0000	1.42
+++ python.eclass	1 Aug 2008 22:22:21 -0000	1.43
@@ -1,6 +1,6 @@
 # Copyright 1999-2008 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.42 2008/07/28 21:56:40 pythonhead Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.43 2008/08/01 22:22:21 pythonhead Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -80,19 +80,19 @@
 	__python_version_extract $PYVER_ALL
 }
 
-# @FUNCTION: get_python_libdir
-# @DESCRIPTION: 
+# @FUNCTION: python_get_libdir
+# @DESCRIPTION:
 # Run without arguments, returns the python library dir
-get_python_libdir() {
+python_get_libdir() {
 	python_version
 	echo "/usr/$(get_libdir)/python${PYVER}"
 }
 
-# @FUNCTION: get_python_sitedir
-# @DESCRIPTION: 
+# @FUNCTION: python_get_sitedir
+# @DESCRIPTION:
 # Run without arguments, returns the python site-packages dir
-get_python_sitedir() {
-	echo "$(get_python_libdir)/site-packages"
+python_get_sitedir() {
+	echo "$(python_get_libdir)/site-packages"
 }
 
 # @FUNCTION: python_makesym






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2008-08-29 19:28 Ali Polatel (hawking)
  0 siblings, 0 replies; 108+ messages in thread
From: Ali Polatel (hawking) @ 2008-08-29 19:28 UTC (permalink / raw
  To: gentoo-commits

hawking     08/08/29 19:28:09

  Modified:             python.eclass
  Log:
  Make python_version return if PYVER is already set.

Revision  Changes    Path
1.44                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.44&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.44&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.43&r2=1.44

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -r1.43 -r1.44
--- python.eclass	1 Aug 2008 22:22:21 -0000	1.43
+++ python.eclass	29 Aug 2008 19:28:08 -0000	1.44
@@ -1,6 +1,6 @@
 # Copyright 1999-2008 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.43 2008/08/01 22:22:21 pythonhead Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.44 2008/08/29 19:28:08 hawking Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -73,6 +73,7 @@
 }
 
 python_version() {
+	[[ -n "${PYVER}" ]] && return 0
 	local tmpstr
 	python=${python:-/usr/bin/python}
 	tmpstr="$(${python} -V 2>&1 )"






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2008-09-01 14:11 Ali Polatel (hawking)
  0 siblings, 0 replies; 108+ messages in thread
From: Ali Polatel (hawking) @ 2008-09-01 14:11 UTC (permalink / raw
  To: gentoo-commits

hawking     08/09/01 14:11:54

  Modified:             python.eclass
  Log:
  Use local for local variables.

Revision  Changes    Path
1.45                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.45&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.45&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.44&r2=1.45

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- python.eclass	29 Aug 2008 19:28:08 -0000	1.44
+++ python.eclass	1 Sep 2008 14:11:54 -0000	1.45
@@ -1,6 +1,6 @@
 # Copyright 1999-2008 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.44 2008/08/29 19:28:08 hawking Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.45 2008/09/01 14:11:54 hawking Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -63,7 +63,7 @@
 # Run without arguments and it will export the version of python
 # currently in use as $PYVER; sets PYVER/PYVER_MAJOR/PYVER_MINOR
 __python_version_extract() {
-	verstr=$1
+	local verstr=$1
 	export PYVER_MAJOR=${verstr:0:1}
 	export PYVER_MINOR=${verstr:2:1}
 	if [ "${verstr:3}x" = ".x" ]; then






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2008-10-26 17:11 Ali Polatel (hawking)
  0 siblings, 0 replies; 108+ messages in thread
From: Ali Polatel (hawking) @ 2008-10-26 17:11 UTC (permalink / raw
  To: gentoo-commits

hawking     08/10/26 17:11:51

  Modified:             python.eclass
  Log:
  Use PYTHONDONTWRITEBYTECODE to {en,dis}able pyc for 2.6 and above.

Revision  Changes    Path
1.46                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.46&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.46&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.45&r2=1.46

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- python.eclass	1 Sep 2008 14:11:54 -0000	1.45
+++ python.eclass	26 Oct 2008 17:11:51 -0000	1.46
@@ -1,6 +1,6 @@
 # Copyright 1999-2008 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.45 2008/09/01 14:11:54 hawking Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.46 2008/10/26 17:11:51 hawking Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -36,28 +36,6 @@
 	echo " PYVER_MINOR: $PYVER_MINOR PYVER_MICRO: $PYVER_MICRO"
 }
 
-# @FUNCTION: python_disable_pyc
-# @DESCRIPTION:
-# Tells python not to automatically recompile modules to .pyc/.pyo
-# even if the timestamps/version stamps don't match. This is done
-# to protect sandbox.
-#
-# note:   supported by >=dev-lang/python-2.2.3-r3 only.
-#
-python_disable_pyc() {
-	export PYTHON_DONTCOMPILE=1
-}
-
-# @FUNCTION: python_enable_pyc
-# @DESCRIPTION:
-# Tells python to automatically recompile modules to .pyc/.pyo if the
-# timestamps/version stamps change
-python_enable_pyc() {
-	unset PYTHON_DONTCOMPILE
-}
-
-python_disable_pyc
-
 # @FUNCTION: python_version
 # @DESCRIPTION:
 # Run without arguments and it will export the version of python
@@ -81,6 +59,38 @@
 	__python_version_extract $PYVER_ALL
 }
 
+# @FUNCTION: python_disable_pyc
+# @DESCRIPTION:
+# Tells python not to automatically recompile modules to .pyc/.pyo
+# even if the timestamps/version stamps don't match. This is done
+# to protect sandbox.
+#
+# note:   supported by >=dev-lang/python-2.2.3-r3 only.
+#
+python_disable_pyc() {
+	python_version
+	if [[ ${PYVER/./,} -ge 2,6 ]]; then
+		export PYTHONDONTWRITEBYTECODE=1
+	else
+		export PYTHON_DONTCOMPILE=1
+	fi
+}
+
+# @FUNCTION: python_enable_pyc
+# @DESCRIPTION:
+# Tells python to automatically recompile modules to .pyc/.pyo if the
+# timestamps/version stamps change
+python_enable_pyc() {
+	python_version
+	if [[ ${PYVER/./,} -ge 2,6 ]]; then
+		unset PYTHONDONTWRITEBYTECODE
+	else
+		unset PYTHON_DONTCOMPILE
+	fi
+}
+
+python_disable_pyc
+
 # @FUNCTION: python_get_libdir
 # @DESCRIPTION:
 # Run without arguments, returns the python library dir






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2008-10-26 17:26 Ali Polatel (hawking)
  0 siblings, 0 replies; 108+ messages in thread
From: Ali Polatel (hawking) @ 2008-10-26 17:26 UTC (permalink / raw
  To: gentoo-commits

hawking     08/10/26 17:26:18

  Modified:             python.eclass
  Log:
  Bashify, thanks to Steve Long.

Revision  Changes    Path
1.47                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.47&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.47&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.46&r2=1.47

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- python.eclass	26 Oct 2008 17:11:51 -0000	1.46
+++ python.eclass	26 Oct 2008 17:26:18 -0000	1.47
@@ -1,6 +1,6 @@
 # Copyright 1999-2008 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.46 2008/10/26 17:11:51 hawking Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.47 2008/10/26 17:26:18 hawking Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -44,7 +44,7 @@
 	local verstr=$1
 	export PYVER_MAJOR=${verstr:0:1}
 	export PYVER_MINOR=${verstr:2:1}
-	if [ "${verstr:3}x" = ".x" ]; then
+	if [[ ${verstr:3:1} == . ]]; then
 		export PYVER_MICRO=${verstr:4}
 	fi
 	export PYVER="${PYVER_MAJOR}.${PYVER_MINOR}"
@@ -142,11 +142,8 @@
 #             echo "gtk support enabled"
 #         fi
 python_mod_exists() {
-	[ -z "$1" ] && die "${FUNCTION} requires an argument!"
-	if ! python -c "import $1" >/dev/null 2>&1; then
-		return 1
-	fi
-	return 0
+	[[ "$1" ]] && die "${FUNCNAME} requires an argument!"
+	python -c "import $1" >/dev/null 2>&1
 }
 
 # @FUNCTION: python_mod_compile






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2008-10-26 17:34 Ali Polatel (hawking)
  0 siblings, 0 replies; 108+ messages in thread
From: Ali Polatel (hawking) @ 2008-10-26 17:34 UTC (permalink / raw
  To: gentoo-commits

hawking     08/10/26 17:34:44

  Modified:             python.eclass
  Log:
  Bashify python_mod_compile, thanks to Steve Long.

Revision  Changes    Path
1.48                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.48&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.48&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.47&r2=1.48

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -r1.47 -r1.48
--- python.eclass	26 Oct 2008 17:26:18 -0000	1.47
+++ python.eclass	26 Oct 2008 17:34:44 -0000	1.48
@@ -1,6 +1,6 @@
 # Copyright 1999-2008 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.47 2008/10/26 17:26:18 hawking Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.48 2008/10/26 17:34:44 hawking Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -156,14 +156,14 @@
 #         python_mod_compile /usr/lib/python2.3/site-packages/pygoogle.py
 #
 python_mod_compile() {
-	local f myroot
+	local f myroot myfiles=()
 
 	# Check if phase is pkg_postinst()
 	[[ ${EBUILD_PHASE} != postinst ]] &&\
 		die "${FUNCNAME} should only be run in pkg_postinst()"
 
 	# allow compiling for older python versions
-	if [ -n "${PYTHON_OVERRIDE_PYVER}" ]; then
+	if [[ "${PYTHON_OVERRIDE_PYVER}" ]]; then
 		PYVER=${PYTHON_OVERRIDE_PYVER}
 	else
 		python_version
@@ -174,12 +174,12 @@
 
 	# respect ROOT
 	for f in $@; do
-		[ -f "${myroot}/${f}" ] && myfiles="${myfiles} ${myroot}/${f}"
+		[[ -f "${myroot}/${f}" ]] && myfiles+=("${myroot}/${f}")
 	done
 
-	if [ -n "${myfiles}" ]; then
-		python${PYVER} ${myroot}/usr/$(get_libdir)/python${PYVER}/py_compile.py ${myfiles}
-		python${PYVER} -O ${myroot}/usr/$(get_libdir)/python${PYVER}/py_compile.py ${myfiles}
+	if ((${#myfiles[@]})); then
+		python${PYVER} ${myroot}/usr/$(get_libdir)/python${PYVER}/py_compile.py "${myfiles[@]}"
+		python${PYVER} -O ${myroot}/usr/$(get_libdir)/python${PYVER}/py_compile.py "${myfiles[@]}"
 	else
 		ewarn "No files to compile!"
 	fi






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2008-10-26 17:46 Ali Polatel (hawking)
  0 siblings, 0 replies; 108+ messages in thread
From: Ali Polatel (hawking) @ 2008-10-26 17:46 UTC (permalink / raw
  To: gentoo-commits

hawking     08/10/26 17:46:31

  Modified:             python.eclass
  Log:
  Bashify python_mod_optimize, thanks to Steve Long.

Revision  Changes    Path
1.49                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.49&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.49&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.48&r2=1.49

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -r1.48 -r1.49
--- python.eclass	26 Oct 2008 17:34:44 -0000	1.48
+++ python.eclass	26 Oct 2008 17:46:31 -0000	1.49
@@ -1,6 +1,6 @@
 # Copyright 1999-2008 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.48 2008/10/26 17:34:44 hawking Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.49 2008/10/26 17:46:31 hawking Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -201,7 +201,7 @@
 # Example:
 #         python_mod_optimize /usr/share/codegen
 python_mod_optimize() {
-	local mydirs myfiles myroot myopts
+	local myroot mydirs=() myfiles=() myopts=()
 
 	# Check if phase is pkg_postinst()
 	[[ ${EBUILD_PHASE} != postinst ]] &&\
@@ -211,23 +211,29 @@
 	myroot="${ROOT%/}"
 
 	# respect ROOT and options passed to compileall.py
-	while [ $# -gt 0 ]; do
+	while (($#)); do
 		case $1 in
 			-l|-f|-q)
-				myopts="${myopts} $1"
+				myopts+=("$1")
 				;;
 			-d|-x)
-				myopts="${myopts} $1 $2"
+				myopts+=("$1" "$2")
 				shift
 				;;
 			-*)
 				ewarn "${FUNCNAME}: Ignoring compile option $1"
 				;;
 			*)
-				[ ! -e "${myroot}/${1}" ] && ewarn "${myroot}/${1} doesn't exist!"
-				[ -d "${myroot}/${1#/}" ] && mydirs="${mydirs} ${myroot}/${1#/}"
-				# Files are passed to python_mod_compile which is ROOT-aware
-				[ -f "${myroot}/${1}" ] && myfiles="${myfiles} ${1}"
+				if [[ -d "${myroot}"/$1 ]]; then
+					mydirs+=("${myroot}/$1")
+				elif [[ -f "${myroot}"/$1 ]]; then
+					# Files are passed to python_mod_compile which is ROOT-aware
+					myfiles+=("$1")
+				elif [[ -e "${myroot}/$1" ]]; then
+					ewarn "${myroot}/$1 is not a file or directory!"
+				else
+					ewarn "${myroot}/$1 doesn't exist!"
+				fi
 				;;
 		esac
 		shift
@@ -241,20 +247,20 @@
 	fi
 
 	# set additional opts
-	myopts="${myopts} -q"
+	myopts+=(-q)
 
 	ebegin "Byte compiling python modules for python-${PYVER} .."
-	if [ -n "${mydirs}" ]; then
+	if ((${#mydirs[@]})); then
 		python${PYVER} \
-			${myroot}/usr/$(get_libdir)/python${PYVER}/compileall.py \
-			${myopts} ${mydirs}
+			"${myroot}"/usr/$(get_libdir)/python${PYVER}/compileall.py \
+			"${myopts[@]}" "${mydirs[@]}"
 		python${PYVER} -O \
-			${myroot}/usr/$(get_libdir)/python${PYVER}/compileall.py \
-			${myopts} ${mydirs}
+			"${myroot}"/usr/$(get_libdir)/python${PYVER}/compileall.py \
+			"${myopts[@]}" "${mydirs[@]}"
 	fi
 
-	if [ -n "${myfiles}" ]; then
-		python_mod_compile ${myfiles}
+	if ((${#myfiles[@]})); then
+		python_mod_compile "${myfiles[@]}"
 	fi
 
 	eend $?






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2008-10-26 21:21 Ali Polatel (hawking)
  0 siblings, 0 replies; 108+ messages in thread
From: Ali Polatel (hawking) @ 2008-10-26 21:21 UTC (permalink / raw
  To: gentoo-commits

hawking     08/10/26 21:21:34

  Modified:             python.eclass
  Log:
  Bashify python_mod_cleanup, make it work for paths with spaces in them.

Revision  Changes    Path
1.50                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.50&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.50&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.49&r2=1.50

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -r1.49 -r1.50
--- python.eclass	26 Oct 2008 17:46:31 -0000	1.49
+++ python.eclass	26 Oct 2008 21:21:34 -0000	1.50
@@ -1,6 +1,6 @@
 # Copyright 1999-2008 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.49 2008/10/26 17:46:31 hawking Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.50 2008/10/26 21:21:34 hawking Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -278,7 +278,7 @@
 #
 # This function should only be run in pkg_postrm()
 python_mod_cleanup() {
-	local SEARCH_PATH myroot
+	local SEARCH_PATH=() myroot src_py
 
 	# Check if phase is pkg_postrm()
 	[[ ${EBUILD_PHASE} != postrm ]] &&\
@@ -287,28 +287,25 @@
 	# strip trailing slash
 	myroot="${ROOT%/}"
 
-	if [ $# -gt 0 ]; then
-		for path in $@; do
-			SEARCH_PATH="${SEARCH_PATH} ${myroot}/${path#/}"
-		done
+	if (($#)); then
+		SEARCH_PATH=("${@#/}")
+		SEARCH_PATH=("${SEARCH_PATH[@]/#/$myroot/}")
 	else
-		for path in ${myroot}/usr/lib*/python*/site-packages; do
-			SEARCH_PATH="${SEARCH_PATH} ${path}"
-		done
+		SEARCH_PATH=("${myroot}"/usr/lib*/python*/site-packages)
 	fi
 
-	for path in ${SEARCH_PATH}; do
+	for path in "${SEARCH_PATH[@]}"; do
 		einfo "Cleaning orphaned Python bytecode from ${path} .."
-		for obj in $(find ${path} -name '*.py[co]'); do
-			src_py="${obj%[co]}"
-			if [ ! -f "${src_py}" ]; then
-				einfo "Purging ${src_py}[co]"
-				rm -f ${src_py}[co]
-			fi
-		done
+		while read -rd ''; do
+			src_py="${REPLY%[co]}"
+			[[ -f "${src_py}" ]] && continue
+			einfo "Purging ${src_py}[co]"
+			rm -f "${src_py}"[co]
+		done < <(find "${path}" -name '*.py[co]' -print0)
+
 		# attempt to remove directories that maybe empty
-		for dir in $(find ${path} -type d | sort -r); do
-			rmdir ${dir} 2>/dev/null
-		done
+		while read -r dir; do
+			rmdir "${dir}" 2>/dev/null
+		done < <(find "${path}" -type d | sort -r)
 	done
 }






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2008-10-26 21:54 Ali Polatel (hawking)
  0 siblings, 0 replies; 108+ messages in thread
From: Ali Polatel (hawking) @ 2008-10-26 21:54 UTC (permalink / raw
  To: gentoo-commits

hawking     08/10/26 21:54:32

  Modified:             python.eclass
  Log:
  Quoting.

Revision  Changes    Path
1.51                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.51&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.51&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.50&r2=1.51

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- python.eclass	26 Oct 2008 21:21:34 -0000	1.50
+++ python.eclass	26 Oct 2008 21:54:32 -0000	1.51
@@ -1,6 +1,6 @@
 # Copyright 1999-2008 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.50 2008/10/26 21:21:34 hawking Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.51 2008/10/26 21:54:32 hawking Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -173,7 +173,7 @@
 	myroot="${ROOT%/}"
 
 	# respect ROOT
-	for f in $@; do
+	for f in "$@"; do
 		[[ -f "${myroot}/${f}" ]] && myfiles+=("${myroot}/${f}")
 	done
 






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2008-10-27  0:17 Ali Polatel (hawking)
  0 siblings, 0 replies; 108+ messages in thread
From: Ali Polatel (hawking) @ 2008-10-27  0:17 UTC (permalink / raw
  To: gentoo-commits

hawking     08/10/27 00:17:28

  Modified:             python.eclass
  Log:
  Add python_need_rebuild marker function. The first step for a faster python-updater :)

Revision  Changes    Path
1.52                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.52&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.52&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.51&r2=1.52

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- python.eclass	26 Oct 2008 21:54:32 -0000	1.51
+++ python.eclass	27 Oct 2008 00:17:28 -0000	1.52
@@ -1,6 +1,6 @@
 # Copyright 1999-2008 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.51 2008/10/26 21:54:32 hawking Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.52 2008/10/27 00:17:28 hawking Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -91,6 +91,14 @@
 
 python_disable_pyc
 
+# @FUNCTION: python_need_rebuild
+# @DESCRIPTION: Run without arguments, specifies that the package should be
+# rebuilt after a python upgrade.
+python_need_rebuild() {
+	python_version
+	export PYTHON_NEED_REBUILD=${PYVER}
+}
+
 # @FUNCTION: python_get_libdir
 # @DESCRIPTION:
 # Run without arguments, returns the python library dir






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2008-10-27 12:23 Ali Polatel (hawking)
  0 siblings, 0 replies; 108+ messages in thread
From: Ali Polatel (hawking) @ 2008-10-27 12:23 UTC (permalink / raw
  To: gentoo-commits

hawking     08/10/27 12:23:50

  Modified:             python.eclass
  Log:
  Don't call python_version in python_{en,dis}able_pyc because they may be called in global scope.

Revision  Changes    Path
1.53                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.53&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.53&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.52&r2=1.53

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -r1.52 -r1.53
--- python.eclass	27 Oct 2008 00:17:28 -0000	1.52
+++ python.eclass	27 Oct 2008 12:23:50 -0000	1.53
@@ -1,6 +1,6 @@
 # Copyright 1999-2008 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.52 2008/10/27 00:17:28 hawking Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.53 2008/10/27 12:23:50 hawking Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -68,12 +68,8 @@
 # note:   supported by >=dev-lang/python-2.2.3-r3 only.
 #
 python_disable_pyc() {
-	python_version
-	if [[ ${PYVER/./,} -ge 2,6 ]]; then
-		export PYTHONDONTWRITEBYTECODE=1
-	else
-		export PYTHON_DONTCOMPILE=1
-	fi
+	export PYTHONDONTWRITEBYTECODE=1 # For 2.6 and above
+	export PYTHON_DONTCOMPILE=1 # For 2.5 and below
 }
 
 # @FUNCTION: python_enable_pyc
@@ -81,12 +77,8 @@
 # Tells python to automatically recompile modules to .pyc/.pyo if the
 # timestamps/version stamps change
 python_enable_pyc() {
-	python_version
-	if [[ ${PYVER/./,} -ge 2,6 ]]; then
-		unset PYTHONDONTWRITEBYTECODE
-	else
-		unset PYTHON_DONTCOMPILE
-	fi
+	unset PYTHONDONTWRITEBYTECODE
+	unset PYTHON_DONTCOMPILE
 }
 
 python_disable_pyc






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2008-10-30  5:21 Zac Medico (zmedico)
  0 siblings, 0 replies; 108+ messages in thread
From: Zac Medico (zmedico) @ 2008-10-30  5:21 UTC (permalink / raw
  To: gentoo-commits

zmedico     08/10/30 05:21:46

  Modified:             python.eclass
  Log:
  Bug #244946 - Use different syntax to pipe find output into while loops inside
  python_mod_cleanup(), as a workaround for a bug in <bash-3.2 which causes
  incorrect saving of the environment when < <(find ...) syntax is used. The bug
  causes bash to die when attempting to source the resulting environment file.
  A similar issue has affected eutils.eclass in the past, triggering bug #215340.
  
  Also fix inverted argument validation logic inside python_mod_exists(), broken
  since version 1.47. Thanks to zlin for reporting.

Revision  Changes    Path
1.54                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.54&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.54&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.53&r2=1.54

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -r1.53 -r1.54
--- python.eclass	27 Oct 2008 12:23:50 -0000	1.53
+++ python.eclass	30 Oct 2008 05:21:46 -0000	1.54
@@ -1,6 +1,6 @@
 # Copyright 1999-2008 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.53 2008/10/27 12:23:50 hawking Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.54 2008/10/30 05:21:46 zmedico Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -142,7 +142,7 @@
 #             echo "gtk support enabled"
 #         fi
 python_mod_exists() {
-	[[ "$1" ]] && die "${FUNCNAME} requires an argument!"
+	[[ "$1" ]] || die "${FUNCNAME} requires an argument!"
 	python -c "import $1" >/dev/null 2>&1
 }
 
@@ -296,16 +296,16 @@
 
 	for path in "${SEARCH_PATH[@]}"; do
 		einfo "Cleaning orphaned Python bytecode from ${path} .."
-		while read -rd ''; do
+		find "${path}" -name '*.py[co]' -print0 | while read -rd ''; do
 			src_py="${REPLY%[co]}"
 			[[ -f "${src_py}" ]] && continue
 			einfo "Purging ${src_py}[co]"
 			rm -f "${src_py}"[co]
-		done < <(find "${path}" -name '*.py[co]' -print0)
+		done
 
 		# attempt to remove directories that maybe empty
-		while read -r dir; do
+		find "${path}" -type d | sort -r | while read -r dir; do
 			rmdir "${dir}" 2>/dev/null
-		done < <(find "${path}" -type d | sort -r)
+		done
 	done
 }






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2009-05-27 22:49 Petteri Raty (betelgeuse)
  0 siblings, 0 replies; 108+ messages in thread
From: Petteri Raty (betelgeuse) @ 2009-05-27 22:49 UTC (permalink / raw
  To: gentoo-commits

betelgeuse    09/05/27 22:49:32

  Modified:             python.eclass
  Log:
  Add support for PYTHON_USE_WITH* variables

Revision  Changes    Path
1.55                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.55&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.55&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.54&r2=1.55

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -r1.54 -r1.55
--- python.eclass	30 Oct 2008 05:21:46 -0000	1.54
+++ python.eclass	27 May 2009 22:49:32 -0000	1.55
@@ -1,6 +1,6 @@
 # Copyright 1999-2008 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.54 2008/10/30 05:21:46 zmedico Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.55 2009/05/27 22:49:32 betelgeuse Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -14,8 +14,11 @@
 
 
 if [[ -n "${NEED_PYTHON}" ]] ; then
-	DEPEND=">=dev-lang/python-${NEED_PYTHON}"
+	PYTHON_ATOM=">=dev-lang/python-${NEED_PYTHON}"
+	DEPEND="${PYTHON_ATOM}"
 	RDEPEND="${DEPEND}"
+else
+	PYTHON_ATOM="dev-lang/python"
 fi
 
 __python_eclass_test() {
@@ -59,6 +62,78 @@
 	__python_version_extract $PYVER_ALL
 }
 
+# @ECLASS-VARIABLE: PYTHON_USE_WITH
+# @DESCRIPTION:
+# Set this to a space separated list of use flags
+# the python slot in use must be built with.
+
+# @ECLASS-VARIABLE: PYTHON_USE_WITH_OR
+# @DESCRIPTION:
+# Set this to a space separated list of use flags
+# of which one must be turned on for the slot of
+# in use.
+
+# @ECLASS-VARIABLE: PYTHON_USE_WITH_OPT
+# @DESCRIPTION:
+# Set this if you need to make either PYTHON_USE_WITH or
+# PYTHON_USE_WITH_OR atoms conditional under a use flag.
+
+# @FUNCTION: python_pkg_setup
+# @DESCRIPTION:
+# Makes sure PYTHON_USE_WITH or PYTHON_USE_WITH_OR listed use flags
+# are respected. Only exported if one of those variables is set.
+if ! has ${EAPI} 0 1 && [[ -n ${PYTHON_USE_WITH} || -n ${PYTHON_USE_WITH_OR} ]]; then
+	python_pkg_setup_fail() {
+		eerror "${1}"
+		die "${1}"
+	}
+
+	python_pkg_setup() {
+		[[ ${PYTHON_USE_WITH_OPT} ]] && use !${PYTHON_USE_WITH_OPT} && return
+
+		python_version
+		local failed
+		local pyatom="dev-lang/python:${PYVER}"
+
+		for use in ${PYTHON_USE_WITH}; do
+			if ! has_version "${pyatom}[${use}]"; then
+				python_pkg_setup_fail \
+					"Please rebuild ${pyatom} with use flags: ${PYTHON_USE_WITH}"
+			fi
+		done
+
+		for use in ${PYTHON_USE_WITH_OR}; do
+			if has_version "${pyatom}[${use}]"; then
+				return
+			fi
+		done
+
+		if [[ ${PYTHON_USE_WITH_OR} ]]; then
+			python_pkg_setup_fail \
+				"Please rebuild ${pyatom} with one of: ${PYTHON_USE_WITH_OR}"
+		fi
+	}
+
+	EXPORT_FUNCTIONS pkg_setup
+
+	if [[ ${PYTHON_USE_WITH} ]]; then
+		PYTHON_USE_WITH_ATOM="${PYTHON_ATOM}[${PYTHON_USE_WITH/ /,}]"
+	elif [[ ${PYTHON_USE_WITH_OR} ]]; then
+		PYTHON_USE_WITH_ATOM="|| ( "
+		for use in ${PYTHON_USE_WITH_OR}; do
+			PYTHON_USE_WITH_ATOM="
+				${PYTHON_USE_WITH_ATOM}
+				${PYTHON_ATOM}[${use}]"
+		done
+		PYTHON_USE_WITH_ATOM="${PYTHON_USE_WITH_ATOM} )"
+	fi
+	if [[ ${PYTHON_USE_WITH_OPT} ]]; then
+		PYTHON_USE_WITH_ATOM="${PYTHON_USE_WITH_OPT}? ( ${PYTHON_USE_WITH_ATOM} )"
+	fi
+	DEPEND="${PYTHON_USE_WITH_ATOM}"
+	RDEPEND="${PYTHON_USE_WITH_ATOM}"
+fi
+
 # @FUNCTION: python_disable_pyc
 # @DESCRIPTION:
 # Tells python not to automatically recompile modules to .pyc/.pyo






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2009-08-02 16:56 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2009-08-02 16:56 UTC (permalink / raw
  To: gentoo-commits

arfrever    09/08/02 16:56:42

  Modified:             python.eclass
  Log:
  Add check to ensure that /usr/bin/python and /usr/bin/python-config are scripts.

Revision  Changes    Path
1.57                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.57&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.57&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.56&r2=1.57

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -r1.56 -r1.57
--- python.eclass	1 Aug 2009 22:36:20 -0000	1.56
+++ python.eclass	2 Aug 2009 16:56:41 -0000	1.57
@@ -1,6 +1,6 @@
 # Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.56 2009/08/01 22:36:20 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.57 2009/08/02 16:56:41 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -112,6 +112,14 @@
 # @DESCRIPTION:
 # Make sure PYTHON_ABIS variable has valid value.
 validate_PYTHON_ABIS() {
+	# Ensure that /usr/bin/python and /usr/bin/python-config are scripts.
+	if [[ "$(</usr/bin/python)" != *"Gentoo Python wrapper script"* ]]; then
+		die "/usr/bin/python isn't valid script"
+	fi
+	if [[ "$(</usr/bin/python-config)" != *"Gentoo python-config wrapper script"* ]]; then
+		die "/usr/bin/python-config isn't valid script"
+	fi
+
 	# USE_${ABI_TYPE^^} and RESTRICT_${ABI_TYPE^^}_ABIS variables hopefully will be included in EAPI >= 4.
 	if [[ -z "${PYTHON_ABIS}" ]] && has "${EAPI:-0}" 0 1 2 3; then
 		local ABI support_ABI supported_PYTHON_ABIS= restricted_ABI






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2009-08-03 22:28 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2009-08-03 22:28 UTC (permalink / raw
  To: gentoo-commits

arfrever    09/08/03 22:28:01

  Modified:             python.eclass
  Log:
  Add --default-function option of python_execute_function().

Revision  Changes    Path
1.58                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.58&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.58&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.57&r2=1.58

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- python.eclass	2 Aug 2009 16:56:41 -0000	1.57
+++ python.eclass	3 Aug 2009 22:28:01 -0000	1.58
@@ -1,6 +1,6 @@
 # Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.57 2009/08/02 16:56:41 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.58 2009/08/03 22:28:01 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -187,12 +187,12 @@
 }
 
 # @FUNCTION: python_execute_function
-# @USAGE: [--action-message message] [--failure-message message] [--nonfatal] [-q|--quiet] [-s|--separate-build-dirs] <function> [arguments]
+# @USAGE: [--action-message message] [-d|--default-function] [--failure-message message] [--nonfatal] [-q|--quiet] [-s|--separate-build-dirs] <function> [arguments]
 # @DESCRIPTION:
 # Execute specified function for each value of PYTHON_ABIS, optionally passing
 # additional arguments. The specified function can use PYTHON_ABI variable.
 python_execute_function() {
-	local action action_message action_message_template= failure_message failure_message_template= function nonfatal="0" PYTHON_ABI quiet="0" separate_build_dirs="0"
+	local action action_message action_message_template= default_function="0" failure_message failure_message_template= function nonfatal="0" PYTHON_ABI quiet="0" separate_build_dirs="0"
 
 	while (($#)); do
 		case "$1" in
@@ -200,6 +200,9 @@
 				action_message_template="$2"
 				shift
 				;;
+			-d|--default-function)
+				default_function="1"
+				;;
 			--failure-message)
 				failure_message_template="$2"
 				shift
@@ -223,11 +226,45 @@
 		shift
 	done
 
-	if [[ "$#" -eq "0" ]]; then
-		die "${FUNCNAME}(): Missing function name"
+	if [[ "${default_function}" == "0" ]]; then
+		if [[ "$#" -eq "0" ]]; then
+			die "${FUNCNAME}(): Missing function name"
+		fi
+		function="$1"
+		shift
+	else
+		if [[ "$#" -ne "0" ]]; then
+			die "${FUNCNAME}(): --default-function option and function name cannot be specified simultaneously"
+		fi
+		if has "${EAPI:-0}" 0 1; then
+			die "${FUNCNAME}(): --default-function option cannot be used in this EAPI"
+		fi
+
+		if [[ "${EBUILD_PHASE}" == "configure" ]]; then
+			python_default_function() {
+				econf
+			}
+		elif [[ "${EBUILD_PHASE}" == "compile" ]]; then
+			python_default_function() {
+				emake
+			}
+		elif [[ "${EBUILD_PHASE}" == "test" ]]; then
+			python_default_function() {
+				if emake -j1 -n check &> /dev/null; then
+					emake -j1 check
+				elif emake -j1 -n test &> /dev/null; then
+					emake -j1 test
+				fi
+			}
+		elif [[ "${EBUILD_PHASE}" == "install" ]]; then
+			python_default_function() {
+				emake DESTDIR="${D}" install
+			}
+		else
+			die "${FUNCNAME}(): --default-function option cannot be used in this ebuild phase"
+		fi
+		function="python_default_function"
 	fi
-	function="$1"
-	shift
 
 	if [[ "${quiet}" == "0" ]]; then
 		[[ "${EBUILD_PHASE}" == "setup" ]] && action="Setting up"
@@ -292,6 +329,10 @@
 			popd > /dev/null || die "popd failed"
 		fi
 	done
+
+	if [[ "${default_function}" == "1" ]]; then
+		unset -f python_default_function
+	fi
 }
 
 






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2009-08-04 21:01 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2009-08-04 21:01 UTC (permalink / raw
  To: gentoo-commits

arfrever    09/08/04 21:01:25

  Modified:             python.eclass
  Log:
  Update dependency on app-admin/eselect-python. Update check for /usr/bin/python.

Revision  Changes    Path
1.59                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.59&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.59&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.58&r2=1.59

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -r1.58 -r1.59
--- python.eclass	3 Aug 2009 22:28:01 -0000	1.58
+++ python.eclass	4 Aug 2009 21:01:25 -0000	1.59
@@ -1,6 +1,6 @@
 # Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.58 2009/08/03 22:28:01 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.59 2009/08/04 21:01:25 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -22,7 +22,7 @@
 fi
 
 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
-	DEPEND="${DEPEND} >=app-admin/eselect-python-20090801"
+	DEPEND="${DEPEND} >=app-admin/eselect-python-20090804"
 fi
 
 __python_eclass_test() {
@@ -112,9 +112,9 @@
 # @DESCRIPTION:
 # Make sure PYTHON_ABIS variable has valid value.
 validate_PYTHON_ABIS() {
-	# Ensure that /usr/bin/python and /usr/bin/python-config are scripts.
-	if [[ "$(</usr/bin/python)" != *"Gentoo Python wrapper script"* ]]; then
-		die "/usr/bin/python isn't valid script"
+	# Ensure that /usr/bin/python and /usr/bin/python-config are valid.
+	if [[ "$(</usr/bin/python)" != *"Gentoo Python wrapper program"* ]]; then
+		die "/usr/bin/python isn't valid program"
 	fi
 	if [[ "$(</usr/bin/python-config)" != *"Gentoo python-config wrapper script"* ]]; then
 		die "/usr/bin/python-config isn't valid script"






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2009-08-05 18:31 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2009-08-05 18:31 UTC (permalink / raw
  To: gentoo-commits

arfrever    09/08/05 18:31:30

  Modified:             python.eclass
  Log:
  Rename get_python() to PYTHON(). Set BUILDDIR in python_execute_function().

Revision  Changes    Path
1.60                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.60&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.60&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.59&r2=1.60

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -r1.59 -r1.60
--- python.eclass	4 Aug 2009 21:01:25 -0000	1.59
+++ python.eclass	5 Aug 2009 18:31:30 -0000	1.60
@@ -1,6 +1,6 @@
 # Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.59 2009/08/04 21:01:25 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.60 2009/08/05 18:31:30 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -66,12 +66,12 @@
 	__python_version_extract $PYVER_ALL
 }
 
-# @FUNCTION: get_python
+# @FUNCTION: PYTHON
 # @USAGE: [-a|--absolute-path] <Python_ABI="${PYTHON_ABI}">
 # @DESCRIPTION:
 # Get Python interpreter filename for specified Python ABI. If Python_ABI argument
 # is ommitted, then PYTHON_ABI environment variable must be set and is used.
-get_python() {
+PYTHON() {
 	local absolute_path="0" slot=
 
 	while (($#)); do
@@ -189,8 +189,8 @@
 # @FUNCTION: python_execute_function
 # @USAGE: [--action-message message] [-d|--default-function] [--failure-message message] [--nonfatal] [-q|--quiet] [-s|--separate-build-dirs] <function> [arguments]
 # @DESCRIPTION:
-# Execute specified function for each value of PYTHON_ABIS, optionally passing
-# additional arguments. The specified function can use PYTHON_ABI variable.
+# Execute specified function for each value of PYTHON_ABIS, optionally passing additional
+# arguments. The specified function can use PYTHON_ABI and BUILDDIR variables.
 python_execute_function() {
 	local action action_message action_message_template= default_function="0" failure_message failure_message_template= function nonfatal="0" PYTHON_ABI quiet="0" separate_build_dirs="0"
 
@@ -304,9 +304,12 @@
 			echo " ${GREEN}*${NORMAL} ${BLUE}${action_message}${NORMAL}"
 		fi
 		if [[ "${separate_build_dirs}" == "1" ]]; then
-			pushd "${S}-${PYTHON_ABI}" > /dev/null || die "pushd failed"
+			export BUILDDIR="${S}-${PYTHON_ABI}"
+			pushd "${BUILDDIR}" > /dev/null || die "pushd failed"
+		else
+			export BUILDDIR="${S}"
 		fi
-		if ! EPYTHON="$(get_python)" "${function}" "$@"; then
+		if ! EPYTHON="$(PYTHON)" "${function}" "$@"; then
 			if [[ -n "${failure_message_template}" ]]; then
 				failure_message="$(eval echo -n "${failure_message_template}")"
 			else
@@ -328,6 +331,7 @@
 		if [[ "${separate_build_dirs}" == "1" ]]; then
 			popd > /dev/null || die "popd failed"
 		fi
+		unset BUILDDIR
 	done
 
 	if [[ "${default_function}" == "1" ]]; then
@@ -635,15 +639,15 @@
 					for dir in "${site_packages_dirs[@]}"; do
 						site_packages_absolute_dirs+=("${root}/$(python_get_sitedir)/${dir}")
 					done
-					"$(get_python)" "${root}/$(python_get_libdir)/compileall.py" "${options[@]}" "${site_packages_absolute_dirs[@]}" || return_code="1"
-					"$(get_python)" -O "${root}/$(python_get_libdir)/compileall.py" "${options[@]}" "${site_packages_absolute_dirs[@]}"  || return_code="1"
+					"$(PYTHON)" "${root}/$(python_get_libdir)/compileall.py" "${options[@]}" "${site_packages_absolute_dirs[@]}" || return_code="1"
+					"$(PYTHON)" -O "${root}/$(python_get_libdir)/compileall.py" "${options[@]}" "${site_packages_absolute_dirs[@]}"  || return_code="1"
 				fi
 				if ((${#site_packages_files[@]})); then
 					for file in "${site_packages_files[@]}"; do
 						site_packages_absolute_files+=("${root}/$(python_get_sitedir)/${file}")
 					done
-					"$(get_python)" "${root}/$(python_get_libdir)/py_compile.py" "${site_packages_absolute_files[@]}" || return_code="1"
-					"$(get_python)" -O "${root}/$(python_get_libdir)/py_compile.py" "${site_packages_absolute_files[@]}" || return_code="1"
+					"$(PYTHON)" "${root}/$(python_get_libdir)/py_compile.py" "${site_packages_absolute_files[@]}" || return_code="1"
+					"$(PYTHON)" -O "${root}/$(python_get_libdir)/py_compile.py" "${site_packages_absolute_files[@]}" || return_code="1"
 				fi
 				eend "${return_code}"
 			fi






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2009-08-07  0:43 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2009-08-07  0:43 UTC (permalink / raw
  To: gentoo-commits

arfrever    09/08/07 00:43:16

  Modified:             python.eclass
  Log:
  Prints errors occuring during running python_mod_compile()/python_mod_optimize() only once. Improve python_execute_function().

Revision  Changes    Path
1.61                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.61&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.61&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.60&r2=1.61

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -r1.60 -r1.61
--- python.eclass	5 Aug 2009 18:31:30 -0000	1.60
+++ python.eclass	7 Aug 2009 00:43:16 -0000	1.61
@@ -1,6 +1,6 @@
 # Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.60 2009/08/05 18:31:30 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.61 2009/08/07 00:43:16 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -241,9 +241,15 @@
 		fi
 
 		if [[ "${EBUILD_PHASE}" == "configure" ]]; then
-			python_default_function() {
-				econf
-			}
+			if has "${EAPI}" 2; then
+				python_default_function() {
+					econf
+				}
+			else
+				python_default_function() {
+					nonfatal econf
+				}
+			fi
 		elif [[ "${EBUILD_PHASE}" == "compile" ]]; then
 			python_default_function() {
 				emake
@@ -552,7 +558,7 @@
 
 	if ((${#myfiles[@]})); then
 		python${PYVER} ${myroot}/usr/$(get_libdir)/python${PYVER}/py_compile.py "${myfiles[@]}"
-		python${PYVER} -O ${myroot}/usr/$(get_libdir)/python${PYVER}/py_compile.py "${myfiles[@]}"
+		python${PYVER} -O ${myroot}/usr/$(get_libdir)/python${PYVER}/py_compile.py "${myfiles[@]}" 2> /dev/null
 	else
 		ewarn "No files to compile!"
 	fi
@@ -640,14 +646,14 @@
 						site_packages_absolute_dirs+=("${root}/$(python_get_sitedir)/${dir}")
 					done
 					"$(PYTHON)" "${root}/$(python_get_libdir)/compileall.py" "${options[@]}" "${site_packages_absolute_dirs[@]}" || return_code="1"
-					"$(PYTHON)" -O "${root}/$(python_get_libdir)/compileall.py" "${options[@]}" "${site_packages_absolute_dirs[@]}"  || return_code="1"
+					"$(PYTHON)" -O "${root}/$(python_get_libdir)/compileall.py" "${options[@]}" "${site_packages_absolute_dirs[@]}" 2> /dev/null || return_code="1"
 				fi
 				if ((${#site_packages_files[@]})); then
 					for file in "${site_packages_files[@]}"; do
 						site_packages_absolute_files+=("${root}/$(python_get_sitedir)/${file}")
 					done
 					"$(PYTHON)" "${root}/$(python_get_libdir)/py_compile.py" "${site_packages_absolute_files[@]}" || return_code="1"
-					"$(PYTHON)" -O "${root}/$(python_get_libdir)/py_compile.py" "${site_packages_absolute_files[@]}" || return_code="1"
+					"$(PYTHON)" -O "${root}/$(python_get_libdir)/py_compile.py" "${site_packages_absolute_files[@]}" 2> /dev/null || return_code="1"
 				fi
 				eend "${return_code}"
 			fi
@@ -662,11 +668,11 @@
 			ebegin "Compilation and optimization of Python modules placed outside of site-packages directories for Python ${PYVER}..."
 			if ((${#other_dirs[@]})); then
 				python${PYVER} "${root}/$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" || return_code="1"
-				python${PYVER} -O "${root}/$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" || return_code="1"
+				python${PYVER} -O "${root}/$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" 2> /dev/null || return_code="1"
 			fi
 			if ((${#other_files[@]})); then
 				python${PYVER} "${root}/$(python_get_libdir)/py_compile.py" "${other_files[@]}" || return_code="1"
-				python${PYVER} -O "${root}/$(python_get_libdir)/py_compile.py" "${other_files[@]}" || return_code="1"
+				python${PYVER} -O "${root}/$(python_get_libdir)/py_compile.py" "${other_files[@]}" 2> /dev/null || return_code="1"
 			fi
 			eend "${return_code}"
 		fi
@@ -722,7 +728,7 @@
 				"${myopts[@]}" "${mydirs[@]}"
 			python${PYVER} -O \
 				"${myroot}"/usr/$(get_libdir)/python${PYVER}/compileall.py \
-				"${myopts[@]}" "${mydirs[@]}"
+				"${myopts[@]}" "${mydirs[@]}" 2> /dev/null
 		fi
 
 		if ((${#myfiles[@]})); then






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2009-08-13 16:57 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2009-08-13 16:57 UTC (permalink / raw
  To: gentoo-commits

arfrever    09/08/13 16:57:01

  Modified:             python.eclass
  Log:
  Don't include needless '/' characters before $(python_get_sitedir). Don't try to find *.py[co] files in directories already removed due to being empty. Display messages about purging of *.py[co] files only once for each pair of *.py[co] files. Display messages about removing of empty directories.

Revision  Changes    Path
1.62                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.62&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.62&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.61&r2=1.62

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -r1.61 -r1.62
--- python.eclass	7 Aug 2009 00:43:16 -0000	1.61
+++ python.eclass	13 Aug 2009 16:57:01 -0000	1.62
@@ -1,6 +1,6 @@
 # Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.61 2009/08/07 00:43:16 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.62 2009/08/13 16:57:01 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -616,13 +616,13 @@
 						fi
 					else
 						for PYTHON_ABI in ${PYTHON_ABIS}; do
-							if [[ -d "${root}/$(python_get_sitedir)/$1" ]]; then
+							if [[ -d "${root}$(python_get_sitedir)/$1" ]]; then
 								site_packages_dirs+=("$1")
 								break
-							elif [[ -f "${root}/$(python_get_sitedir)/$1" ]]; then
+							elif [[ -f "${root}$(python_get_sitedir)/$1" ]]; then
 								site_packages_files+=("$1")
 								break
-							elif [[ -e "${root}/$(python_get_sitedir)/$1" ]]; then
+							elif [[ -e "${root}$(python_get_sitedir)/$1" ]]; then
 								ewarn "'$1' is not a file or a directory!"
 							else
 								ewarn "'$1' doesn't exist!"
@@ -643,17 +643,17 @@
 				ebegin "Compilation and optimization of Python modules for Python ${PYTHON_ABI}"
 				if ((${#site_packages_dirs[@]})); then
 					for dir in "${site_packages_dirs[@]}"; do
-						site_packages_absolute_dirs+=("${root}/$(python_get_sitedir)/${dir}")
+						site_packages_absolute_dirs+=("${root}$(python_get_sitedir)/${dir}")
 					done
-					"$(PYTHON)" "${root}/$(python_get_libdir)/compileall.py" "${options[@]}" "${site_packages_absolute_dirs[@]}" || return_code="1"
-					"$(PYTHON)" -O "${root}/$(python_get_libdir)/compileall.py" "${options[@]}" "${site_packages_absolute_dirs[@]}" 2> /dev/null || return_code="1"
+					"$(PYTHON)" "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${site_packages_absolute_dirs[@]}" || return_code="1"
+					"$(PYTHON)" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${site_packages_absolute_dirs[@]}" 2> /dev/null || return_code="1"
 				fi
 				if ((${#site_packages_files[@]})); then
 					for file in "${site_packages_files[@]}"; do
-						site_packages_absolute_files+=("${root}/$(python_get_sitedir)/${file}")
+						site_packages_absolute_files+=("${root}$(python_get_sitedir)/${file}")
 					done
-					"$(PYTHON)" "${root}/$(python_get_libdir)/py_compile.py" "${site_packages_absolute_files[@]}" || return_code="1"
-					"$(PYTHON)" -O "${root}/$(python_get_libdir)/py_compile.py" "${site_packages_absolute_files[@]}" 2> /dev/null || return_code="1"
+					"$(PYTHON)" "${root}$(python_get_libdir)/py_compile.py" "${site_packages_absolute_files[@]}" || return_code="1"
+					"$(PYTHON)" -O "${root}$(python_get_libdir)/py_compile.py" "${site_packages_absolute_files[@]}" 2> /dev/null || return_code="1"
 				fi
 				eend "${return_code}"
 			fi
@@ -667,12 +667,12 @@
 			return_code="0"
 			ebegin "Compilation and optimization of Python modules placed outside of site-packages directories for Python ${PYVER}..."
 			if ((${#other_dirs[@]})); then
-				python${PYVER} "${root}/$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" || return_code="1"
-				python${PYVER} -O "${root}/$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" 2> /dev/null || return_code="1"
+				python${PYVER} "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" || return_code="1"
+				python${PYVER} -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" 2> /dev/null || return_code="1"
 			fi
 			if ((${#other_files[@]})); then
-				python${PYVER} "${root}/$(python_get_libdir)/py_compile.py" "${other_files[@]}" || return_code="1"
-				python${PYVER} -O "${root}/$(python_get_libdir)/py_compile.py" "${other_files[@]}" 2> /dev/null || return_code="1"
+				python${PYVER} "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" || return_code="1"
+				python${PYVER} -O "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" 2> /dev/null || return_code="1"
 			fi
 			eend "${return_code}"
 		fi
@@ -768,7 +768,7 @@
 					SEARCH_PATH+=("${root}/${1#/}")
 				else
 					for PYTHON_ABI in ${PYTHON_ABIS}; do
-						SEARCH_PATH+=("${root}/$(python_get_sitedir)/$1")
+						SEARCH_PATH+=("${root}$(python_get_sitedir)/$1")
 					done
 				fi
 				shift
@@ -782,17 +782,18 @@
 	fi
 
 	for path in "${SEARCH_PATH[@]}"; do
+		[[ ! -d "${path}" ]] && continue
 		einfo "Cleaning orphaned Python bytecode from ${path} .."
 		find "${path}" -name '*.py[co]' -print0 | while read -rd ''; do
 			src_py="${REPLY%[co]}"
-			[[ -f "${src_py}" ]] && continue
+			[[ -f "${src_py}" || (! -f "${src_py}c" && ! -f "${src_py}o") ]] && continue
 			einfo "Purging ${src_py}[co]"
 			rm -f "${src_py}"[co]
 		done
 
 		# Attempt to remove directories that may be empty.
 		find "${path}" -type d | sort -r | while read -r dir; do
-			rmdir "${dir}" 2>/dev/null
+			rmdir "${dir}" 2>/dev/null && einfo "Removing empty directory ${dir}"
 		done
 	done
 }






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2009-08-14 21:22 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2009-08-14 21:22 UTC (permalink / raw
  To: gentoo-commits

arfrever    09/08/14 21:22:47

  Modified:             python.eclass
  Log:
  Small updates.

Revision  Changes    Path
1.63                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.63&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.63&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.62&r2=1.63

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -r1.62 -r1.63
--- python.eclass	13 Aug 2009 16:57:01 -0000	1.62
+++ python.eclass	14 Aug 2009 21:22:47 -0000	1.63
@@ -1,6 +1,6 @@
 # Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.62 2009/08/13 16:57:01 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.63 2009/08/14 21:22:47 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -113,8 +113,8 @@
 # Make sure PYTHON_ABIS variable has valid value.
 validate_PYTHON_ABIS() {
 	# Ensure that /usr/bin/python and /usr/bin/python-config are valid.
-	if [[ "$(</usr/bin/python)" != *"Gentoo Python wrapper program"* ]]; then
-		die "/usr/bin/python isn't valid program"
+	if [[ "$(readlink /usr/bin/python)" != "python-wrapper" ]]; then
+		die "/usr/bin/python isn't valid symlink"
 	fi
 	if [[ "$(</usr/bin/python-config)" != *"Gentoo python-config wrapper script"* ]]; then
 		die "/usr/bin/python-config isn't valid script"
@@ -558,7 +558,7 @@
 
 	if ((${#myfiles[@]})); then
 		python${PYVER} ${myroot}/usr/$(get_libdir)/python${PYVER}/py_compile.py "${myfiles[@]}"
-		python${PYVER} -O ${myroot}/usr/$(get_libdir)/python${PYVER}/py_compile.py "${myfiles[@]}" 2> /dev/null
+		python${PYVER} -O ${myroot}/usr/$(get_libdir)/python${PYVER}/py_compile.py "${myfiles[@]}" &> /dev/null
 	else
 		ewarn "No files to compile!"
 	fi
@@ -646,14 +646,14 @@
 						site_packages_absolute_dirs+=("${root}$(python_get_sitedir)/${dir}")
 					done
 					"$(PYTHON)" "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${site_packages_absolute_dirs[@]}" || return_code="1"
-					"$(PYTHON)" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${site_packages_absolute_dirs[@]}" 2> /dev/null || return_code="1"
+					"$(PYTHON)" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${site_packages_absolute_dirs[@]}" &> /dev/null || return_code="1"
 				fi
 				if ((${#site_packages_files[@]})); then
 					for file in "${site_packages_files[@]}"; do
 						site_packages_absolute_files+=("${root}$(python_get_sitedir)/${file}")
 					done
 					"$(PYTHON)" "${root}$(python_get_libdir)/py_compile.py" "${site_packages_absolute_files[@]}" || return_code="1"
-					"$(PYTHON)" -O "${root}$(python_get_libdir)/py_compile.py" "${site_packages_absolute_files[@]}" 2> /dev/null || return_code="1"
+					"$(PYTHON)" -O "${root}$(python_get_libdir)/py_compile.py" "${site_packages_absolute_files[@]}" &> /dev/null || return_code="1"
 				fi
 				eend "${return_code}"
 			fi
@@ -668,16 +668,16 @@
 			ebegin "Compilation and optimization of Python modules placed outside of site-packages directories for Python ${PYVER}..."
 			if ((${#other_dirs[@]})); then
 				python${PYVER} "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" || return_code="1"
-				python${PYVER} -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" 2> /dev/null || return_code="1"
+				python${PYVER} -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" &> /dev/null || return_code="1"
 			fi
 			if ((${#other_files[@]})); then
 				python${PYVER} "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" || return_code="1"
-				python${PYVER} -O "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" 2> /dev/null || return_code="1"
+				python${PYVER} -O "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" &> /dev/null || return_code="1"
 			fi
 			eend "${return_code}"
 		fi
 	else
-		local myroot mydirs=() myfiles=() myopts=()
+		local myroot mydirs=() myfiles=() myopts=() return_code="0"
 
 		# strip trailing slash
 		myroot="${ROOT%/}"
@@ -725,17 +725,17 @@
 		if ((${#mydirs[@]})); then
 			python${PYVER} \
 				"${myroot}"/usr/$(get_libdir)/python${PYVER}/compileall.py \
-				"${myopts[@]}" "${mydirs[@]}"
+				"${myopts[@]}" "${mydirs[@]}" || return_code="1"
 			python${PYVER} -O \
 				"${myroot}"/usr/$(get_libdir)/python${PYVER}/compileall.py \
-				"${myopts[@]}" "${mydirs[@]}" 2> /dev/null
+				"${myopts[@]}" "${mydirs[@]}" &> /dev/null || return_code="1"
 		fi
 
 		if ((${#myfiles[@]})); then
 			python_mod_compile "${myfiles[@]}"
 		fi
 
-		eend $?
+		eend "${return_code}"
 	fi
 }
 






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2009-08-15 21:50 Petteri Raty (betelgeuse)
  0 siblings, 0 replies; 108+ messages in thread
From: Petteri Raty (betelgeuse) @ 2009-08-15 21:50 UTC (permalink / raw
  To: gentoo-commits

betelgeuse    09/08/15 21:50:31

  Modified:             python.eclass
  Log:
  Fix PYTHON_USE_WITH to work properly with EAPI 0.

Revision  Changes    Path
1.64                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.64&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.64&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.63&r2=1.64

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -r1.63 -r1.64
--- python.eclass	14 Aug 2009 21:22:47 -0000	1.63
+++ python.eclass	15 Aug 2009 21:50:31 -0000	1.64
@@ -1,6 +1,6 @@
 # Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.63 2009/08/14 21:22:47 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.64 2009/08/15 21:50:31 betelgeuse Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -366,7 +366,7 @@
 # @DESCRIPTION:
 # Makes sure PYTHON_USE_WITH or PYTHON_USE_WITH_OR listed use flags
 # are respected. Only exported if one of those variables is set.
-if ! has ${EAPI} 0 1 && [[ -n ${PYTHON_USE_WITH} || -n ${PYTHON_USE_WITH_OR} ]]; then
+if ! has ${EAPI:-0} 0 1 && [[ -n ${PYTHON_USE_WITH} || -n ${PYTHON_USE_WITH_OR} ]]; then
 	python_pkg_setup_fail() {
 		eerror "${1}"
 		die "${1}"






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2009-08-15 23:32 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2009-08-15 23:32 UTC (permalink / raw
  To: gentoo-commits

arfrever    09/08/15 23:32:58

  Modified:             python.eclass
  Log:
  Remove unused python_makesym() function.

Revision  Changes    Path
1.65                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.65&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.65&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.64&r2=1.65

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -r1.64 -r1.65
--- python.eclass	15 Aug 2009 21:50:31 -0000	1.64
+++ python.eclass	15 Aug 2009 23:32:58 -0000	1.65
@@ -1,6 +1,6 @@
 # Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.64 2009/08/15 21:50:31 betelgeuse Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.65 2009/08/15 23:32:58 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -10,8 +10,8 @@
 # @BLURB: A Utility Eclass that should be inherited by anything that deals with Python or Python modules.
 # @DESCRIPTION:
 # Some useful functions for dealing with python.
-inherit alternatives multilib
 
+inherit multilib
 
 if [[ -n "${NEED_PYTHON}" ]] ; then
 	PYTHON_ATOM=">=dev-lang/python-${NEED_PYTHON}"
@@ -481,15 +481,6 @@
 	echo "$(python_get_libdir)/site-packages"
 }
 
-# @FUNCTION: python_makesym
-# @DESCRIPTION:
-# Run without arguments, it will create the /usr/bin/python symlinks
-# to the latest installed version
-python_makesym() {
-	alternatives_auto_makesym "/usr/bin/python" "python[0-9].[0-9]"
-	alternatives_auto_makesym "/usr/bin/python2" "python2.[0-9]"
-}
-
 # @FUNCTION: python_tkinter_exists
 # @DESCRIPTION:
 # Run without arguments, checks if python was compiled with Tkinter






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2009-08-28 16:08 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2009-08-28 16:08 UTC (permalink / raw
  To: gentoo-commits

arfrever    09/08/28 16:08:52

  Modified:             python.eclass
  Log:
  Update dependencies. Add more sanity checks. Improve python_execute_function().

Revision  Changes    Path
1.66                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.66&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.66&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.65&r2=1.66

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -r1.65 -r1.66
--- python.eclass	15 Aug 2009 23:32:58 -0000	1.65
+++ python.eclass	28 Aug 2009 16:08:51 -0000	1.66
@@ -1,6 +1,6 @@
 # Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.65 2009/08/15 23:32:58 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.66 2009/08/28 16:08:51 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -9,7 +9,7 @@
 # original author: Alastair Tse <liquidx@gentoo.org>
 # @BLURB: A Utility Eclass that should be inherited by anything that deals with Python or Python modules.
 # @DESCRIPTION:
-# Some useful functions for dealing with python.
+# Some useful functions for dealing with Python.
 
 inherit multilib
 
@@ -21,6 +21,7 @@
 	PYTHON_ATOM="dev-lang/python"
 fi
 
+DEPEND="${DEPEND} >=app-shells/bash-3.2"
 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
 	DEPEND="${DEPEND} >=app-admin/eselect-python-20090804"
 fi
@@ -112,12 +113,17 @@
 # @DESCRIPTION:
 # Make sure PYTHON_ABIS variable has valid value.
 validate_PYTHON_ABIS() {
+	# Ensure that some functions cannot be accidentally successfully used in EAPI <= 2 without setting SUPPORT_PYTHON_ABIS variable.
+	if has "${EAPI:-0}" 0 1 2 && [[ -z "${SUPPORT_PYTHON_ABIS}" ]]; then
+		die "${FUNCNAME}() cannot be used in this EAPI without setting SUPPORT_PYTHON_ABIS variable"
+	fi
+
 	# Ensure that /usr/bin/python and /usr/bin/python-config are valid.
 	if [[ "$(readlink /usr/bin/python)" != "python-wrapper" ]]; then
-		die "/usr/bin/python isn't valid symlink"
+		die "'/usr/bin/python' isn't valid symlink"
 	fi
 	if [[ "$(</usr/bin/python-config)" != *"Gentoo python-config wrapper script"* ]]; then
-		die "/usr/bin/python-config isn't valid script"
+		die "'/usr/bin/python-config' isn't valid script"
 	fi
 
 	# USE_${ABI_TYPE^^} and RESTRICT_${ABI_TYPE^^}_ABIS variables hopefully will be included in EAPI >= 4.
@@ -130,12 +136,14 @@
 				continue
 			fi
 			support_ABI="1"
-			for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
-				if python -c "from fnmatch import fnmatch; exit(not fnmatch('${ABI}', '${restricted_ABI}'))"; then
-					support_ABI="0"
-					break
-				fi
-			done
+			if [[ -z "${IGNORE_RESTRICT_PYTHON_ABIS}" ]]; then
+				for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
+					if python -c "from fnmatch import fnmatch; exit(not fnmatch('${ABI}', '${restricted_ABI}'))"; then
+						support_ABI="0"
+						break
+					fi
+				done
+			fi
 			[[ "${support_ABI}" == "1" ]] && supported_PYTHON_ABIS+=" ${ABI}"
 		done
 		export PYTHON_ABIS="${supported_PYTHON_ABIS# }"
@@ -145,6 +153,14 @@
 		python_version
 		export PYTHON_ABIS="${PYVER}"
 	fi
+
+	# Ensure that EPYTHON variable is respected.
+	local PYTHON_ABI
+	for PYTHON_ABI in ${PYTHON_ABIS}; do
+		if [[ "$(EPYTHON="$(PYTHON)" python -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')" != "${PYTHON_ABI}" ]]; then
+			die "'python' doesn't respect EPYTHON variable"
+		fi
+	done
 }
 
 # @FUNCTION: python_copy_sources
@@ -178,7 +194,7 @@
 python_set_build_dir_symlink() {
 	local dir="$1"
 
-	[[ -z "${PYTHON_ABIS}" ]] && die "PYTHON_ABIS variable not set"
+	[[ -z "${PYTHON_ABI}" ]] && die "PYTHON_ABI variable not set"
 	[[ -z "${dir}" ]] && dir="build"
 
 	# Don't delete preexistent directories.
@@ -309,18 +325,27 @@
 			fi
 			echo " ${GREEN}*${NORMAL} ${BLUE}${action_message}${NORMAL}"
 		fi
+
 		if [[ "${separate_build_dirs}" == "1" ]]; then
 			export BUILDDIR="${S}-${PYTHON_ABI}"
 			pushd "${BUILDDIR}" > /dev/null || die "pushd failed"
 		else
 			export BUILDDIR="${S}"
 		fi
-		if ! EPYTHON="$(PYTHON)" "${function}" "$@"; then
+
+		if ! has "${EAPI}" 0 1 2 && has "${PYTHON_ABI}" ${FAILURE_TOLERANT_PYTHON_ABIS}; then
+			EPYTHON="$(PYTHON)" nonfatal "${function}" "$@"
+		else
+			EPYTHON="$(PYTHON)" "${function}" "$@"
+		fi
+
+		if [[ "$?" != "0" ]]; then
 			if [[ -n "${failure_message_template}" ]]; then
 				failure_message="$(eval echo -n "${failure_message_template}")"
 			else
 				failure_message="${action} failed with Python ${PYTHON_ABI} in ${function}() function"
 			fi
+
 			if [[ "${nonfatal}" == "1" ]] || has "${PYTHON_ABI}" ${FAILURE_TOLERANT_PYTHON_ABIS}; then
 				local ABI enabled_PYTHON_ABIS
 				for ABI in ${PYTHON_ABIS}; do
@@ -334,6 +359,7 @@
 				die "${failure_message}"
 			fi
 		fi
+
 		if [[ "${separate_build_dirs}" == "1" ]]; then
 			popd > /dev/null || die "popd failed"
 		fi
@@ -420,24 +446,19 @@
 
 # @FUNCTION: python_disable_pyc
 # @DESCRIPTION:
-# Tells python not to automatically recompile modules to .pyc/.pyo
+# Tell Python not to automatically recompile modules to .pyc/.pyo
 # even if the timestamps/version stamps don't match. This is done
 # to protect sandbox.
-#
-# note:   supported by >=dev-lang/python-2.2.3-r3 only.
-#
 python_disable_pyc() {
-	export PYTHONDONTWRITEBYTECODE=1 # For 2.6 and above
-	export PYTHON_DONTCOMPILE=1 # For 2.5 and below
+	export PYTHONDONTWRITEBYTECODE="1"
 }
 
 # @FUNCTION: python_enable_pyc
 # @DESCRIPTION:
-# Tells python to automatically recompile modules to .pyc/.pyo if the
-# timestamps/version stamps change
+# Tell Python to automatically recompile modules to .pyc/.pyo if the
+# timestamps/version stamps have changed.
 python_enable_pyc() {
 	unset PYTHONDONTWRITEBYTECODE
-	unset PYTHON_DONTCOMPILE
 }
 
 python_disable_pyc






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2009-08-29  2:15 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2009-08-29  2:15 UTC (permalink / raw
  To: gentoo-commits

arfrever    09/08/29 02:15:24

  Modified:             python.eclass
  Log:
  Ensure that defined functions are passed to python_execute_function(). Add PYTHON_DEFINE_DEFAULT_FUNCTIONS variable.

Revision  Changes    Path
1.67                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.67&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.67&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.66&r2=1.67

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -r1.66 -r1.67
--- python.eclass	28 Aug 2009 16:08:51 -0000	1.66
+++ python.eclass	29 Aug 2009 02:15:24 -0000	1.67
@@ -1,6 +1,6 @@
 # Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.66 2009/08/28 16:08:51 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.67 2009/08/29 02:15:24 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -233,7 +233,7 @@
 				separate_build_dirs="1"
 				;;
 			-*)
-				die "${FUNCNAME}(): Unrecognized option $1"
+				die "${FUNCNAME}(): Unrecognized option '$1'"
 				;;
 			*)
 				break
@@ -248,12 +248,16 @@
 		fi
 		function="$1"
 		shift
+
+		if [[ -z "$(type -t "${function}")" ]]; then
+			die "${FUNCNAME}(): '${function}' function isn't defined"
+		fi
 	else
 		if [[ "$#" -ne "0" ]]; then
-			die "${FUNCNAME}(): --default-function option and function name cannot be specified simultaneously"
+			die "${FUNCNAME}(): '--default-function' option and function name cannot be specified simultaneously"
 		fi
 		if has "${EAPI:-0}" 0 1; then
-			die "${FUNCNAME}(): --default-function option cannot be used in this EAPI"
+			die "${FUNCNAME}(): '--default-function' option cannot be used in this EAPI"
 		fi
 
 		if [[ "${EBUILD_PHASE}" == "configure" ]]; then
@@ -392,7 +396,7 @@
 # @DESCRIPTION:
 # Makes sure PYTHON_USE_WITH or PYTHON_USE_WITH_OR listed use flags
 # are respected. Only exported if one of those variables is set.
-if ! has ${EAPI:-0} 0 1 && [[ -n ${PYTHON_USE_WITH} || -n ${PYTHON_USE_WITH_OR} ]]; then
+if ! has "${EAPI:-0}" 0 1 && [[ -n ${PYTHON_USE_WITH} || -n ${PYTHON_USE_WITH_OR} ]]; then
 	python_pkg_setup_fail() {
 		eerror "${1}"
 		die "${1}"
@@ -444,6 +448,23 @@
 	RDEPEND="${PYTHON_USE_WITH_ATOM}"
 fi
 
+# @ECLASS-VARIABLE: PYTHON_DEFINE_DEFAULT_FUNCTIONS
+# @DESCRIPTION:
+# Set this to define default functions for the following ebuild phases:
+# src_prepare, src_configure, src_compile, src_test, src_install.
+if ! has "${EAPI:-0}" 0 1 && [[ -n "${PYTHON_DEFINE_DEFAULT_FUNCTIONS}" ]]; then
+	python_src_prepare() {
+		python_copy_sources
+	}
+
+	for python_default_function in src_configure src_compile src_test src_install; do
+		eval "python_${python_default_function}() { python_execute_function -d -s; }"
+	done
+	unset python_default_function
+
+	EXPORT_FUNCTIONS src_prepare src_configure src_compile src_test src_install
+fi
+
 # @FUNCTION: python_disable_pyc
 # @DESCRIPTION:
 # Tell Python not to automatically recompile modules to .pyc/.pyo






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2009-08-31  0:07 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2009-08-31  0:07 UTC (permalink / raw
  To: gentoo-commits

arfrever    09/08/31 00:07:38

  Modified:             python.eclass
  Log:
  Improve validate_PYTHON_ABIS().

Revision  Changes    Path
1.68                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.68&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.68&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.67&r2=1.68

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -r1.67 -r1.68
--- python.eclass	29 Aug 2009 02:15:24 -0000	1.67
+++ python.eclass	31 Aug 2009 00:07:37 -0000	1.68
@@ -1,6 +1,6 @@
 # Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.67 2009/08/29 02:15:24 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.68 2009/08/31 00:07:37 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -130,28 +130,41 @@
 	if [[ -z "${PYTHON_ABIS}" ]] && has "${EAPI:-0}" 0 1 2 3; then
 		local ABI support_ABI supported_PYTHON_ABIS= restricted_ABI
 		PYTHON_ABI_SUPPORTED_VALUES="2.4 2.5 2.6 2.7 3.0 3.1 3.2"
-		for ABI in ${USE_PYTHON}; do
-			if ! has "${ABI}" ${PYTHON_ABI_SUPPORTED_VALUES}; then
-				ewarn "Ignoring unsupported Python ABI '${ABI}'"
-				continue
+
+		if declare -p | grep "^declare -x USE_PYTHON=" > /dev/null; then
+			if [[ -z "${USE_PYTHON}" ]]; then
+				die "USE_PYTHON variable is empty"
 			fi
-			support_ABI="1"
-			if [[ -z "${IGNORE_RESTRICT_PYTHON_ABIS}" ]]; then
+
+			for ABI in ${USE_PYTHON}; do
+				if ! has "${ABI}" ${PYTHON_ABI_SUPPORTED_VALUES}; then
+					die "USE_PYTHON variable contains invalid value '${ABI}'"
+				fi
+				support_ABI="1"
 				for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
 					if python -c "from fnmatch import fnmatch; exit(not fnmatch('${ABI}', '${restricted_ABI}'))"; then
 						support_ABI="0"
 						break
 					fi
 				done
+				[[ "${support_ABI}" == "1" ]] && supported_PYTHON_ABIS+=" ${ABI}"
+			done
+			export PYTHON_ABIS="${supported_PYTHON_ABIS# }"
+
+			if [[ -z "${PYTHON_ABIS//[${IFS}]/}" ]]; then
+				die "USE_PYTHON variable doesn't enable any Python version supported by ${CATEGORY}/${PF}"
 			fi
-			[[ "${support_ABI}" == "1" ]] && supported_PYTHON_ABIS+=" ${ABI}"
-		done
-		export PYTHON_ABIS="${supported_PYTHON_ABIS# }"
-	fi
+		else
+			local restricted_ABI
+			python_version
 
-	if [[ -z "${PYTHON_ABIS//[${IFS}]/}" ]]; then
-		python_version
-		export PYTHON_ABIS="${PYVER}"
+			for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
+				if python -c "from fnmatch import fnmatch; exit(not fnmatch('${PYVER}', '${restricted_ABI}'))"; then
+					die "Active Python version isn't supported by ${CATEGORY}/${PF}"
+				fi
+			done
+			export PYTHON_ABIS="${PYVER}"
+		fi
 	fi
 
 	# Ensure that EPYTHON variable is respected.






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2009-08-31 23:58 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2009-08-31 23:58 UTC (permalink / raw
  To: gentoo-commits

arfrever    09/08/31 23:58:28

  Modified:             python.eclass
  Log:
  Improve validate_PYTHON_ABIS() and python_execute_function().

Revision  Changes    Path
1.69                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.69&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.69&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.68&r2=1.69

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -r1.68 -r1.69
--- python.eclass	31 Aug 2009 00:07:37 -0000	1.68
+++ python.eclass	31 Aug 2009 23:58:28 -0000	1.69
@@ -1,6 +1,6 @@
 # Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.68 2009/08/31 00:07:37 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.69 2009/08/31 23:58:28 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -131,7 +131,7 @@
 		local ABI support_ABI supported_PYTHON_ABIS= restricted_ABI
 		PYTHON_ABI_SUPPORTED_VALUES="2.4 2.5 2.6 2.7 3.0 3.1 3.2"
 
-		if declare -p | grep "^declare -x USE_PYTHON=" > /dev/null; then
+		if [[ "$(declare -p USE_PYTHON 2>/dev/null)" == "declare -x USE_PYTHON="* ]]; then
 			if [[ -z "${USE_PYTHON}" ]]; then
 				die "USE_PYTHON variable is empty"
 			fi
@@ -363,8 +363,12 @@
 				failure_message="${action} failed with Python ${PYTHON_ABI} in ${function}() function"
 			fi
 
-			if [[ "${nonfatal}" == "1" ]] || has "${PYTHON_ABI}" ${FAILURE_TOLERANT_PYTHON_ABIS}; then
-				local ABI enabled_PYTHON_ABIS
+			if [[ "${nonfatal}" == "1" ]]; then
+				if [[ "${quiet}" == "0" ]]; then
+					ewarn "${RED}${failure_message}${NORMAL}"
+				fi
+			elif has "${PYTHON_ABI}" ${FAILURE_TOLERANT_PYTHON_ABIS}; then
+				local ABI enabled_PYTHON_ABIS=
 				for ABI in ${PYTHON_ABIS}; do
 					[[ "${ABI}" != "${PYTHON_ABI}" ]] && enabled_PYTHON_ABIS+=" ${ABI}"
 				done
@@ -372,6 +376,9 @@
 				if [[ "${quiet}" == "0" ]]; then
 					ewarn "${RED}${failure_message}${NORMAL}"
 				fi
+				if [[ -z "${PYTHON_ABIS}" ]]; then
+					die "${function}() function failed with all enabled versions of Python"
+				fi
 			else
 				die "${failure_message}"
 			fi






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2009-09-05 17:30 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2009-09-05 17:30 UTC (permalink / raw
  To: gentoo-commits

arfrever    09/09/05 17:30:08

  Modified:             python.eclass
  Log:
  Improve validate_PYTHON_ABIS(). Improve handling of test failures in python_execute_function().

Revision  Changes    Path
1.70                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.70&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.70&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.69&r2=1.70

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -r1.69 -r1.70
--- python.eclass	31 Aug 2009 23:58:28 -0000	1.69
+++ python.eclass	5 Sep 2009 17:30:08 -0000	1.70
@@ -1,6 +1,6 @@
 # Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.69 2009/08/31 23:58:28 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.70 2009/09/05 17:30:08 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -127,11 +127,11 @@
 	fi
 
 	# USE_${ABI_TYPE^^} and RESTRICT_${ABI_TYPE^^}_ABIS variables hopefully will be included in EAPI >= 4.
-	if [[ -z "${PYTHON_ABIS}" ]] && has "${EAPI:-0}" 0 1 2 3; then
+	if [[ "$(declare -p PYTHON_ABIS 2> /dev/null)" != "declare -x PYTHON_ABIS="* ]] && has "${EAPI:-0}" 0 1 2 3; then
 		local ABI support_ABI supported_PYTHON_ABIS= restricted_ABI
 		PYTHON_ABI_SUPPORTED_VALUES="2.4 2.5 2.6 2.7 3.0 3.1 3.2"
 
-		if [[ "$(declare -p USE_PYTHON 2>/dev/null)" == "declare -x USE_PYTHON="* ]]; then
+		if [[ "$(declare -p USE_PYTHON 2> /dev/null)" == "declare -x USE_PYTHON="* ]]; then
 			if [[ -z "${USE_PYTHON}" ]]; then
 				die "USE_PYTHON variable is empty"
 			fi
@@ -368,11 +368,13 @@
 					ewarn "${RED}${failure_message}${NORMAL}"
 				fi
 			elif has "${PYTHON_ABI}" ${FAILURE_TOLERANT_PYTHON_ABIS}; then
-				local ABI enabled_PYTHON_ABIS=
-				for ABI in ${PYTHON_ABIS}; do
-					[[ "${ABI}" != "${PYTHON_ABI}" ]] && enabled_PYTHON_ABIS+=" ${ABI}"
-				done
-				export PYTHON_ABIS="${enabled_PYTHON_ABIS# }"
+				if [[ "${EBUILD_PHASE}" != "test" ]] || ! has test-fail-continue ${FEATURES}; then
+					local ABI enabled_PYTHON_ABIS=
+					for ABI in ${PYTHON_ABIS}; do
+						[[ "${ABI}" != "${PYTHON_ABI}" ]] && enabled_PYTHON_ABIS+=" ${ABI}"
+					done
+					export PYTHON_ABIS="${enabled_PYTHON_ABIS# }"
+				fi
 				if [[ "${quiet}" == "0" ]]; then
 					ewarn "${RED}${failure_message}${NORMAL}"
 				fi






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2009-09-09  4:16 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2009-09-09  4:16 UTC (permalink / raw
  To: gentoo-commits

arfrever    09/09/09 04:16:58

  Modified:             python.eclass
  Log:
  Add support for '--' option in some functions. Ensure that appropriate Python version is installed in validate_PYTHON_ABIS(). Add support for '--no-link' option in python_copy_sources().

Revision  Changes    Path
1.71                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.71&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.71&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.70&r2=1.71

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -r1.70 -r1.71
--- python.eclass	5 Sep 2009 17:30:08 -0000	1.70
+++ python.eclass	9 Sep 2009 04:16:58 -0000	1.71
@@ -1,6 +1,6 @@
 # Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.70 2009/09/05 17:30:08 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.71 2009/09/09 04:16:58 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -68,7 +68,7 @@
 }
 
 # @FUNCTION: PYTHON
-# @USAGE: [-a|--absolute-path] <Python_ABI="${PYTHON_ABI}">
+# @USAGE: [-a|--absolute-path] [--] <Python_ABI="${PYTHON_ABI}">
 # @DESCRIPTION:
 # Get Python interpreter filename for specified Python ABI. If Python_ABI argument
 # is ommitted, then PYTHON_ABI environment variable must be set and is used.
@@ -80,6 +80,9 @@
 			-a|--absolute-path)
 				absolute_path="1"
 				;;
+			--)
+				break
+				;;
 			-*)
 				die "${FUNCNAME}(): Unrecognized option $1"
 				;;
@@ -167,9 +170,14 @@
 		fi
 	fi
 
-	# Ensure that EPYTHON variable is respected.
 	local PYTHON_ABI
 	for PYTHON_ABI in ${PYTHON_ABIS}; do
+		# Ensure that appropriate Python version is installed.
+		if ! has_version "dev-lang/python:${PYTHON_ABI}"; then
+			die "dev-lang/python:${PYTHON_ABI} isn't installed"
+		fi
+
+		# Ensure that EPYTHON variable is respected.
 		if [[ "$(EPYTHON="$(PYTHON)" python -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')" != "${PYTHON_ABI}" ]]; then
 			die "'python' doesn't respect EPYTHON variable"
 		fi
@@ -177,11 +185,29 @@
 }
 
 # @FUNCTION: python_copy_sources
-# @USAGE: [directory]
+# @USAGE: [--no-link] [--] [directory]
 # @DESCRIPTION:
 # Copy unpacked sources of given package for each Python ABI.
 python_copy_sources() {
-	local dir dirs=() PYTHON_ABI
+	local dir dirs=() no_link="0" PYTHON_ABI
+
+	while (($#)); do
+		case "$1" in
+			--no-link)
+				no_link="1"
+				;;
+			--)
+				break
+				;;
+			-*)
+				die "${FUNCNAME}(): Unrecognized option '$1'"
+				;;
+			*)
+				break
+				;;
+		esac
+		shift
+	done
 
 	if [[ "$#" -eq "0" ]]; then
 		if [[ "${WORKDIR}" == "${S}" ]]; then
@@ -195,7 +221,11 @@
 	validate_PYTHON_ABIS
 	for PYTHON_ABI in ${PYTHON_ABIS}; do
 		for dir in "${dirs[@]}"; do
-			cp -lpr "${dir}" "${dir}-${PYTHON_ABI}" > /dev/null || die "Copying of sources failed"
+			if [[ "${no_link}" == "1" ]]; then
+				cp -pr "${dir}" "${dir}-${PYTHON_ABI}" > /dev/null || die "Copying of sources failed"
+			else
+				cp -lpr "${dir}" "${dir}-${PYTHON_ABI}" > /dev/null || die "Copying of sources failed"
+			fi
 		done
 	done
 }
@@ -216,7 +246,7 @@
 }
 
 # @FUNCTION: python_execute_function
-# @USAGE: [--action-message message] [-d|--default-function] [--failure-message message] [--nonfatal] [-q|--quiet] [-s|--separate-build-dirs] <function> [arguments]
+# @USAGE: [--action-message message] [-d|--default-function] [--failure-message message] [--nonfatal] [-q|--quiet] [-s|--separate-build-dirs] [--] <function> [arguments]
 # @DESCRIPTION:
 # Execute specified function for each value of PYTHON_ABIS, optionally passing additional
 # arguments. The specified function can use PYTHON_ABI and BUILDDIR variables.
@@ -245,6 +275,9 @@
 			-s|--separate-build-dirs)
 				separate_build_dirs="1"
 				;;
+			--)
+				break
+				;;
 			-*)
 				die "${FUNCNAME}(): Unrecognized option '$1'"
 				;;






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2009-09-11 19:55 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2009-09-11 19:55 UTC (permalink / raw
  To: gentoo-commits

arfrever    09/09/11 19:55:05

  Modified:             python.eclass
  Log:
  Improve handling of directory stack in python_execute_function().

Revision  Changes    Path
1.72                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.72&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.72&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.71&r2=1.72

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -r1.71 -r1.72
--- python.eclass	9 Sep 2009 04:16:58 -0000	1.71
+++ python.eclass	11 Sep 2009 19:55:05 -0000	1.72
@@ -1,6 +1,6 @@
 # Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.71 2009/09/09 04:16:58 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.72 2009/09/11 19:55:05 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -251,7 +251,7 @@
 # Execute specified function for each value of PYTHON_ABIS, optionally passing additional
 # arguments. The specified function can use PYTHON_ABI and BUILDDIR variables.
 python_execute_function() {
-	local action action_message action_message_template= default_function="0" failure_message failure_message_template= function nonfatal="0" PYTHON_ABI quiet="0" separate_build_dirs="0"
+	local action action_message action_message_template= default_function="0" failure_message failure_message_template= function nonfatal="0" previous_directory_stack_length PYTHON_ABI quiet="0" separate_build_dirs="0"
 
 	while (($#)); do
 		case "$1" in
@@ -383,6 +383,8 @@
 			export BUILDDIR="${S}"
 		fi
 
+		previous_directory_stack_length="${#DIRSTACK[@]}"
+
 		if ! has "${EAPI}" 0 1 2 && has "${PYTHON_ABI}" ${FAILURE_TOLERANT_PYTHON_ABIS}; then
 			EPYTHON="$(PYTHON)" nonfatal "${function}" "$@"
 		else
@@ -419,6 +421,14 @@
 			fi
 		fi
 
+		if [[ "${#DIRSTACK[@]}" -lt "${previous_directory_stack_length}" ]]; then
+			die "Directory stack decreased illegally"
+		fi
+
+		while [[ "${#DIRSTACK[@]}" -gt "${previous_directory_stack_length}" ]]; do
+			popd > /dev/null || die "popd failed"
+		done
+
 		if [[ "${separate_build_dirs}" == "1" ]]; then
 			popd > /dev/null || die "popd failed"
 		fi






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2009-09-18 17:50 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2009-09-18 17:50 UTC (permalink / raw
  To: gentoo-commits

arfrever    09/09/18 17:50:08

  Modified:             python.eclass
  Log:
  Improve handling of directory stack in python_execute_function().

Revision  Changes    Path
1.73                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.73&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.73&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.72&r2=1.73

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -r1.72 -r1.73
--- python.eclass	11 Sep 2009 19:55:05 -0000	1.72
+++ python.eclass	18 Sep 2009 17:50:08 -0000	1.73
@@ -1,12 +1,10 @@
 # Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.72 2009/09/11 19:55:05 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.73 2009/09/18 17:50:08 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
 # python@gentoo.org
-#
-# original author: Alastair Tse <liquidx@gentoo.org>
 # @BLURB: A Utility Eclass that should be inherited by anything that deals with Python or Python modules.
 # @DESCRIPTION:
 # Some useful functions for dealing with Python.
@@ -251,7 +249,7 @@
 # Execute specified function for each value of PYTHON_ABIS, optionally passing additional
 # arguments. The specified function can use PYTHON_ABI and BUILDDIR variables.
 python_execute_function() {
-	local action action_message action_message_template= default_function="0" failure_message failure_message_template= function nonfatal="0" previous_directory_stack_length PYTHON_ABI quiet="0" separate_build_dirs="0"
+	local action action_message action_message_template= default_function="0" failure_message failure_message_template= function nonfatal="0" previous_directory previous_directory_stack previous_directory_stack_length PYTHON_ABI quiet="0" separate_build_dirs="0"
 
 	while (($#)); do
 		case "$1" in
@@ -383,7 +381,9 @@
 			export BUILDDIR="${S}"
 		fi
 
-		previous_directory_stack_length="${#DIRSTACK[@]}"
+		previous_directory="$(pwd)"
+		previous_directory_stack="$(dirs -p)"
+		previous_directory_stack_length="$(dirs -p | wc -l)"
 
 		if ! has "${EAPI}" 0 1 2 && has "${PYTHON_ABI}" ${FAILURE_TOLERANT_PYTHON_ABIS}; then
 			EPYTHON="$(PYTHON)" nonfatal "${function}" "$@"
@@ -421,14 +421,27 @@
 			fi
 		fi
 
-		if [[ "${#DIRSTACK[@]}" -lt "${previous_directory_stack_length}" ]]; then
+		# Ensure that directory stack hasn't been decreased.
+		if [[ "$(dirs -p | wc -l)" -lt "${previous_directory_stack_length}" ]]; then
 			die "Directory stack decreased illegally"
 		fi
 
-		while [[ "${#DIRSTACK[@]}" -gt "${previous_directory_stack_length}" ]]; do
+		# Avoid side effects of earlier returning from the specified function.
+		while [[ "$(dirs -p | wc -l)" -gt "${previous_directory_stack_length}" ]]; do
 			popd > /dev/null || die "popd failed"
 		done
 
+		# Ensure that the bottom part of directory stack hasn't been changed. Restore
+		# previous directory (from before running of the specified function) before
+		# comparison of directory stacks to avoid mismatch of directory stacks after
+		# potential using of 'cd' to change current directory. Restoration of previous
+		# directory allows to safely use 'cd' to change current directory in the
+		# specified function without changing it back to original directory.
+		cd "${previous_directory}"
+		if [[ "$(dirs -p)" != "${previous_directory_stack}" ]]; then
+			die "Directory stack changed illegally"
+		fi
+
 		if [[ "${separate_build_dirs}" == "1" ]]; then
 			popd > /dev/null || die "popd failed"
 		fi






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2009-10-02  2:02 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2009-10-02  2:02 UTC (permalink / raw
  To: gentoo-commits

arfrever    09/10/02 02:02:24

  Modified:             python.eclass
  Log:
  Automatically enable Python 2 and Python 3 if no version has been explicitly enabled. Improve python_pkg_setup().

Revision  Changes    Path
1.74                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.74&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.74&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.73&r2=1.74

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -r1.73 -r1.74
--- python.eclass	18 Sep 2009 17:50:08 -0000	1.73
+++ python.eclass	2 Oct 2009 02:02:24 -0000	1.74
@@ -1,11 +1,11 @@
 # Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.73 2009/09/18 17:50:08 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.74 2009/10/02 02:02:24 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
 # python@gentoo.org
-# @BLURB: A Utility Eclass that should be inherited by anything that deals with Python or Python modules.
+# @BLURB: A utility eclass that should be inherited by anything that deals with Python or Python modules.
 # @DESCRIPTION:
 # Some useful functions for dealing with Python.
 
@@ -19,10 +19,8 @@
 	PYTHON_ATOM="dev-lang/python"
 fi
 
-DEPEND="${DEPEND} >=app-shells/bash-3.2"
-if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
-	DEPEND="${DEPEND} >=app-admin/eselect-python-20090804"
-fi
+DEPEND+=" >=app-admin/eselect-python-20090804
+	>=app-shells/bash-3.2"
 
 __python_eclass_test() {
 	__python_version_extract 2.3
@@ -129,7 +127,7 @@
 
 	# USE_${ABI_TYPE^^} and RESTRICT_${ABI_TYPE^^}_ABIS variables hopefully will be included in EAPI >= 4.
 	if [[ "$(declare -p PYTHON_ABIS 2> /dev/null)" != "declare -x PYTHON_ABIS="* ]] && has "${EAPI:-0}" 0 1 2 3; then
-		local ABI support_ABI supported_PYTHON_ABIS= restricted_ABI
+		local ABI restricted_ABI support_ABI supported_PYTHON_ABIS=
 		PYTHON_ABI_SUPPORTED_VALUES="2.4 2.5 2.6 2.7 3.0 3.1 3.2"
 
 		if [[ "$(declare -p USE_PYTHON 2> /dev/null)" == "declare -x USE_PYTHON="* ]]; then
@@ -153,18 +151,70 @@
 			export PYTHON_ABIS="${supported_PYTHON_ABIS# }"
 
 			if [[ -z "${PYTHON_ABIS//[${IFS}]/}" ]]; then
-				die "USE_PYTHON variable doesn't enable any Python version supported by ${CATEGORY}/${PF}"
+				die "USE_PYTHON variable doesn't enable any version of Python supported by ${CATEGORY}/${PF}"
 			fi
 		else
-			local restricted_ABI
-			python_version
+			local ABI python2_version= python2_supported_versions python3_version= python3_supported_versions restricted_ABI support_python_major_version
 
-			for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
-				if python -c "from fnmatch import fnmatch; exit(not fnmatch('${PYVER}', '${restricted_ABI}'))"; then
-					die "Active Python version isn't supported by ${CATEGORY}/${PF}"
+			if has_version "=dev-lang/python-2*"; then
+				if [[ "$(readlink /usr/bin/python2)" != "python2."* ]]; then
+					die "'/usr/bin/python2' isn't valid symlink"
 				fi
-			done
-			export PYTHON_ABIS="${PYVER}"
+
+				python2_version="$(/usr/bin/python2 -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')"
+				python2_supported_versions="2.4 2.5 2.6 2.7"
+
+				for ABI in ${python2_supported_versions}; do
+					support_python_major_version="1"
+					for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
+						if python -c "from fnmatch import fnmatch; exit(not fnmatch('${ABI}', '${restricted_ABI}'))"; then
+							support_python_major_version="0"
+						fi
+					done
+					[[ "${support_python_major_version}" == "1" ]] && break
+				done
+				if [[ "${support_python_major_version}" == "1" ]]; then
+					for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
+						if python -c "from fnmatch import fnmatch; exit(not fnmatch('${python2_version}', '${restricted_ABI}'))"; then
+							die "Active version of Python 2 isn't supported by ${CATEGORY}/${PF}"
+						fi
+					done
+				else
+					python2_version=""
+				fi
+			fi
+
+			if has_version "=dev-lang/python-3*"; then
+				if [[ "$(readlink /usr/bin/python3)" != "python3."* ]]; then
+					die "'/usr/bin/python3' isn't valid symlink"
+				fi
+
+				python3_version="$(/usr/bin/python3 -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')"
+				python3_supported_versions="3.0 3.1 3.2"
+
+				for ABI in ${python3_supported_versions}; do
+					support_python_major_version="1"
+					for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
+						if python -c "from fnmatch import fnmatch; exit(not fnmatch('${ABI}', '${restricted_ABI}'))"; then
+							support_python_major_version="0"
+						fi
+					done
+					[[ "${support_python_major_version}" == "1" ]] && break
+				done
+				if [[ "${support_python_major_version}" == "1" ]]; then
+					for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
+						if python -c "from fnmatch import fnmatch; exit(not fnmatch('${python3_version}', '${restricted_ABI}'))"; then
+							die "Active version of Python 3 isn't supported by ${CATEGORY}/${PF}"
+						fi
+					done
+				else
+					python3_version=""
+				fi
+			fi
+
+			PYTHON_ABIS="${python2_version} ${python3_version}"
+			PYTHON_ABIS="${PYTHON_ABIS# }"
+			export PYTHON_ABIS="${PYTHON_ABIS% }"
 		fi
 	fi
 
@@ -475,55 +525,64 @@
 # Makes sure PYTHON_USE_WITH or PYTHON_USE_WITH_OR listed use flags
 # are respected. Only exported if one of those variables is set.
 if ! has "${EAPI:-0}" 0 1 && [[ -n ${PYTHON_USE_WITH} || -n ${PYTHON_USE_WITH_OR} ]]; then
-	python_pkg_setup_fail() {
-		eerror "${1}"
-		die "${1}"
-	}
-
 	python_pkg_setup() {
-		[[ ${PYTHON_USE_WITH_OPT} ]] && use !${PYTHON_USE_WITH_OPT} && return
+		python_pkg_setup_fail() {
+			eerror "${1}"
+			die "${1}"
+		}
 
-		python_version
-		local failed
-		local pyatom="dev-lang/python:${PYVER}"
+		[[ ${PYTHON_USE_WITH_OPT} ]] && use !${PYTHON_USE_WITH_OPT} && return
 
-		for use in ${PYTHON_USE_WITH}; do
-			if ! has_version "${pyatom}[${use}]"; then
-				python_pkg_setup_fail \
-					"Please rebuild ${pyatom} with use flags: ${PYTHON_USE_WITH}"
+		python_pkg_setup_check_USE_flags() {
+			local pyatom use
+			if [[ -n "${PYTHON_ABI}" ]]; then
+				pyatom="dev-lang/python:${PYTHON_ABI}"
+			else
+				python_version
+				pyatom="dev-lang/python:${PYVER}"
 			fi
-		done
 
-		for use in ${PYTHON_USE_WITH_OR}; do
-			if has_version "${pyatom}[${use}]"; then
-				return
+			for use in ${PYTHON_USE_WITH}; do
+				if ! has_version "${pyatom}[${use}]"; then
+					python_pkg_setup_fail "Please rebuild ${pyatom} with the following USE flags enabled: ${PYTHON_USE_WITH}"
+				fi
+			done
+
+			for use in ${PYTHON_USE_WITH_OR}; do
+				if has_version "${pyatom}[${use}]"; then
+					return
+				fi
+			done
+
+			if [[ ${PYTHON_USE_WITH_OR} ]]; then
+				python_pkg_setup_fail "Please rebuild ${pyatom} with at least one of the following USE flags enabled: ${PYTHON_USE_WITH_OR}"
 			fi
-		done
+		}
 
-		if [[ ${PYTHON_USE_WITH_OR} ]]; then
-			python_pkg_setup_fail \
-				"Please rebuild ${pyatom} with one of: ${PYTHON_USE_WITH_OR}"
+		if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
+			python_execute_function -q python_pkg_setup_check_USE_flags
+		else
+			python_pkg_setup_check_USE_flags
 		fi
 	}
 
 	EXPORT_FUNCTIONS pkg_setup
 
-	if [[ ${PYTHON_USE_WITH} ]]; then
+	if [[ -n "${PYTHON_USE_WITH}" ]]; then
 		PYTHON_USE_WITH_ATOM="${PYTHON_ATOM}[${PYTHON_USE_WITH/ /,}]"
-	elif [[ ${PYTHON_USE_WITH_OR} ]]; then
+	elif [[ -n "${PYTHON_USE_WITH_OR}" ]]; then
 		PYTHON_USE_WITH_ATOM="|| ( "
 		for use in ${PYTHON_USE_WITH_OR}; do
-			PYTHON_USE_WITH_ATOM="
-				${PYTHON_USE_WITH_ATOM}
-				${PYTHON_ATOM}[${use}]"
+			PYTHON_USE_WITH_ATOM+=" ${PYTHON_ATOM}[${use}]"
 		done
-		PYTHON_USE_WITH_ATOM="${PYTHON_USE_WITH_ATOM} )"
+		unset use
+		PYTHON_USE_WITH_ATOM+=" )"
 	fi
-	if [[ ${PYTHON_USE_WITH_OPT} ]]; then
+	if [[ -n "${PYTHON_USE_WITH_OPT}" ]]; then
 		PYTHON_USE_WITH_ATOM="${PYTHON_USE_WITH_OPT}? ( ${PYTHON_USE_WITH_ATOM} )"
 	fi
-	DEPEND="${PYTHON_USE_WITH_ATOM}"
-	RDEPEND="${PYTHON_USE_WITH_ATOM}"
+	DEPEND+=" ${PYTHON_USE_WITH_ATOM}"
+	RDEPEND+=" ${PYTHON_USE_WITH_ATOM}"
 fi
 
 # @ECLASS-VARIABLE: PYTHON_DEFINE_DEFAULT_FUNCTIONS






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2009-10-02 17:32 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2009-10-02 17:32 UTC (permalink / raw
  To: gentoo-commits

arfrever    09/10/02 17:32:23

  Modified:             python.eclass
  Log:
  Print a warning when Python 2 or Python 3 is explicitly disabled.

Revision  Changes    Path
1.75                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.75&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.75&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.74&r2=1.75

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -r1.74 -r1.75
--- python.eclass	2 Oct 2009 02:02:24 -0000	1.74
+++ python.eclass	2 Oct 2009 17:32:23 -0000	1.75
@@ -1,6 +1,6 @@
 # Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.74 2009/10/02 02:02:24 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.75 2009/10/02 17:32:23 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -127,10 +127,14 @@
 
 	# USE_${ABI_TYPE^^} and RESTRICT_${ABI_TYPE^^}_ABIS variables hopefully will be included in EAPI >= 4.
 	if [[ "$(declare -p PYTHON_ABIS 2> /dev/null)" != "declare -x PYTHON_ABIS="* ]] && has "${EAPI:-0}" 0 1 2 3; then
-		local ABI restricted_ABI support_ABI supported_PYTHON_ABIS=
+		local ABI python2_supported_versions python3_supported_versions restricted_ABI support_ABI supported_PYTHON_ABIS=
 		PYTHON_ABI_SUPPORTED_VALUES="2.4 2.5 2.6 2.7 3.0 3.1 3.2"
+		python2_supported_versions="2.4 2.5 2.6 2.7"
+		python3_supported_versions="3.0 3.1 3.2"
 
 		if [[ "$(declare -p USE_PYTHON 2> /dev/null)" == "declare -x USE_PYTHON="* ]]; then
+			local python2_enabled="0" python3_enabled="0"
+
 			if [[ -z "${USE_PYTHON}" ]]; then
 				die "USE_PYTHON variable is empty"
 			fi
@@ -139,6 +143,14 @@
 				if ! has "${ABI}" ${PYTHON_ABI_SUPPORTED_VALUES}; then
 					die "USE_PYTHON variable contains invalid value '${ABI}'"
 				fi
+
+				if has "${ABI}" ${python2_supported_versions}; then
+					python2_enabled="1"
+				fi
+				if has "${ABI}" ${python3_supported_versions}; then
+					python3_enabled="1"
+				fi
+
 				support_ABI="1"
 				for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
 					if python -c "from fnmatch import fnmatch; exit(not fnmatch('${ABI}', '${restricted_ABI}'))"; then
@@ -153,8 +165,15 @@
 			if [[ -z "${PYTHON_ABIS//[${IFS}]/}" ]]; then
 				die "USE_PYTHON variable doesn't enable any version of Python supported by ${CATEGORY}/${PF}"
 			fi
+
+			if [[ "${python2_enabled}" == "0" ]]; then
+				ewarn "USE_PYTHON variable doesn't enable any version of Python 2. This configuration is unsupported."
+			fi
+			if [[ "${python3_enabled}" == "0" ]]; then
+				ewarn "USE_PYTHON variable doesn't enable any version of Python 3. This configuration is unsupported."
+			fi
 		else
-			local ABI python2_version= python2_supported_versions python3_version= python3_supported_versions restricted_ABI support_python_major_version
+			local python2_version= python3_version= support_python_major_version
 
 			if has_version "=dev-lang/python-2*"; then
 				if [[ "$(readlink /usr/bin/python2)" != "python2."* ]]; then
@@ -162,7 +181,6 @@
 				fi
 
 				python2_version="$(/usr/bin/python2 -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')"
-				python2_supported_versions="2.4 2.5 2.6 2.7"
 
 				for ABI in ${python2_supported_versions}; do
 					support_python_major_version="1"
@@ -190,7 +208,6 @@
 				fi
 
 				python3_version="$(/usr/bin/python3 -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')"
-				python3_supported_versions="3.0 3.1 3.2"
 
 				for ABI in ${python3_supported_versions}; do
 					support_python_major_version="1"






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2009-10-02 23:09 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2009-10-02 23:09 UTC (permalink / raw
  To: gentoo-commits

arfrever    09/10/02 23:09:08

  Modified:             python.eclass
  Log:
  Add the check to ensure that Python wrapper is configured to use the same version of Python as /usr/bin/python2 or /usr/bin/python3. Add workaround in python_pkg_setup() for older versions of Portage not supporting Python 3.

Revision  Changes    Path
1.76                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.76&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.76&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.75&r2=1.76

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -r1.75 -r1.76
--- python.eclass	2 Oct 2009 17:32:23 -0000	1.75
+++ python.eclass	2 Oct 2009 23:09:08 -0000	1.76
@@ -1,6 +1,6 @@
 # Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.75 2009/10/02 17:32:23 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.76 2009/10/02 23:09:08 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -110,7 +110,7 @@
 
 # @FUNCTION: validate_PYTHON_ABIS
 # @DESCRIPTION:
-# Make sure PYTHON_ABIS variable has valid value.
+# Ensure that PYTHON_ABIS variable has valid value.
 validate_PYTHON_ABIS() {
 	# Ensure that some functions cannot be accidentally successfully used in EAPI <= 2 without setting SUPPORT_PYTHON_ABIS variable.
 	if has "${EAPI:-0}" 0 1 2 && [[ -z "${SUPPORT_PYTHON_ABIS}" ]]; then
@@ -173,7 +173,9 @@
 				ewarn "USE_PYTHON variable doesn't enable any version of Python 3. This configuration is unsupported."
 			fi
 		else
-			local python2_version= python3_version= support_python_major_version
+			local python_version python2_version= python3_version= support_python_major_version
+
+			python_version="$(/usr/bin/python -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')"
 
 			if has_version "=dev-lang/python-2*"; then
 				if [[ "$(readlink /usr/bin/python2)" != "python2."* ]]; then
@@ -229,6 +231,12 @@
 				fi
 			fi
 
+			if ! has "${python_version}" "${python2_version}" "${python3_version}"; then
+				eerror "Python wrapper is configured incorrectly or /usr/bin/python2 or /usr/bin/python3 symlink"
+				eerror "is set incorrectly. Use \`eselect python\` to fix configuration."
+				die "Incorrect configuration of Python"
+			fi
+
 			PYTHON_ABIS="${python2_version} ${python3_version}"
 			PYTHON_ABIS="${PYTHON_ABIS# }"
 			export PYTHON_ABIS="${PYTHON_ABIS% }"
@@ -559,6 +567,13 @@
 				pyatom="dev-lang/python:${PYVER}"
 			fi
 
+			# Workaround for older versions of Portage.
+			# has_version() calls portageq which is implemented in Python.
+			if has_version "=dev-lang/python-2*"; then
+				local EPYTHON
+				export EPYTHON="$(readlink /usr/bin/python2)"
+			fi
+
 			for use in ${PYTHON_USE_WITH}; do
 				if ! has_version "${pyatom}[${use}]"; then
 					python_pkg_setup_fail "Please rebuild ${pyatom} with the following USE flags enabled: ${PYTHON_USE_WITH}"






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2009-10-11 13:34 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2009-10-11 13:34 UTC (permalink / raw
  To: gentoo-commits

arfrever    09/10/11 13:34:24

  Modified:             python.eclass
  Log:
  Optimize validate_PYTHON_ABIS(). Add python_convert_shebangs(). Remove incomplete workaround for older versions of Portage in python_pkg_setup().

Revision  Changes    Path
1.77                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.77&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.77&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.76&r2=1.77

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -r1.76 -r1.77
--- python.eclass	2 Oct 2009 23:09:08 -0000	1.76
+++ python.eclass	11 Oct 2009 13:34:23 -0000	1.77
@@ -1,6 +1,6 @@
 # Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.76 2009/10/02 23:09:08 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.77 2009/10/11 13:34:23 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -11,7 +11,7 @@
 
 inherit multilib
 
-if [[ -n "${NEED_PYTHON}" ]] ; then
+if [[ -n "${NEED_PYTHON}" ]]; then
 	PYTHON_ATOM=">=dev-lang/python-${NEED_PYTHON}"
 	DEPEND="${PYTHON_ATOM}"
 	RDEPEND="${DEPEND}"
@@ -108,6 +108,9 @@
 	fi
 }
 
+unset PYTHON_ABIS
+unset PYTHON_ABIS_SANITY_CHECKS
+
 # @FUNCTION: validate_PYTHON_ABIS
 # @DESCRIPTION:
 # Ensure that PYTHON_ABIS variable has valid value.
@@ -153,7 +156,7 @@
 
 				support_ABI="1"
 				for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
-					if python -c "from fnmatch import fnmatch; exit(not fnmatch('${ABI}', '${restricted_ABI}'))"; then
+					if [[ "${ABI}" == ${restricted_ABI} ]]; then
 						support_ABI="0"
 						break
 					fi
@@ -187,7 +190,7 @@
 				for ABI in ${python2_supported_versions}; do
 					support_python_major_version="1"
 					for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
-						if python -c "from fnmatch import fnmatch; exit(not fnmatch('${ABI}', '${restricted_ABI}'))"; then
+						if [[ "${ABI}" == ${restricted_ABI} ]]; then
 							support_python_major_version="0"
 						fi
 					done
@@ -195,7 +198,7 @@
 				done
 				if [[ "${support_python_major_version}" == "1" ]]; then
 					for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
-						if python -c "from fnmatch import fnmatch; exit(not fnmatch('${python2_version}', '${restricted_ABI}'))"; then
+						if [[ "${python2_version}" == ${restricted_ABI} ]]; then
 							die "Active version of Python 2 isn't supported by ${CATEGORY}/${PF}"
 						fi
 					done
@@ -214,7 +217,7 @@
 				for ABI in ${python3_supported_versions}; do
 					support_python_major_version="1"
 					for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
-						if python -c "from fnmatch import fnmatch; exit(not fnmatch('${ABI}', '${restricted_ABI}'))"; then
+						if [[ "${ABI}" == ${restricted_ABI} ]]; then
 							support_python_major_version="0"
 						fi
 					done
@@ -222,7 +225,7 @@
 				done
 				if [[ "${support_python_major_version}" == "1" ]]; then
 					for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
-						if python -c "from fnmatch import fnmatch; exit(not fnmatch('${python3_version}', '${restricted_ABI}'))"; then
+						if [[ "${python3_version}" == ${restricted_ABI} ]]; then
 							die "Active version of Python 3 isn't supported by ${CATEGORY}/${PF}"
 						fi
 					done
@@ -243,18 +246,21 @@
 		fi
 	fi
 
-	local PYTHON_ABI
-	for PYTHON_ABI in ${PYTHON_ABIS}; do
-		# Ensure that appropriate Python version is installed.
-		if ! has_version "dev-lang/python:${PYTHON_ABI}"; then
-			die "dev-lang/python:${PYTHON_ABI} isn't installed"
-		fi
+	if [[ "$(declare -p PYTHON_ABIS_SANITY_CHECKS 2> /dev/null)" != "declare -- PYTHON_ABIS_SANITY_CHECKS="* ]]; then
+		local PYTHON_ABI
+		for PYTHON_ABI in ${PYTHON_ABIS}; do
+			# Ensure that appropriate Python version is installed.
+			if ! has_version "dev-lang/python:${PYTHON_ABI}"; then
+				die "dev-lang/python:${PYTHON_ABI} isn't installed"
+			fi
 
-		# Ensure that EPYTHON variable is respected.
-		if [[ "$(EPYTHON="$(PYTHON)" python -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')" != "${PYTHON_ABI}" ]]; then
-			die "'python' doesn't respect EPYTHON variable"
-		fi
-	done
+			# Ensure that EPYTHON variable is respected.
+			if [[ "$(EPYTHON="$(PYTHON)" python -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')" != "${PYTHON_ABI}" ]]; then
+				die "'python' doesn't respect EPYTHON variable"
+			fi
+		done
+		PYTHON_ABIS_SANITY_CHECKS="1"
+	fi
 }
 
 # @FUNCTION: python_copy_sources
@@ -528,6 +534,78 @@
 	fi
 }
 
+# @FUNCTION: python_convert_shebangs
+# @USAGE: [-q|--quiet] [-r|--recursive] [-x|--only-executables] [--] <Python_version> <file|directory> [files|directories]
+# @DESCRIPTION:
+# Convert shebangs in specified files. Directories can be specified only with --recursive option.
+python_convert_shebangs() {
+	local argument file files=() only_executables="0" python_version quiet="0" recursive="0"
+
+	while (($#)); do
+		case "$1" in
+			-r|--recursive)
+				recursive="1"
+				;;
+			-q|--quiet)
+				quiet="1"
+				;;
+			-x|--only-executables)
+				only_executables="1"
+				;;
+			--)
+				break
+				;;
+			-*)
+				die "${FUNCNAME}(): Unrecognized option '$1'"
+				;;
+			*)
+				break
+				;;
+		esac
+		shift
+	done
+
+	if [[ "$#" -eq 0 ]]; then
+		die "${FUNCNAME}(): Missing Python version and files or directories"
+	elif [[ "$#" -eq 1 ]]; then
+		die "${FUNCNAME}(): Missing files or directories"
+	fi
+
+	python_version="$1"
+	shift
+
+	for argument in "$@"; do
+		if [[ ! -e "${argument}" ]]; then
+			die "${FUNCNAME}(): '${argument}' doesn't exist"
+		elif [[ -f "${argument}" ]]; then
+			files+=("${argument}")
+		elif [[ -d "${argument}" ]]; then
+			if [[ "${recursive}" == "1" ]]; then
+				if [[ "${only_executables}" == "1" ]]; then
+					files+=($(find "${argument}" -perm /111 -type f))
+				else
+					files+=($(find "${argument}" -type f))
+				fi
+			else
+				die "${FUNCNAME}(): '${argument}' isn't a regular file"
+			fi
+		else
+			die "${FUNCNAME}(): '${argument}' isn't a regular file or a directory"
+		fi
+	done
+
+	for file in "${files[@]}"; do
+		[[ "${only_executables}" == "1" && ! -x "${file}" ]] && continue
+
+		if [[ "$(head -n1 "${file}")" =~ ^'#!'.*python ]]; then
+			[[ "${quiet}" == "0" ]] && einfo "Converting shebang in '${file}'"
+			sed -e "1s/python\([[:digit:]]\+\(\.[[:digit:]]\+\)\?\)\?/python${python_version}/" -i "${file}" || die "Conversion of shebang in '${file}' failed"
+
+			# Delete potential whitespace after "#!".
+			sed -e '1s/\(^#!\)[[:space:]]*/\1/' -i "${file}" || die "sed '${file}' failed"
+		fi
+	done
+}
 
 # @ECLASS-VARIABLE: PYTHON_USE_WITH
 # @DESCRIPTION:
@@ -567,13 +645,6 @@
 				pyatom="dev-lang/python:${PYVER}"
 			fi
 
-			# Workaround for older versions of Portage.
-			# has_version() calls portageq which is implemented in Python.
-			if has_version "=dev-lang/python-2*"; then
-				local EPYTHON
-				export EPYTHON="$(readlink /usr/bin/python2)"
-			fi
-
 			for use in ${PYTHON_USE_WITH}; do
 				if ! has_version "${pyatom}[${use}]"; then
 					python_pkg_setup_fail "Please rebuild ${pyatom} with the following USE flags enabled: ${PYTHON_USE_WITH}"






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2009-11-15 14:25 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2009-11-15 14:25 UTC (permalink / raw
  To: gentoo-commits

arfrever    09/11/15 14:25:55

  Modified:             python.eclass
  Log:
  Make PYTHON() support multilib systems. Improve output of python_convert_shebangs(). Support passing of regular files to python_mod_cleanup(). Improve output of python_mod_cleanup().

Revision  Changes    Path
1.78                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.78&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.78&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.77&r2=1.78

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -r1.77 -r1.78
--- python.eclass	11 Oct 2009 13:34:23 -0000	1.77
+++ python.eclass	15 Nov 2009 14:25:55 -0000	1.78
@@ -1,6 +1,6 @@
 # Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.77 2009/10/11 13:34:23 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.78 2009/11/15 14:25:55 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -106,6 +106,10 @@
 	else
 		echo -n "python${slot}"
 	fi
+
+	if [[ "${ABI}" != "${DEFAULT_ABI}" ]]; then
+		echo -n "-${ABI}"
+	fi
 }
 
 unset PYTHON_ABIS
@@ -130,7 +134,7 @@
 
 	# USE_${ABI_TYPE^^} and RESTRICT_${ABI_TYPE^^}_ABIS variables hopefully will be included in EAPI >= 4.
 	if [[ "$(declare -p PYTHON_ABIS 2> /dev/null)" != "declare -x PYTHON_ABIS="* ]] && has "${EAPI:-0}" 0 1 2 3; then
-		local ABI python2_supported_versions python3_supported_versions restricted_ABI support_ABI supported_PYTHON_ABIS=
+		local PYTHON_ABI python2_supported_versions python3_supported_versions restricted_ABI support_ABI supported_PYTHON_ABIS=
 		PYTHON_ABI_SUPPORTED_VALUES="2.4 2.5 2.6 2.7 3.0 3.1 3.2"
 		python2_supported_versions="2.4 2.5 2.6 2.7"
 		python3_supported_versions="3.0 3.1 3.2"
@@ -142,26 +146,26 @@
 				die "USE_PYTHON variable is empty"
 			fi
 
-			for ABI in ${USE_PYTHON}; do
-				if ! has "${ABI}" ${PYTHON_ABI_SUPPORTED_VALUES}; then
-					die "USE_PYTHON variable contains invalid value '${ABI}'"
+			for PYTHON_ABI in ${USE_PYTHON}; do
+				if ! has "${PYTHON_ABI}" ${PYTHON_ABI_SUPPORTED_VALUES}; then
+					die "USE_PYTHON variable contains invalid value '${PYTHON_ABI}'"
 				fi
 
-				if has "${ABI}" ${python2_supported_versions}; then
+				if has "${PYTHON_ABI}" ${python2_supported_versions}; then
 					python2_enabled="1"
 				fi
-				if has "${ABI}" ${python3_supported_versions}; then
+				if has "${PYTHON_ABI}" ${python3_supported_versions}; then
 					python3_enabled="1"
 				fi
 
 				support_ABI="1"
 				for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
-					if [[ "${ABI}" == ${restricted_ABI} ]]; then
+					if [[ "${PYTHON_ABI}" == ${restricted_ABI} ]]; then
 						support_ABI="0"
 						break
 					fi
 				done
-				[[ "${support_ABI}" == "1" ]] && supported_PYTHON_ABIS+=" ${ABI}"
+				[[ "${support_ABI}" == "1" ]] && supported_PYTHON_ABIS+=" ${PYTHON_ABI}"
 			done
 			export PYTHON_ABIS="${supported_PYTHON_ABIS# }"
 
@@ -187,10 +191,10 @@
 
 				python2_version="$(/usr/bin/python2 -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')"
 
-				for ABI in ${python2_supported_versions}; do
+				for PYTHON_ABI in ${python2_supported_versions}; do
 					support_python_major_version="1"
 					for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
-						if [[ "${ABI}" == ${restricted_ABI} ]]; then
+						if [[ "${PYTHON_ABI}" == ${restricted_ABI} ]]; then
 							support_python_major_version="0"
 						fi
 					done
@@ -214,10 +218,10 @@
 
 				python3_version="$(/usr/bin/python3 -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')"
 
-				for ABI in ${python3_supported_versions}; do
+				for PYTHON_ABI in ${python3_supported_versions}; do
 					support_python_major_version="1"
 					for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
-						if [[ "${ABI}" == ${restricted_ABI} ]]; then
+						if [[ "${PYTHON_ABI}" == ${restricted_ABI} ]]; then
 							support_python_major_version="0"
 						fi
 					done
@@ -485,9 +489,9 @@
 				fi
 			elif has "${PYTHON_ABI}" ${FAILURE_TOLERANT_PYTHON_ABIS}; then
 				if [[ "${EBUILD_PHASE}" != "test" ]] || ! has test-fail-continue ${FEATURES}; then
-					local ABI enabled_PYTHON_ABIS=
-					for ABI in ${PYTHON_ABIS}; do
-						[[ "${ABI}" != "${PYTHON_ABI}" ]] && enabled_PYTHON_ABIS+=" ${ABI}"
+					local enabled_PYTHON_ABIS= other_PYTHON_ABI
+					for other_PYTHON_ABI in ${PYTHON_ABIS}; do
+						[[ "${other_PYTHON_ABI}" != "${PYTHON_ABI}" ]] && enabled_PYTHON_ABIS+=" ${other_PYTHON_ABI}"
 					done
 					export PYTHON_ABIS="${enabled_PYTHON_ABIS# }"
 				fi
@@ -595,6 +599,7 @@
 	done
 
 	for file in "${files[@]}"; do
+		file="${file#./}"
 		[[ "${only_executables}" == "1" && ! -x "${file}" ]] && continue
 
 		if [[ "$(head -n1 "${file}")" =~ ^'#!'.*python ]]; then
@@ -722,8 +727,6 @@
 	unset PYTHONDONTWRITEBYTECODE
 }
 
-python_disable_pyc
-
 # @FUNCTION: python_need_rebuild
 # @DESCRIPTION: Run without arguments, specifies that the package should be
 # rebuilt after a python upgrade.
@@ -938,7 +941,7 @@
 
 		if ((${#other_dirs[@]})) || ((${#other_files[@]})); then
 			return_code="0"
-			ebegin "Compilation and optimization of Python modules placed outside of site-packages directories for Python ${PYVER}..."
+			ebegin "Compilation and optimization of Python modules placed outside of site-packages directories for Python ${PYVER}"
 			if ((${#other_dirs[@]})); then
 				python${PYVER} "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" || return_code="1"
 				python${PYVER} -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" &> /dev/null || return_code="1"
@@ -994,7 +997,7 @@
 		# set additional opts
 		myopts+=(-q)
 
-		ebegin "Byte compiling python modules for python-${PYVER} .."
+		ebegin "Compilation and optimization of Python modules for Python ${PYVER}"
 		if ((${#mydirs[@]})); then
 			python${PYVER} \
 				"${myroot}"/usr/$(get_libdir)/python${PYVER}/compileall.py \
@@ -1024,7 +1027,7 @@
 #
 # This function should only be run in pkg_postrm().
 python_mod_cleanup() {
-	local PYTHON_ABI SEARCH_PATH=() root src_py
+	local path py_file PYTHON_ABI SEARCH_PATH=() root
 
 	# Check if phase is pkg_postrm().
 	[[ ${EBUILD_PHASE} != "postrm" ]] && die "${FUNCNAME} should only be run in pkg_postrm()"
@@ -1051,22 +1054,45 @@
 			SEARCH_PATH=("${SEARCH_PATH[@]/#/${root}/}")
 		fi
 	else
-		SEARCH_PATH=("${root}"/usr/lib*/python*/site-packages)
+		local dir sitedir
+		for dir in "${root}"/usr/lib*; do
+			if [[ -d "${dir}" && ! -L "${dir}" ]]; then
+				for sitedir in "${dir}"/python*/site-packages; do
+					if [[ -d "${sitedir}" ]]; then
+						SEARCH_PATH+=("${sitedir}")
+					fi
+				done
+			fi
+		done
+	fi
+
+	local BLUE CYAN NORMAL
+	if [[ "${NOCOLOR:-false}" =~ ^(false|no)$ ]]; then
+		BLUE=$'\e[34m'
+		CYAN=$'\e[36m'
+		NORMAL=$'\e[0m'
+	else
+		BLUE=
+		CYAN=
+		NORMAL=
 	fi
 
 	for path in "${SEARCH_PATH[@]}"; do
-		[[ ! -d "${path}" ]] && continue
-		einfo "Cleaning orphaned Python bytecode from ${path} .."
-		find "${path}" -name '*.py[co]' -print0 | while read -rd ''; do
-			src_py="${REPLY%[co]}"
-			[[ -f "${src_py}" || (! -f "${src_py}c" && ! -f "${src_py}o") ]] && continue
-			einfo "Purging ${src_py}[co]"
-			rm -f "${src_py}"[co]
-		done
+		if [[ -d "${path}" ]]; then
+			find "${path}" -name '*.py[co]' -print0 | while read -rd ''; do
+				py_file="${REPLY%[co]}"
+				[[ -f "${py_file}" || (! -f "${py_file}c" && ! -f "${py_file}o") ]] && continue
+				einfo "${BLUE}<<< ${py_file}[co]${NORMAL}"
+				rm -f "${py_file}"[co]
+			done
 
-		# Attempt to remove directories that may be empty.
-		find "${path}" -type d | sort -r | while read -r dir; do
-			rmdir "${dir}" 2>/dev/null && einfo "Removing empty directory ${dir}"
-		done
+			# Attempt to delete directories, which may be empty.
+			find "${path}" -type d | sort -r | while read -r dir; do
+				rmdir "${dir}" 2>/dev/null && einfo "${CYAN}<<< ${dir}${NORMAL}"
+			done
+		elif [[ "${path}" == *.py && ! -f "${path}" && (-f "${path}c" || -f "${path}o") ]]; then
+			einfo "${BLUE}<<< ${path}[co]${NORMAL}"
+			rm -f "${path}"[co]
+		fi
 	done
 }






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2009-11-15 22:00 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2009-11-15 22:00 UTC (permalink / raw
  To: gentoo-commits

arfrever    09/11/15 22:00:47

  Modified:             python.eclass
  Log:
  Fix support for non-multilib profiles in PYTHON(). Print additional data in validate_PYTHON_ABIS() when EPYTHON variable isn't respected.

Revision  Changes    Path
1.79                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.79&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.79&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.78&r2=1.79

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -r1.78 -r1.79
--- python.eclass	15 Nov 2009 14:25:55 -0000	1.78
+++ python.eclass	15 Nov 2009 22:00:47 -0000	1.79
@@ -1,6 +1,6 @@
 # Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.78 2009/11/15 14:25:55 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.79 2009/11/15 22:00:47 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -107,7 +107,7 @@
 		echo -n "python${slot}"
 	fi
 
-	if [[ "${ABI}" != "${DEFAULT_ABI}" ]]; then
+	if [[ -n "${ABI}" && "${ABI}" != "${DEFAULT_ABI}" && "${DEFAULT_ABI}" != "default" ]]; then
 		echo -n "-${ABI}"
 	fi
 }
@@ -260,6 +260,12 @@
 
 			# Ensure that EPYTHON variable is respected.
 			if [[ "$(EPYTHON="$(PYTHON)" python -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')" != "${PYTHON_ABI}" ]]; then
+				eerror "python:                    '$(type -p python)'"
+				eerror "ABI:                       '${ABI}'"
+				eerror "DEFAULT_ABI:               '${DEFAULT_ABI}'"
+				eerror "EPYTHON:                   '$(PYTHON)'"
+				eerror "PYTHON_ABI:                '${PYTHON_ABI}'"
+				eerror "Version of enabled Python: '$(EPYTHON="$(PYTHON)" python -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')'"
 				die "'python' doesn't respect EPYTHON variable"
 			fi
 		done
@@ -1016,10 +1022,10 @@
 }
 
 # @FUNCTION: python_mod_cleanup
-# @USAGE: [directory]
+# @USAGE: [directory|file]
 # @DESCRIPTION:
-# Run with optional arguments, where arguments are directories of
-# python modules. If none given, it will look in /usr/lib/python[0-9].[0-9].
+# Run with optional arguments, where arguments are Python modules. If none given,
+# it will look in /usr/lib/python[0-9].[0-9].
 #
 # It will recursively scan all compiled Python modules in the directories and
 # determine if they are orphaned (i.e. their corresponding .py files are missing.)






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2009-11-22 13:48 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2009-11-22 13:48 UTC (permalink / raw
  To: gentoo-commits

arfrever    09/11/22 13:48:16

  Modified:             python.eclass
  Log:
  Use brighter colors in python_mod_cleanup() (bug #293966).

Revision  Changes    Path
1.80                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.80&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.80&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.79&r2=1.80

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -r1.79 -r1.80
--- python.eclass	15 Nov 2009 22:00:47 -0000	1.79
+++ python.eclass	22 Nov 2009 13:48:16 -0000	1.80
@@ -1,6 +1,6 @@
 # Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.79 2009/11/15 22:00:47 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.80 2009/11/22 13:48:16 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -1074,8 +1074,8 @@
 
 	local BLUE CYAN NORMAL
 	if [[ "${NOCOLOR:-false}" =~ ^(false|no)$ ]]; then
-		BLUE=$'\e[34m'
-		CYAN=$'\e[36m'
+		BLUE=$'\e[1;34m'
+		CYAN=$'\e[1;36m'
 		NORMAL=$'\e[0m'
 	else
 		BLUE=






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2009-11-22 16:45 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2009-11-22 16:45 UTC (permalink / raw
  To: gentoo-commits

arfrever    09/11/22 16:45:54

  Modified:             python.eclass
  Log:
  Support --source-dir option of python_execute_function().

Revision  Changes    Path
1.81                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.81&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.81&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.80&r2=1.81

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -r1.80 -r1.81
--- python.eclass	22 Nov 2009 13:48:16 -0000	1.80
+++ python.eclass	22 Nov 2009 16:45:54 -0000	1.81
@@ -1,6 +1,6 @@
 # Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.80 2009/11/22 13:48:16 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.81 2009/11/22 16:45:54 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -335,12 +335,12 @@
 }
 
 # @FUNCTION: python_execute_function
-# @USAGE: [--action-message message] [-d|--default-function] [--failure-message message] [--nonfatal] [-q|--quiet] [-s|--separate-build-dirs] [--] <function> [arguments]
+# @USAGE: [--action-message message] [-d|--default-function] [--failure-message message] [--nonfatal] [-q|--quiet] [-s|--separate-build-dirs] [--source-dir source_directory] [--] <function> [arguments]
 # @DESCRIPTION:
 # Execute specified function for each value of PYTHON_ABIS, optionally passing additional
 # arguments. The specified function can use PYTHON_ABI and BUILDDIR variables.
 python_execute_function() {
-	local action action_message action_message_template= default_function="0" failure_message failure_message_template= function nonfatal="0" previous_directory previous_directory_stack previous_directory_stack_length PYTHON_ABI quiet="0" separate_build_dirs="0"
+	local action action_message action_message_template= default_function="0" failure_message failure_message_template= function nonfatal="0" previous_directory previous_directory_stack previous_directory_stack_length PYTHON_ABI quiet="0" separate_build_dirs="0" source_dir=
 
 	while (($#)); do
 		case "$1" in
@@ -364,6 +364,10 @@
 			-s|--separate-build-dirs)
 				separate_build_dirs="1"
 				;;
+			--source-dir)
+				source_dir="$2"
+				shift
+				;;
 			--)
 				break
 				;;
@@ -377,6 +381,10 @@
 		shift
 	done
 
+	if [[ -n "${source_dir}" && "${separate_build_dirs}" == 0 ]]; then
+		die "${FUNCNAME}(): '--source-dir' option can be specified only with '--separate-build-dirs' option"
+	fi
+
 	if [[ "${default_function}" == "0" ]]; then
 		if [[ "$#" -eq "0" ]]; then
 			die "${FUNCNAME}(): Missing function name"
@@ -466,7 +474,11 @@
 		fi
 
 		if [[ "${separate_build_dirs}" == "1" ]]; then
-			export BUILDDIR="${S}-${PYTHON_ABI}"
+			if [[ -n "${source_dir}" ]]; then
+				export BUILDDIR="${S}/${source_dir}-${PYTHON_ABI}"
+			else
+				export BUILDDIR="${S}-${PYTHON_ABI}"
+			fi
 			pushd "${BUILDDIR}" > /dev/null || die "pushd failed"
 		else
 			export BUILDDIR="${S}"






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2009-12-23 23:43 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2009-12-23 23:43 UTC (permalink / raw
  To: gentoo-commits

arfrever    09/12/23 23:43:42

  Modified:             python.eclass
  Log:
  Update EAPI checks. Add support for -2, -3, --only-ABI and --final-ABI options of PYTHON(). Add python_set_active_version(). Add python_generate_wrapper_scripts().

Revision  Changes    Path
1.82                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.82&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.82&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.81&r2=1.82

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -r1.81 -r1.82
--- python.eclass	22 Nov 2009 16:45:54 -0000	1.81
+++ python.eclass	23 Dec 2009 23:43:42 -0000	1.82
@@ -1,6 +1,6 @@
 # Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.81 2009/11/22 16:45:54 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.82 2009/12/23 23:43:42 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -58,29 +58,48 @@
 	[[ -n "${PYVER}" ]] && return 0
 	local tmpstr
 	python=${python:-/usr/bin/python}
-	tmpstr="$(${python} -V 2>&1 )"
+	tmpstr="$(EPYTHON= ${python} -V 2>&1 )"
 	export PYVER_ALL="${tmpstr#Python }"
 	__python_version_extract $PYVER_ALL
 }
 
 # @FUNCTION: PYTHON
-# @USAGE: [-a|--absolute-path] [--] <Python_ABI="${PYTHON_ABI}">
+# @USAGE: [-2] [-3] [-A|--only-ABI] [-a|--absolute-path] [-f|--final-ABI] [--] <Python_ABI="${PYTHON_ABI}">
 # @DESCRIPTION:
 # Get Python interpreter filename for specified Python ABI. If Python_ABI argument
 # is ommitted, then PYTHON_ABI environment variable must be set and is used.
+# If -2 option is specified, then active version of Python 2 is used.
+# If -3 option is specified, then active version of Python 3 is used.
+# If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
+# -2, -3 and --final-ABI options and Python_ABI argument cannot be specified simultaneously.
+# If --only-ABI option is specified, then only specified Python ABI is printed instead of
+# Python interpreter filename.
+# --only-ABI and --absolute-path options cannot be specified simultaneously.
 PYTHON() {
-	local absolute_path="0" slot=
+	local absolute_path="0" final_ABI="0" only_ABI="0" python2="0" python3="0" slot=
 
 	while (($#)); do
 		case "$1" in
+			-2)
+				python2="1"
+				;;
+			-3)
+				python3="1"
+				;;
+			-A|--only-ABI)
+				only_ABI="1"
+				;;
 			-a|--absolute-path)
 				absolute_path="1"
 				;;
+			-f|--final-ABI)
+				final_ABI="1"
+				;;
 			--)
 				break
 				;;
 			-*)
-				die "${FUNCNAME}(): Unrecognized option $1"
+				die "${FUNCNAME}(): Unrecognized option '$1'"
 				;;
 			*)
 				break
@@ -89,19 +108,58 @@
 		shift
 	done
 
+	if [[ "${only_ABI}" == "1" && "${absolute_path}" == "1" ]]; then
+		die "${FUNCNAME}(): '--only-ABI and '--absolute-path' options cannot be specified simultaneously"
+	fi
+
+	if [[ "$((${python2} + ${python3} + ${final_ABI}))" -gt "1" ]]; then
+		die "${FUNCNAME}(): '-2', '-3' or '--final-ABI' options cannot be specified simultaneously"
+	fi
+
 	if [[ "$#" -eq "0" ]]; then
-		if [[ -n "${PYTHON_ABI}" ]]; then
+		if [[ "${final_ABI}" == "1" ]]; then
+			validate_PYTHON_ABIS
+			slot="${PYTHON_ABIS##* }"
+		elif [[ "${python2}" == "1" ]]; then
+			slot="$(eselect python show --python2)"
+			if [[ -z "${slot}" ]]; then
+				die "${FUNCNAME}(): Active Python 2 interpreter not set"
+			elif [[ "${slot}" != "python2."* ]]; then
+				die "${FUNCNAME}(): Internal error in \`eselect python show --python2\`"
+			fi
+			slot="${slot#python}"
+		elif [[ "${python3}" == "1" ]]; then
+			slot="$(eselect python show --python3)"
+			if [[ -z "${slot}" ]]; then
+				die "${FUNCNAME}(): Active Python 3 interpreter not set"
+			elif [[ "${slot}" != "python3."* ]]; then
+				die "${FUNCNAME}(): Internal error in \`eselect python show --python3\`"
+			fi
+			slot="${slot#python}"
+		elif [[ -n "${PYTHON_ABI}" ]]; then
 			slot="${PYTHON_ABI}"
 		else
 			die "${FUNCNAME}(): Invalid usage"
 		fi
 	elif [[ "$#" -eq "1" ]]; then
+		if [[ "${final_ABI}" == "1" ]]; then
+			die "${FUNCNAME}(): '--final-ABI' option and Python ABI cannot be specified simultaneously"
+		fi
+		if [[ "${python2}" == "1" ]]; then
+			die "${FUNCNAME}(): '-2' option and Python ABI cannot be specified simultaneously"
+		fi
+		if [[ "${python3}" == "1" ]]; then
+			die "${FUNCNAME}(): '-3' option and Python ABI cannot be specified simultaneously"
+		fi
 		slot="$1"
 	else
 		die "${FUNCNAME}(): Invalid usage"
 	fi
 
-	if [[ "${absolute_path}" == "1" ]]; then
+	if [[ "${only_ABI}" == "1" ]]; then
+		echo -n "${slot}"
+		return
+	elif [[ "${absolute_path}" == "1" ]]; then
 		echo -n "/usr/bin/python${slot}"
 	else
 		echo -n "python${slot}"
@@ -112,6 +170,40 @@
 	fi
 }
 
+# @FUNCTION: python_set_active_version
+# @USAGE: <Python_ABI|2|3>
+# @DESCRIPTION:
+# Set active version of Python.
+python_set_active_version() {
+	if [[ "$#" -ne "1" ]]; then
+		die "${FUNCNAME}() requires 1 argument"
+	fi
+
+	if [[ "$1" =~ ^[[:digit:]]+\.[[:digit:]]+$ ]]; then
+		if ! has_version "dev-lang/python:$1"; then
+			die "${FUNCNAME}(): 'dev-lang/python:$1' isn't installed"
+		fi
+		export EPYTHON="$(PYTHON "$1")"
+	elif [[ "$1" == "2" ]]; then
+		if ! has_version "=dev-lang/python-2*"; then
+			die "${FUNCNAME}(): '=dev-lang/python-2*' isn't installed"
+		fi
+		export EPYTHON="$(PYTHON -2)"
+	elif [[ "$1" == "3" ]]; then
+		if ! has_version "=dev-lang/python-3*"; then
+			die "${FUNCNAME}(): '=dev-lang/python-3*' isn't installed"
+		fi
+		export EPYTHON="$(PYTHON -3)"
+	else
+		die "${FUNCNAME}(): Unrecognized argument '$1'"
+	fi
+
+	# PYTHON_ABI variable is intended to be used only in ebuilds/eclasses,
+	# so it doesn't need to be exported to subprocesses.
+	PYTHON_ABI="${EPYTHON#python}"
+	PYTHON_ABI="${PYTHON_ABI%%-*}"
+}
+
 unset PYTHON_ABIS
 unset PYTHON_ABIS_SANITY_CHECKS
 
@@ -132,8 +224,8 @@
 		die "'/usr/bin/python-config' isn't valid script"
 	fi
 
-	# USE_${ABI_TYPE^^} and RESTRICT_${ABI_TYPE^^}_ABIS variables hopefully will be included in EAPI >= 4.
-	if [[ "$(declare -p PYTHON_ABIS 2> /dev/null)" != "declare -x PYTHON_ABIS="* ]] && has "${EAPI:-0}" 0 1 2 3; then
+	# USE_${ABI_TYPE^^} and RESTRICT_${ABI_TYPE^^}_ABIS variables hopefully will be included in EAPI >= 5.
+	if [[ "$(declare -p PYTHON_ABIS 2> /dev/null)" != "declare -x PYTHON_ABIS="* ]] && has "${EAPI:-0}" 0 1 2 3 4; then
 		local PYTHON_ABI python2_supported_versions python3_supported_versions restricted_ABI support_ABI supported_PYTHON_ABIS=
 		PYTHON_ABI_SUPPORTED_VALUES="2.4 2.5 2.6 2.7 3.0 3.1 3.2"
 		python2_supported_versions="2.4 2.5 2.6 2.7"
@@ -165,9 +257,8 @@
 						break
 					fi
 				done
-				[[ "${support_ABI}" == "1" ]] && supported_PYTHON_ABIS+=" ${PYTHON_ABI}"
+				[[ "${support_ABI}" == "1" ]] && export PYTHON_ABIS+="${PYTHON_ABIS:+ }${PYTHON_ABI}"
 			done
-			export PYTHON_ABIS="${supported_PYTHON_ABIS# }"
 
 			if [[ -z "${PYTHON_ABIS//[${IFS}]/}" ]]; then
 				die "USE_PYTHON variable doesn't enable any version of Python supported by ${CATEGORY}/${PF}"
@@ -238,8 +329,13 @@
 				fi
 			fi
 
-			if ! has "${python_version}" "${python2_version}" "${python3_version}"; then
-				eerror "Python wrapper is configured incorrectly or /usr/bin/python2 or /usr/bin/python3 symlink"
+			if [[ -n "${python2_version}" && "${python_version}" == "2."* && "${python_version}" != "${python2_version}" ]]; then
+				eerror "Python wrapper is configured incorrectly or /usr/bin/python2 symlink"
+				eerror "is set incorrectly. Use \`eselect python\` to fix configuration."
+				die "Incorrect configuration of Python"
+			fi
+			if [[ -n "${python3_version}" && "${python_version}" == "3."* && "${python_version}" != "${python3_version}" ]]; then
+				eerror "Python wrapper is configured incorrectly or /usr/bin/python3 symlink"
 				eerror "is set incorrectly. Use \`eselect python\` to fix configuration."
 				die "Incorrect configuration of Python"
 			fi
@@ -253,7 +349,7 @@
 	if [[ "$(declare -p PYTHON_ABIS_SANITY_CHECKS 2> /dev/null)" != "declare -- PYTHON_ABIS_SANITY_CHECKS="* ]]; then
 		local PYTHON_ABI
 		for PYTHON_ABI in ${PYTHON_ABIS}; do
-			# Ensure that appropriate Python version is installed.
+			# Ensure that appropriate version of Python is installed.
 			if ! has_version "dev-lang/python:${PYTHON_ABI}"; then
 				die "dev-lang/python:${PYTHON_ABI} isn't installed"
 			fi
@@ -404,7 +500,7 @@
 		fi
 
 		if [[ "${EBUILD_PHASE}" == "configure" ]]; then
-			if has "${EAPI}" 2; then
+			if has "${EAPI}" 2 3; then
 				python_default_function() {
 					econf
 				}
@@ -430,7 +526,7 @@
 				emake DESTDIR="${D}" install
 			}
 		else
-			die "${FUNCNAME}(): --default-function option cannot be used in this ebuild phase"
+			die "${FUNCNAME}(): '--default-function' option cannot be used in this ebuild phase"
 		fi
 		function="python_default_function"
 	fi
@@ -488,7 +584,7 @@
 		previous_directory_stack="$(dirs -p)"
 		previous_directory_stack_length="$(dirs -p | wc -l)"
 
-		if ! has "${EAPI}" 0 1 2 && has "${PYTHON_ABI}" ${FAILURE_TOLERANT_PYTHON_ABIS}; then
+		if ! has "${EAPI}" 0 1 2 3 && has "${PYTHON_ABI}" ${FAILURE_TOLERANT_PYTHON_ABIS}; then
 			EPYTHON="$(PYTHON)" nonfatal "${function}" "$@"
 		else
 			EPYTHON="$(PYTHON)" "${function}" "$@"
@@ -509,9 +605,9 @@
 				if [[ "${EBUILD_PHASE}" != "test" ]] || ! has test-fail-continue ${FEATURES}; then
 					local enabled_PYTHON_ABIS= other_PYTHON_ABI
 					for other_PYTHON_ABI in ${PYTHON_ABIS}; do
-						[[ "${other_PYTHON_ABI}" != "${PYTHON_ABI}" ]] && enabled_PYTHON_ABIS+=" ${other_PYTHON_ABI}"
+						[[ "${other_PYTHON_ABI}" != "${PYTHON_ABI}" ]] && enabled_PYTHON_ABIS+="${enabled_PYTHON_ABIS:+ }${other_PYTHON_ABI}"
 					done
-					export PYTHON_ABIS="${enabled_PYTHON_ABIS# }"
+					export PYTHON_ABIS="${enabled_PYTHON_ABIS}"
 				fi
 				if [[ "${quiet}" == "0" ]]; then
 					ewarn "${RED}${failure_message}${NORMAL}"
@@ -621,7 +717,9 @@
 		[[ "${only_executables}" == "1" && ! -x "${file}" ]] && continue
 
 		if [[ "$(head -n1 "${file}")" =~ ^'#!'.*python ]]; then
-			[[ "${quiet}" == "0" ]] && einfo "Converting shebang in '${file}'"
+			if [[ "${quiet}" == "0" ]]; then
+				einfo "Converting shebang in '${file}'"
+			fi
 			sed -e "1s/python\([[:digit:]]\+\(\.[[:digit:]]\+\)\?\)\?/python${python_version}/" -i "${file}" || die "Conversion of shebang in '${file}' failed"
 
 			# Delete potential whitespace after "#!".
@@ -630,6 +728,167 @@
 	done
 }
 
+# @FUNCTION: python_generate_wrapper_scripts
+# @USAGE: [-E|--respect-EPYTHON] [-f|--force] [-q|--quiet] [--] <file> [files]
+# @DESCRIPTION:
+# Generate wrapper scripts. Existing files are overwritten only with --force option.
+# If --respect-EPYTHON option is specified, then generated wrapper scripts will
+# respect EPYTHON variable at run time.
+python_generate_wrapper_scripts() {
+	local eselect_python_option file force="0" quiet="0" PYTHON_ABI python2_enabled="0" python2_supported_versions python3_enabled="0" python3_supported_versions respect_EPYTHON="0"
+	python2_supported_versions="2.4 2.5 2.6 2.7"
+	python3_supported_versions="3.0 3.1 3.2"
+
+	while (($#)); do
+		case "$1" in
+			-E|--respect-EPYTHON)
+				respect_EPYTHON="1"
+				;;
+			-f|--force)
+				force="1"
+				;;
+			-q|--quiet)
+				quiet="1"
+				;;
+			--)
+				break
+				;;
+			-*)
+				die "${FUNCNAME}(): Unrecognized option '$1'"
+				;;
+			*)
+				break
+				;;
+		esac
+		shift
+	done
+
+	if [[ "$#" -eq 0 ]]; then
+		die "${FUNCNAME}(): Missing arguments"
+	fi
+
+	validate_PYTHON_ABIS
+	for PYTHON_ABI in ${python2_supported_versions}; do
+		if has "${PYTHON_ABI}" ${PYTHON_ABIS}; then
+			python2_enabled="1"
+		fi
+	done
+	for PYTHON_ABI in ${python3_supported_versions}; do
+		if has "${PYTHON_ABI}" ${PYTHON_ABIS}; then
+			python3_enabled="1"
+		fi
+	done
+
+	if [[ "${python2_enabled}" == "1" && "${python3_enabled}" == "1" ]]; then
+		eselect_python_option=
+	elif [[ "${python2_enabled}" == "1" && "${python3_enabled}" == "0" ]]; then
+		eselect_python_option="--python2"
+	elif [[ "${python2_enabled}" == "0" && "${python3_enabled}" == "1" ]]; then
+		eselect_python_option="--python3"
+	else
+		die "${FUNCNAME}(): Unsupported environment"
+	fi
+
+	for file in "$@"; do
+		if [[ -f "${file}" && "${force}" == "0" ]]; then
+			die "${FUNCNAME}(): '$1' already exists"
+		fi
+
+		if [[ "${quiet}" == "0" ]]; then
+			einfo "Generating '${file#${D%/}}' wrapper script"
+		fi
+
+		cat << EOF > "${file}"
+#!/usr/bin/env python
+# Gentoo '${file##*/}' wrapper script
+
+import os
+import re
+import subprocess
+import sys
+
+EPYTHON_re = re.compile(r"^python(\d+\.\d+)$")
+
+EOF
+		if [[ "$?" != "0" ]]; then
+			die "${FUNCNAME}(): Generation of '$1' failed"
+		fi
+		if [[ "${respect_EPYTHON}" == "1" ]]; then
+			cat << EOF >> "${file}"
+EPYTHON = os.environ.get("EPYTHON")
+if EPYTHON:
+	EPYTHON_matched = EPYTHON_re.match(EPYTHON)
+	if EPYTHON_matched:
+		PYTHON_ABI = EPYTHON_matched.group(1)
+	else:
+		sys.stderr.write("EPYTHON variable has unrecognized value '%s'\n" % EPYTHON)
+		sys.exit(1)
+else:
+	try:
+		eselect_process = subprocess.Popen(["/usr/bin/eselect", "python", "show"${eselect_python_option:+, $(echo "\"")}${eselect_python_option}${eselect_python_option:+$(echo "\"")}], stdout=subprocess.PIPE)
+		if eselect_process.wait() != 0:
+			raise ValueError
+	except (OSError, ValueError):
+		sys.stderr.write("Execution of 'eselect python show${eselect_python_option:+ }${eselect_python_option}' failed\n")
+		sys.exit(1)
+
+	eselect_output = eselect_process.stdout.read()
+	if not isinstance(eselect_output, str):
+		# Python 3
+		eselect_output = eselect_output.decode()
+
+	EPYTHON_matched = EPYTHON_re.match(eselect_output)
+	if EPYTHON_matched:
+		PYTHON_ABI = EPYTHON_matched.group(1)
+	else:
+		sys.stderr.write("'eselect python show${eselect_python_option:+ }${eselect_python_option}' printed unrecognized value '%s" % eselect_output)
+		sys.exit(1)
+EOF
+			if [[ "$?" != "0" ]]; then
+				die "${FUNCNAME}(): Generation of '$1' failed"
+			fi
+		else
+			cat << EOF >> "${file}"
+try:
+	eselect_process = subprocess.Popen(["/usr/bin/eselect", "python", "show"${eselect_python_option:+, $(echo "\"")}${eselect_python_option}${eselect_python_option:+$(echo "\"")}], stdout=subprocess.PIPE)
+	if eselect_process.wait() != 0:
+		raise ValueError
+except (OSError, ValueError):
+	sys.stderr.write("Execution of 'eselect python show${eselect_python_option:+ }${eselect_python_option}' failed\n")
+	sys.exit(1)
+
+eselect_output = eselect_process.stdout.read()
+if not isinstance(eselect_output, str):
+	# Python 3
+	eselect_output = eselect_output.decode()
+
+EPYTHON_matched = EPYTHON_re.match(eselect_output)
+if EPYTHON_matched:
+	PYTHON_ABI = EPYTHON_matched.group(1)
+else:
+	sys.stderr.write("'eselect python show${eselect_python_option:+ }${eselect_python_option}' printed unrecognized value '%s" % eselect_output)
+	sys.exit(1)
+EOF
+			if [[ "$?" != "0" ]]; then
+				die "${FUNCNAME}(): Generation of '$1' failed"
+			fi
+		fi
+		cat << EOF >> "${file}"
+
+target_executable = "%s-%s" % (sys.argv[0], PYTHON_ABI)
+if not os.path.exists(target_executable):
+	sys.stderr.write("'%s' does not exist\n" % target_executable)
+	sys.exit(1)
+
+os.execv(target_executable, sys.argv)
+EOF
+		if [[ "$?" != "0" ]]; then
+			die "${FUNCNAME}(): Generation of '$1' failed"
+		fi
+		fperms +x "${file#${D%/}}" || die "fperms '${file}' failed"
+	done
+}
+
 # @ECLASS-VARIABLE: PYTHON_USE_WITH
 # @DESCRIPTION:
 # Set this to a space separated list of use flags
@@ -835,9 +1094,8 @@
 	[[ ${EBUILD_PHASE} != postinst ]] &&\
 		die "${FUNCNAME} should only be run in pkg_postinst()"
 
-	# allow compiling for older python versions
-	if [[ "${PYTHON_OVERRIDE_PYVER}" ]]; then
-		PYVER=${PYTHON_OVERRIDE_PYVER}
+	if [[ -n "${PYTHON_ABI}" ]]; then
+		PYVER="${PYTHON_ABI}"
 	else
 		python_version
 	fi
@@ -1005,9 +1263,8 @@
 			shift
 		done
 
-		# allow compiling for older python versions
-		if [ -n "${PYTHON_OVERRIDE_PYVER}" ]; then
-			PYVER=${PYTHON_OVERRIDE_PYVER}
+		if [[ -n "${PYTHON_ABI}" ]]; then
+			PYVER="${PYTHON_ABI}"
 		else
 			python_version
 		fi






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2010-01-10 17:03 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2010-01-10 17:03 UTC (permalink / raw
  To: gentoo-commits

arfrever    10/01/10 17:03:08

  Modified:             python.eclass
  Log:
  Ensure that python.eclass cannot be used with EAPIs, in which API of python.eclass has not been yet established.
  >=app-shells/bash-3.2 is now required by PMS, so DEPEND does not need to explicitly specify it.
  Add support for -A / --active option of PYTHON(). Rename --only-ABI option to --ABI.
  Print more detailed error messages in validate_PYTHON_ABIS() (bug #298107).
  Support symlinks to wrapper scripts generated by python_generate_wrapper_scripts().
  Do not use python_version(). Use $(PYTHON -A) / $(PYTHON -A --ABI) instead of ${PYVER}.
  Fix python_mod_optimize() and python_mod_cleanup() for packages not supporting installation for multiple versions of Python in EAPI >=3.

Revision  Changes    Path
1.83                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.83&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.83&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.82&r2=1.83

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -r1.82 -r1.83
--- python.eclass	23 Dec 2009 23:43:42 -0000	1.82
+++ python.eclass	10 Jan 2010 17:03:08 -0000	1.83
@@ -1,6 +1,6 @@
-# Copyright 1999-2009 Gentoo Foundation
+# Copyright 1999-2010 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.82 2009/12/23 23:43:42 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.83 2010/01/10 17:03:08 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -11,6 +11,10 @@
 
 inherit multilib
 
+if ! has "${EAPI:-0}" 0 1 2; then
+	die "API of python.eclass in EAPI=\"${EAPI}\" not established"
+fi
+
 if [[ -n "${NEED_PYTHON}" ]]; then
 	PYTHON_ATOM=">=dev-lang/python-${NEED_PYTHON}"
 	DEPEND="${PYTHON_ATOM}"
@@ -19,8 +23,7 @@
 	PYTHON_ATOM="dev-lang/python"
 fi
 
-DEPEND+=" >=app-admin/eselect-python-20090804
-	>=app-shells/bash-3.2"
+DEPEND+=" >=app-admin/eselect-python-20090804"
 
 __python_eclass_test() {
 	__python_version_extract 2.3
@@ -64,19 +67,21 @@
 }
 
 # @FUNCTION: PYTHON
-# @USAGE: [-2] [-3] [-A|--only-ABI] [-a|--absolute-path] [-f|--final-ABI] [--] <Python_ABI="${PYTHON_ABI}">
+# @USAGE: [-2] [-3] [--ABI] [-A|--active] [-a|--absolute-path] [-f|--final-ABI] [--] <Python_ABI="${PYTHON_ABI}">
 # @DESCRIPTION:
 # Get Python interpreter filename for specified Python ABI. If Python_ABI argument
 # is ommitted, then PYTHON_ABI environment variable must be set and is used.
 # If -2 option is specified, then active version of Python 2 is used.
 # If -3 option is specified, then active version of Python 3 is used.
+# If --active option is specified, then active version of Python is used.
+# Active version of Python can be set by python_set_active_version().
 # If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
-# -2, -3 and --final-ABI options and Python_ABI argument cannot be specified simultaneously.
-# If --only-ABI option is specified, then only specified Python ABI is printed instead of
+# -2, -3, --active and --final-ABI options and Python_ABI argument cannot be specified simultaneously.
+# If --ABI option is specified, then only specified Python ABI is printed instead of
 # Python interpreter filename.
-# --only-ABI and --absolute-path options cannot be specified simultaneously.
+# --ABI and --absolute-path options cannot be specified simultaneously.
 PYTHON() {
-	local absolute_path="0" final_ABI="0" only_ABI="0" python2="0" python3="0" slot=
+	local ABI_output="0" absolute_path_output="0" active="0" final_ABI="0" python2="0" python3="0" slot=
 
 	while (($#)); do
 		case "$1" in
@@ -86,11 +91,14 @@
 			-3)
 				python3="1"
 				;;
-			-A|--only-ABI)
-				only_ABI="1"
+			--ABI)
+				ABI_output="1"
+				;;
+			-A|--active)
+				active="1"
 				;;
 			-a|--absolute-path)
-				absolute_path="1"
+				absolute_path_output="1"
 				;;
 			-f|--final-ABI)
 				final_ABI="1"
@@ -108,16 +116,21 @@
 		shift
 	done
 
-	if [[ "${only_ABI}" == "1" && "${absolute_path}" == "1" ]]; then
-		die "${FUNCNAME}(): '--only-ABI and '--absolute-path' options cannot be specified simultaneously"
+	if [[ "${ABI_output}" == "1" && "${absolute_path_output}" == "1" ]]; then
+		die "${FUNCNAME}(): '--ABI and '--absolute-path' options cannot be specified simultaneously"
 	fi
 
-	if [[ "$((${python2} + ${python3} + ${final_ABI}))" -gt "1" ]]; then
-		die "${FUNCNAME}(): '-2', '-3' or '--final-ABI' options cannot be specified simultaneously"
+	if [[ "$((${python2} + ${python3} + ${active} + ${final_ABI}))" -gt 1 ]]; then
+		die "${FUNCNAME}(): '-2', '-3', '--active' or '--final-ABI' options cannot be specified simultaneously"
 	fi
 
-	if [[ "$#" -eq "0" ]]; then
-		if [[ "${final_ABI}" == "1" ]]; then
+	if [[ "$#" -eq 0 ]]; then
+		if [[ "${active}" == "1" ]]; then
+			if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
+				die "${FUNCNAME}(): '--active' option cannot be used in ebuilds of packages supporting installation for multiple versions of Python"
+			fi
+			slot="$(/usr/bin/python -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')"
+		elif [[ "${final_ABI}" == "1" ]]; then
 			validate_PYTHON_ABIS
 			slot="${PYTHON_ABIS##* }"
 		elif [[ "${python2}" == "1" ]]; then
@@ -141,7 +154,10 @@
 		else
 			die "${FUNCNAME}(): Invalid usage"
 		fi
-	elif [[ "$#" -eq "1" ]]; then
+	elif [[ "$#" -eq 1 ]]; then
+		if [[ "${active}" == "1" ]]; then
+			die "${FUNCNAME}(): '--active' option and Python ABI cannot be specified simultaneously"
+		fi
 		if [[ "${final_ABI}" == "1" ]]; then
 			die "${FUNCNAME}(): '--final-ABI' option and Python ABI cannot be specified simultaneously"
 		fi
@@ -156,10 +172,10 @@
 		die "${FUNCNAME}(): Invalid usage"
 	fi
 
-	if [[ "${only_ABI}" == "1" ]]; then
+	if [[ "${ABI_output}" == "1" ]]; then
 		echo -n "${slot}"
 		return
-	elif [[ "${absolute_path}" == "1" ]]; then
+	elif [[ "${absolute_path_output}" == "1" ]]; then
 		echo -n "/usr/bin/python${slot}"
 	else
 		echo -n "python${slot}"
@@ -218,10 +234,14 @@
 
 	# Ensure that /usr/bin/python and /usr/bin/python-config are valid.
 	if [[ "$(readlink /usr/bin/python)" != "python-wrapper" ]]; then
-		die "'/usr/bin/python' isn't valid symlink"
+		eerror "'/usr/bin/python' is not valid symlink."
+		eerror "Use \`eselect python set \${python_interpreter}\` to fix this problem."
+		die "'/usr/bin/python' is not valid symlink"
 	fi
 	if [[ "$(</usr/bin/python-config)" != *"Gentoo python-config wrapper script"* ]]; then
-		die "'/usr/bin/python-config' isn't valid script"
+		eerror "'/usr/bin/python-config' is not valid script"
+		eerror "Use \`eselect python set \${python_interpreter}\` to fix this problem."
+		die "'/usr/bin/python-config' is not valid script"
 	fi
 
 	# USE_${ABI_TYPE^^} and RESTRICT_${ABI_TYPE^^}_ABIS variables hopefully will be included in EAPI >= 5.
@@ -394,7 +414,7 @@
 		shift
 	done
 
-	if [[ "$#" -eq "0" ]]; then
+	if [[ "$#" -eq 0 ]]; then
 		if [[ "${WORKDIR}" == "${S}" ]]; then
 			die "${FUNCNAME}() cannot be used"
 		fi
@@ -482,7 +502,7 @@
 	fi
 
 	if [[ "${default_function}" == "0" ]]; then
-		if [[ "$#" -eq "0" ]]; then
+		if [[ "$#" -eq 0 ]]; then
 			die "${FUNCNAME}(): Missing function name"
 		fi
 		function="$1"
@@ -875,7 +895,8 @@
 		fi
 		cat << EOF >> "${file}"
 
-target_executable = "%s-%s" % (sys.argv[0], PYTHON_ABI)
+os.environ["PYTHON_PROCESS_NAME"] = sys.argv[0]
+target_executable = "%s-%s" % (os.path.realpath(sys.argv[0]), PYTHON_ABI)
 if not os.path.exists(target_executable):
 	sys.stderr.write("'%s' does not exist\n" % target_executable)
 	sys.exit(1)
@@ -923,8 +944,7 @@
 			if [[ -n "${PYTHON_ABI}" ]]; then
 				pyatom="dev-lang/python:${PYTHON_ABI}"
 			else
-				python_version
-				pyatom="dev-lang/python:${PYVER}"
+				pyatom="dev-lang/python:$(PYTHON -A --ABI)"
 			fi
 
 			for use in ${PYTHON_USE_WITH}; do
@@ -1008,8 +1028,7 @@
 # @DESCRIPTION: Run without arguments, specifies that the package should be
 # rebuilt after a python upgrade.
 python_need_rebuild() {
-	python_version
-	export PYTHON_NEED_REBUILD=${PYVER}
+	export PYTHON_NEED_REBUILD="$(PYTHON -A --ABI)"
 }
 
 # @FUNCTION: python_get_includedir
@@ -1019,8 +1038,7 @@
 	if [[ -n "${PYTHON_ABI}" ]]; then
 		echo "/usr/include/python${PYTHON_ABI}"
 	else
-		python_version
-		echo "/usr/include/python${PYVER}"
+		echo "/usr/include/python$(PYTHON -A --ABI)"
 	fi
 }
 
@@ -1031,8 +1049,7 @@
 	if [[ -n "${PYTHON_ABI}" ]]; then
 		echo "/usr/$(get_libdir)/python${PYTHON_ABI}"
 	else
-		python_version
-		echo "/usr/$(get_libdir)/python${PYVER}"
+		echo "/usr/$(get_libdir)/python$(PYTHON -A --ABI)"
 	fi
 }
 
@@ -1094,12 +1111,6 @@
 	[[ ${EBUILD_PHASE} != postinst ]] &&\
 		die "${FUNCNAME} should only be run in pkg_postinst()"
 
-	if [[ -n "${PYTHON_ABI}" ]]; then
-		PYVER="${PYTHON_ABI}"
-	else
-		python_version
-	fi
-
 	# strip trailing slash
 	myroot="${ROOT%/}"
 
@@ -1109,8 +1120,8 @@
 	done
 
 	if ((${#myfiles[@]})); then
-		python${PYVER} ${myroot}/usr/$(get_libdir)/python${PYVER}/py_compile.py "${myfiles[@]}"
-		python${PYVER} -O ${myroot}/usr/$(get_libdir)/python${PYVER}/py_compile.py "${myfiles[@]}" &> /dev/null
+		"$(PYTHON -A)" "${myroot}$(python_get_libdir)/py_compile.py" "${myfiles[@]}"
+		"$(PYTHON -A)" -O "${myroot}$(python_get_libdir)/py_compile.py" "${myfiles[@]}" &> /dev/null
 	else
 		ewarn "No files to compile!"
 	fi
@@ -1167,7 +1178,7 @@
 							ewarn "'${root}/$1' doesn't exist!"
 						fi
 					else
-						for PYTHON_ABI in ${PYTHON_ABIS}; do
+						for PYTHON_ABI in ${PYTHON_ABIS-${PYTHON_ABI-$(PYTHON -A --ABI)}}; do
 							if [[ -d "${root}$(python_get_sitedir)/$1" ]]; then
 								site_packages_dirs+=("$1")
 								break
@@ -1189,7 +1200,7 @@
 		# Set additional options.
 		options+=("-q")
 
-		for PYTHON_ABI in ${PYTHON_ABIS}; do
+		for PYTHON_ABI in ${PYTHON_ABIS-${PYTHON_ABI-$(PYTHON -A --ABI)}}; do
 			if ((${#site_packages_dirs[@]})) || ((${#site_packages_files[@]})); then
 				return_code="0"
 				ebegin "Compilation and optimization of Python modules for Python ${PYTHON_ABI}"
@@ -1217,14 +1228,14 @@
 
 		if ((${#other_dirs[@]})) || ((${#other_files[@]})); then
 			return_code="0"
-			ebegin "Compilation and optimization of Python modules placed outside of site-packages directories for Python ${PYVER}"
+			ebegin "Compilation and optimization of Python modules placed outside of site-packages directories for Python $(PYTHON -A --ABI)"
 			if ((${#other_dirs[@]})); then
-				python${PYVER} "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" || return_code="1"
-				python${PYVER} -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" &> /dev/null || return_code="1"
+				"$(PYTHON -A)" "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" || return_code="1"
+				"$(PYTHON -A)" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" &> /dev/null || return_code="1"
 			fi
 			if ((${#other_files[@]})); then
-				python${PYVER} "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" || return_code="1"
-				python${PYVER} -O "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" &> /dev/null || return_code="1"
+				"$(PYTHON -A)" "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" || return_code="1"
+				"$(PYTHON -A)" -O "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" &> /dev/null || return_code="1"
 			fi
 			eend "${return_code}"
 		fi
@@ -1263,23 +1274,13 @@
 			shift
 		done
 
-		if [[ -n "${PYTHON_ABI}" ]]; then
-			PYVER="${PYTHON_ABI}"
-		else
-			python_version
-		fi
-
 		# set additional opts
 		myopts+=(-q)
 
-		ebegin "Compilation and optimization of Python modules for Python ${PYVER}"
+		ebegin "Compilation and optimization of Python modules for Python $(PYTHON -A --ABI)"
 		if ((${#mydirs[@]})); then
-			python${PYVER} \
-				"${myroot}"/usr/$(get_libdir)/python${PYVER}/compileall.py \
-				"${myopts[@]}" "${mydirs[@]}" || return_code="1"
-			python${PYVER} -O \
-				"${myroot}"/usr/$(get_libdir)/python${PYVER}/compileall.py \
-				"${myopts[@]}" "${mydirs[@]}" &> /dev/null || return_code="1"
+			"$(PYTHON -A)" "${myroot}$(python_get_libdir)/compileall.py" "${myopts[@]}" "${mydirs[@]}" || return_code="1"
+			"$(PYTHON -A)" -O "${myroot}$(python_get_libdir)/compileall.py" "${myopts[@]}" "${mydirs[@]}" &> /dev/null || return_code="1"
 		fi
 
 		if ((${#myfiles[@]})); then
@@ -1318,7 +1319,7 @@
 				elif [[ "$1" =~ ^/ ]]; then
 					SEARCH_PATH+=("${root}/${1#/}")
 				else
-					for PYTHON_ABI in ${PYTHON_ABIS}; do
+					for PYTHON_ABI in ${PYTHON_ABIS-${PYTHON_ABI-$(PYTHON -A --ABI)}}; do
 						SEARCH_PATH+=("${root}$(python_get_sitedir)/$1")
 					done
 				fi






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2010-01-11 16:07 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2010-01-11 16:07 UTC (permalink / raw
  To: gentoo-commits

arfrever    10/01/11 16:07:24

  Modified:             python.eclass
  Log:
  Disable has_version() checks for Python implementations (bug #300579).
  Improve some messages.

Revision  Changes    Path
1.84                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.84&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.84&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.83&r2=1.84

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -r1.83 -r1.84
--- python.eclass	10 Jan 2010 17:03:08 -0000	1.83
+++ python.eclass	11 Jan 2010 16:07:23 -0000	1.84
@@ -1,6 +1,6 @@
 # Copyright 1999-2010 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.83 2010/01/10 17:03:08 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.84 2010/01/11 16:07:23 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -186,6 +186,14 @@
 	fi
 }
 
+_python_implementation() {
+	if [[ "${CATEGORY}/${PN}" == "dev-lang/python" ]]; then
+		return 0
+	else
+		return 1
+	fi
+}
+
 # @FUNCTION: python_set_active_version
 # @USAGE: <Python_ABI|2|3>
 # @DESCRIPTION:
@@ -196,18 +204,18 @@
 	fi
 
 	if [[ "$1" =~ ^[[:digit:]]+\.[[:digit:]]+$ ]]; then
-		if ! has_version "dev-lang/python:$1"; then
-			die "${FUNCNAME}(): 'dev-lang/python:$1' isn't installed"
+		if ! _python_implementation && ! has_version "dev-lang/python:$1"; then
+			die "${FUNCNAME}(): 'dev-lang/python:$1' is not installed"
 		fi
 		export EPYTHON="$(PYTHON "$1")"
 	elif [[ "$1" == "2" ]]; then
-		if ! has_version "=dev-lang/python-2*"; then
-			die "${FUNCNAME}(): '=dev-lang/python-2*' isn't installed"
+		if ! _python_implementation && ! has_version "=dev-lang/python-2*"; then
+			die "${FUNCNAME}(): '=dev-lang/python-2*' is not installed"
 		fi
 		export EPYTHON="$(PYTHON -2)"
 	elif [[ "$1" == "3" ]]; then
-		if ! has_version "=dev-lang/python-3*"; then
-			die "${FUNCNAME}(): '=dev-lang/python-3*' isn't installed"
+		if ! _python_implementation && ! has_version "=dev-lang/python-3*"; then
+			die "${FUNCNAME}(): '=dev-lang/python-3*' is not installed"
 		fi
 		export EPYTHON="$(PYTHON -3)"
 	else
@@ -215,7 +223,7 @@
 	fi
 
 	# PYTHON_ABI variable is intended to be used only in ebuilds/eclasses,
-	# so it doesn't need to be exported to subprocesses.
+	# so it does not need to be exported to subprocesses.
 	PYTHON_ABI="${EPYTHON#python}"
 	PYTHON_ABI="${PYTHON_ABI%%-*}"
 }
@@ -281,14 +289,14 @@
 			done
 
 			if [[ -z "${PYTHON_ABIS//[${IFS}]/}" ]]; then
-				die "USE_PYTHON variable doesn't enable any version of Python supported by ${CATEGORY}/${PF}"
+				die "USE_PYTHON variable does not enable any version of Python supported by ${CATEGORY}/${PF}"
 			fi
 
 			if [[ "${python2_enabled}" == "0" ]]; then
-				ewarn "USE_PYTHON variable doesn't enable any version of Python 2. This configuration is unsupported."
+				ewarn "USE_PYTHON variable does not enable any version of Python 2. This configuration is unsupported."
 			fi
 			if [[ "${python3_enabled}" == "0" ]]; then
-				ewarn "USE_PYTHON variable doesn't enable any version of Python 3. This configuration is unsupported."
+				ewarn "USE_PYTHON variable does not enable any version of Python 3. This configuration is unsupported."
 			fi
 		else
 			local python_version python2_version= python3_version= support_python_major_version
@@ -297,7 +305,7 @@
 
 			if has_version "=dev-lang/python-2*"; then
 				if [[ "$(readlink /usr/bin/python2)" != "python2."* ]]; then
-					die "'/usr/bin/python2' isn't valid symlink"
+					die "'/usr/bin/python2' is not valid symlink"
 				fi
 
 				python2_version="$(/usr/bin/python2 -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')"
@@ -314,7 +322,7 @@
 				if [[ "${support_python_major_version}" == "1" ]]; then
 					for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
 						if [[ "${python2_version}" == ${restricted_ABI} ]]; then
-							die "Active version of Python 2 isn't supported by ${CATEGORY}/${PF}"
+							die "Active version of Python 2 is not supported by ${CATEGORY}/${PF}"
 						fi
 					done
 				else
@@ -324,7 +332,7 @@
 
 			if has_version "=dev-lang/python-3*"; then
 				if [[ "$(readlink /usr/bin/python3)" != "python3."* ]]; then
-					die "'/usr/bin/python3' isn't valid symlink"
+					die "'/usr/bin/python3' is not valid symlink"
 				fi
 
 				python3_version="$(/usr/bin/python3 -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')"
@@ -341,7 +349,7 @@
 				if [[ "${support_python_major_version}" == "1" ]]; then
 					for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
 						if [[ "${python3_version}" == ${restricted_ABI} ]]; then
-							die "Active version of Python 3 isn't supported by ${CATEGORY}/${PF}"
+							die "Active version of Python 3 is not supported by ${CATEGORY}/${PF}"
 						fi
 					done
 				else
@@ -366,12 +374,12 @@
 		fi
 	fi
 
-	if [[ "$(declare -p PYTHON_ABIS_SANITY_CHECKS 2> /dev/null)" != "declare -- PYTHON_ABIS_SANITY_CHECKS="* ]]; then
+	if ! _python_implementation && [[ "$(declare -p PYTHON_ABIS_SANITY_CHECKS 2> /dev/null)" != "declare -- PYTHON_ABIS_SANITY_CHECKS="* ]]; then
 		local PYTHON_ABI
 		for PYTHON_ABI in ${PYTHON_ABIS}; do
 			# Ensure that appropriate version of Python is installed.
 			if ! has_version "dev-lang/python:${PYTHON_ABI}"; then
-				die "dev-lang/python:${PYTHON_ABI} isn't installed"
+				die "dev-lang/python:${PYTHON_ABI} is not installed"
 			fi
 
 			# Ensure that EPYTHON variable is respected.
@@ -382,7 +390,7 @@
 				eerror "EPYTHON:                   '$(PYTHON)'"
 				eerror "PYTHON_ABI:                '${PYTHON_ABI}'"
 				eerror "Version of enabled Python: '$(EPYTHON="$(PYTHON)" python -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')'"
-				die "'python' doesn't respect EPYTHON variable"
+				die "'python' does not respect EPYTHON variable"
 			fi
 		done
 		PYTHON_ABIS_SANITY_CHECKS="1"
@@ -445,7 +453,7 @@
 	[[ -z "${PYTHON_ABI}" ]] && die "PYTHON_ABI variable not set"
 	[[ -z "${dir}" ]] && dir="build"
 
-	# Don't delete preexistent directories.
+	# Do not delete preexistent directories.
 	rm -f "${dir}" || die "Deletion of '${dir}' failed"
 	ln -s "${dir}-${PYTHON_ABI}" "${dir}" || die "Creation of '${dir}' directory symlink failed"
 }
@@ -509,7 +517,7 @@
 		shift
 
 		if [[ -z "$(type -t "${function}")" ]]; then
-			die "${FUNCNAME}(): '${function}' function isn't defined"
+			die "${FUNCNAME}(): '${function}' function is not defined"
 		fi
 	else
 		if [[ "$#" -ne "0" ]]; then
@@ -640,7 +648,7 @@
 			fi
 		fi
 
-		# Ensure that directory stack hasn't been decreased.
+		# Ensure that directory stack has not been decreased.
 		if [[ "$(dirs -p | wc -l)" -lt "${previous_directory_stack_length}" ]]; then
 			die "Directory stack decreased illegally"
 		fi
@@ -650,7 +658,7 @@
 			popd > /dev/null || die "popd failed"
 		done
 
-		# Ensure that the bottom part of directory stack hasn't been changed. Restore
+		# Ensure that the bottom part of directory stack has not been changed. Restore
 		# previous directory (from before running of the specified function) before
 		# comparison of directory stacks to avoid mismatch of directory stacks after
 		# potential using of 'cd' to change current directory. Restoration of previous
@@ -714,7 +722,7 @@
 
 	for argument in "$@"; do
 		if [[ ! -e "${argument}" ]]; then
-			die "${FUNCNAME}(): '${argument}' doesn't exist"
+			die "${FUNCNAME}(): '${argument}' does not exist"
 		elif [[ -f "${argument}" ]]; then
 			files+=("${argument}")
 		elif [[ -d "${argument}" ]]; then
@@ -725,10 +733,10 @@
 					files+=($(find "${argument}" -type f))
 				fi
 			else
-				die "${FUNCNAME}(): '${argument}' isn't a regular file"
+				die "${FUNCNAME}(): '${argument}' is not a regular file"
 			fi
 		else
-			die "${FUNCNAME}(): '${argument}' isn't a regular file or a directory"
+			die "${FUNCNAME}(): '${argument}' is not a regular file or a directory"
 		fi
 	done
 
@@ -1010,7 +1018,7 @@
 # @FUNCTION: python_disable_pyc
 # @DESCRIPTION:
 # Tell Python not to automatically recompile modules to .pyc/.pyo
-# even if the timestamps/version stamps don't match. This is done
+# even if the timestamps/version stamps do not match. This is done
 # to protect sandbox.
 python_disable_pyc() {
 	export PYTHONDONTWRITEBYTECODE="1"
@@ -1027,6 +1035,8 @@
 # @FUNCTION: python_need_rebuild
 # @DESCRIPTION: Run without arguments, specifies that the package should be
 # rebuilt after a python upgrade.
+# Do not use this function in ebuilds of packages supporting installation
+# for multiple versions of Python.
 python_need_rebuild() {
 	export PYTHON_NEED_REBUILD="$(PYTHON -A --ABI)"
 }
@@ -1165,8 +1175,8 @@
 					ewarn "${FUNCNAME}: Ignoring compile option $1"
 					;;
 				*)
-					if [[ "$1" =~ ^/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then
-						die "${FUNCNAME} doesn't support absolute paths of directories/files in site-packages directories"
+					if ! _python_implementation && [[ "$1" =~ ^/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then
+						die "${FUNCNAME} does not support absolute paths of directories/files in site-packages directories"
 					elif [[ "$1" =~ ^/ ]]; then
 						if [[ -d "${root}/$1" ]]; then
 							other_dirs+=("${root}/$1")
@@ -1175,7 +1185,7 @@
 						elif [[ -e "${root}/$1" ]]; then
 							ewarn "'${root}/$1' is not a file or a directory!"
 						else
-							ewarn "'${root}/$1' doesn't exist!"
+							ewarn "'${root}/$1' does not exist!"
 						fi
 					else
 						for PYTHON_ABI in ${PYTHON_ABIS-${PYTHON_ABI-$(PYTHON -A --ABI)}}; do
@@ -1188,7 +1198,7 @@
 							elif [[ -e "${root}$(python_get_sitedir)/$1" ]]; then
 								ewarn "'$1' is not a file or a directory!"
 							else
-								ewarn "'$1' doesn't exist!"
+								ewarn "'$1' does not exist!"
 							fi
 						done
 					fi
@@ -1223,7 +1233,7 @@
 			unset site_packages_absolute_dirs site_packages_absolute_files
 		done
 
-		# Don't use PYTHON_ABI in next calls to python_get_libdir().
+		# Do not use PYTHON_ABI in next calls to python_get_libdir().
 		unset PYTHON_ABI
 
 		if ((${#other_dirs[@]})) || ((${#other_files[@]})); then
@@ -1267,7 +1277,7 @@
 					elif [[ -e "${myroot}/$1" ]]; then
 						ewarn "${myroot}/$1 is not a file or directory!"
 					else
-						ewarn "${myroot}/$1 doesn't exist!"
+						ewarn "${myroot}/$1 does not exist!"
 					fi
 					;;
 			esac
@@ -1314,8 +1324,8 @@
 	if (($#)); then
 		if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
 			while (($#)); do
-				if [[ "$1" =~ ^/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then
-					die "${FUNCNAME} doesn't support absolute paths of directories/files in site-packages directories"
+				if ! _python_implementation && [[ "$1" =~ ^/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then
+					die "${FUNCNAME} does not support absolute paths of directories/files in site-packages directories"
 				elif [[ "$1" =~ ^/ ]]; then
 					SEARCH_PATH+=("${root}/${1#/}")
 				else






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2010-01-14 19:23 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2010-01-14 19:23 UTC (permalink / raw
  To: gentoo-commits

arfrever    10/01/14 19:23:02

  Modified:             python.eclass
  Log:
  Define functions in more logical order.

Revision  Changes    Path
1.85                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.85&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.85&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.84&r2=1.85

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -r1.84 -r1.85
--- python.eclass	11 Jan 2010 16:07:23 -0000	1.84
+++ python.eclass	14 Jan 2010 19:23:02 -0000	1.85
@@ -1,6 +1,6 @@
 # Copyright 1999-2010 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.84 2010/01/11 16:07:23 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.85 2010/01/14 19:23:02 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -25,208 +25,106 @@
 
 DEPEND+=" >=app-admin/eselect-python-20090804"
 
-__python_eclass_test() {
-	__python_version_extract 2.3
-	echo -n "2.3 -> PYVER: $PYVER PYVER_MAJOR: $PYVER_MAJOR"
-	echo " PYVER_MINOR: $PYVER_MINOR PYVER_MICRO: $PYVER_MICRO"
-	__python_version_extract 2.3.4
-	echo -n "2.3.4 -> PYVER: $PYVER PYVER_MAJOR: $PYVER_MAJOR"
-	echo " PYVER_MINOR: $PYVER_MINOR PYVER_MICRO: $PYVER_MICRO"
-	__python_version_extract 2.3.5
-	echo -n "2.3.5 -> PYVER: $PYVER PYVER_MAJOR: $PYVER_MAJOR"
-	echo " PYVER_MINOR: $PYVER_MINOR PYVER_MICRO: $PYVER_MICRO"
-	__python_version_extract 2.4
-	echo -n "2.4 -> PYVER: $PYVER PYVER_MAJOR: $PYVER_MAJOR"
-	echo " PYVER_MINOR: $PYVER_MINOR PYVER_MICRO: $PYVER_MICRO"
-	__python_version_extract 2.5b3
-	echo -n "2.5b3 -> PYVER: $PYVER PYVER_MAJOR: $PYVER_MAJOR"
-	echo " PYVER_MINOR: $PYVER_MINOR PYVER_MICRO: $PYVER_MICRO"
-}
+# @ECLASS-VARIABLE: PYTHON_USE_WITH
+# @DESCRIPTION:
+# Set this to a space separated list of use flags
+# the python slot in use must be built with.
 
-# @FUNCTION: python_version
+# @ECLASS-VARIABLE: PYTHON_USE_WITH_OR
 # @DESCRIPTION:
-# Run without arguments and it will export the version of python
-# currently in use as $PYVER; sets PYVER/PYVER_MAJOR/PYVER_MINOR
-__python_version_extract() {
-	local verstr=$1
-	export PYVER_MAJOR=${verstr:0:1}
-	export PYVER_MINOR=${verstr:2:1}
-	if [[ ${verstr:3:1} == . ]]; then
-		export PYVER_MICRO=${verstr:4}
-	fi
-	export PYVER="${PYVER_MAJOR}.${PYVER_MINOR}"
-}
+# Set this to a space separated list of use flags
+# of which one must be turned on for the slot of
+# in use.
 
-python_version() {
-	[[ -n "${PYVER}" ]] && return 0
-	local tmpstr
-	python=${python:-/usr/bin/python}
-	tmpstr="$(EPYTHON= ${python} -V 2>&1 )"
-	export PYVER_ALL="${tmpstr#Python }"
-	__python_version_extract $PYVER_ALL
-}
+# @ECLASS-VARIABLE: PYTHON_USE_WITH_OPT
+# @DESCRIPTION:
+# Set this if you need to make either PYTHON_USE_WITH or
+# PYTHON_USE_WITH_OR atoms conditional under a use flag.
 
-# @FUNCTION: PYTHON
-# @USAGE: [-2] [-3] [--ABI] [-A|--active] [-a|--absolute-path] [-f|--final-ABI] [--] <Python_ABI="${PYTHON_ABI}">
+# @FUNCTION: python_pkg_setup
 # @DESCRIPTION:
-# Get Python interpreter filename for specified Python ABI. If Python_ABI argument
-# is ommitted, then PYTHON_ABI environment variable must be set and is used.
-# If -2 option is specified, then active version of Python 2 is used.
-# If -3 option is specified, then active version of Python 3 is used.
-# If --active option is specified, then active version of Python is used.
-# Active version of Python can be set by python_set_active_version().
-# If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
-# -2, -3, --active and --final-ABI options and Python_ABI argument cannot be specified simultaneously.
-# If --ABI option is specified, then only specified Python ABI is printed instead of
-# Python interpreter filename.
-# --ABI and --absolute-path options cannot be specified simultaneously.
-PYTHON() {
-	local ABI_output="0" absolute_path_output="0" active="0" final_ABI="0" python2="0" python3="0" slot=
+# Makes sure PYTHON_USE_WITH or PYTHON_USE_WITH_OR listed use flags
+# are respected. Only exported if one of those variables is set.
+if ! has "${EAPI:-0}" 0 1 && [[ -n ${PYTHON_USE_WITH} || -n ${PYTHON_USE_WITH_OR} ]]; then
+	python_pkg_setup() {
+		python_pkg_setup_fail() {
+			eerror "${1}"
+			die "${1}"
+		}
 
-	while (($#)); do
-		case "$1" in
-			-2)
-				python2="1"
-				;;
-			-3)
-				python3="1"
-				;;
-			--ABI)
-				ABI_output="1"
-				;;
-			-A|--active)
-				active="1"
-				;;
-			-a|--absolute-path)
-				absolute_path_output="1"
-				;;
-			-f|--final-ABI)
-				final_ABI="1"
-				;;
-			--)
-				break
-				;;
-			-*)
-				die "${FUNCNAME}(): Unrecognized option '$1'"
-				;;
-			*)
-				break
-				;;
-		esac
-		shift
-	done
+		[[ ${PYTHON_USE_WITH_OPT} ]] && use !${PYTHON_USE_WITH_OPT} && return
 
-	if [[ "${ABI_output}" == "1" && "${absolute_path_output}" == "1" ]]; then
-		die "${FUNCNAME}(): '--ABI and '--absolute-path' options cannot be specified simultaneously"
-	fi
+		python_pkg_setup_check_USE_flags() {
+			local pyatom use
+			if [[ -n "${PYTHON_ABI}" ]]; then
+				pyatom="dev-lang/python:${PYTHON_ABI}"
+			else
+				pyatom="dev-lang/python:$(PYTHON -A --ABI)"
+			fi
 
-	if [[ "$((${python2} + ${python3} + ${active} + ${final_ABI}))" -gt 1 ]]; then
-		die "${FUNCNAME}(): '-2', '-3', '--active' or '--final-ABI' options cannot be specified simultaneously"
-	fi
+			for use in ${PYTHON_USE_WITH}; do
+				if ! has_version "${pyatom}[${use}]"; then
+					python_pkg_setup_fail "Please rebuild ${pyatom} with the following USE flags enabled: ${PYTHON_USE_WITH}"
+				fi
+			done
 
-	if [[ "$#" -eq 0 ]]; then
-		if [[ "${active}" == "1" ]]; then
-			if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
-				die "${FUNCNAME}(): '--active' option cannot be used in ebuilds of packages supporting installation for multiple versions of Python"
-			fi
-			slot="$(/usr/bin/python -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')"
-		elif [[ "${final_ABI}" == "1" ]]; then
-			validate_PYTHON_ABIS
-			slot="${PYTHON_ABIS##* }"
-		elif [[ "${python2}" == "1" ]]; then
-			slot="$(eselect python show --python2)"
-			if [[ -z "${slot}" ]]; then
-				die "${FUNCNAME}(): Active Python 2 interpreter not set"
-			elif [[ "${slot}" != "python2."* ]]; then
-				die "${FUNCNAME}(): Internal error in \`eselect python show --python2\`"
-			fi
-			slot="${slot#python}"
-		elif [[ "${python3}" == "1" ]]; then
-			slot="$(eselect python show --python3)"
-			if [[ -z "${slot}" ]]; then
-				die "${FUNCNAME}(): Active Python 3 interpreter not set"
-			elif [[ "${slot}" != "python3."* ]]; then
-				die "${FUNCNAME}(): Internal error in \`eselect python show --python3\`"
+			for use in ${PYTHON_USE_WITH_OR}; do
+				if has_version "${pyatom}[${use}]"; then
+					return
+				fi
+			done
+
+			if [[ ${PYTHON_USE_WITH_OR} ]]; then
+				python_pkg_setup_fail "Please rebuild ${pyatom} with at least one of the following USE flags enabled: ${PYTHON_USE_WITH_OR}"
 			fi
-			slot="${slot#python}"
-		elif [[ -n "${PYTHON_ABI}" ]]; then
-			slot="${PYTHON_ABI}"
+		}
+
+		if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
+			python_execute_function -q python_pkg_setup_check_USE_flags
 		else
-			die "${FUNCNAME}(): Invalid usage"
-		fi
-	elif [[ "$#" -eq 1 ]]; then
-		if [[ "${active}" == "1" ]]; then
-			die "${FUNCNAME}(): '--active' option and Python ABI cannot be specified simultaneously"
-		fi
-		if [[ "${final_ABI}" == "1" ]]; then
-			die "${FUNCNAME}(): '--final-ABI' option and Python ABI cannot be specified simultaneously"
-		fi
-		if [[ "${python2}" == "1" ]]; then
-			die "${FUNCNAME}(): '-2' option and Python ABI cannot be specified simultaneously"
-		fi
-		if [[ "${python3}" == "1" ]]; then
-			die "${FUNCNAME}(): '-3' option and Python ABI cannot be specified simultaneously"
+			python_pkg_setup_check_USE_flags
 		fi
-		slot="$1"
-	else
-		die "${FUNCNAME}(): Invalid usage"
-	fi
+	}
 
-	if [[ "${ABI_output}" == "1" ]]; then
-		echo -n "${slot}"
-		return
-	elif [[ "${absolute_path_output}" == "1" ]]; then
-		echo -n "/usr/bin/python${slot}"
-	else
-		echo -n "python${slot}"
-	fi
+	EXPORT_FUNCTIONS pkg_setup
 
-	if [[ -n "${ABI}" && "${ABI}" != "${DEFAULT_ABI}" && "${DEFAULT_ABI}" != "default" ]]; then
-		echo -n "-${ABI}"
+	if [[ -n "${PYTHON_USE_WITH}" ]]; then
+		PYTHON_USE_WITH_ATOM="${PYTHON_ATOM}[${PYTHON_USE_WITH/ /,}]"
+	elif [[ -n "${PYTHON_USE_WITH_OR}" ]]; then
+		PYTHON_USE_WITH_ATOM="|| ( "
+		for use in ${PYTHON_USE_WITH_OR}; do
+			PYTHON_USE_WITH_ATOM+=" ${PYTHON_ATOM}[${use}]"
+		done
+		unset use
+		PYTHON_USE_WITH_ATOM+=" )"
 	fi
-}
-
-_python_implementation() {
-	if [[ "${CATEGORY}/${PN}" == "dev-lang/python" ]]; then
-		return 0
-	else
-		return 1
+	if [[ -n "${PYTHON_USE_WITH_OPT}" ]]; then
+		PYTHON_USE_WITH_ATOM="${PYTHON_USE_WITH_OPT}? ( ${PYTHON_USE_WITH_ATOM} )"
 	fi
-}
+	DEPEND+=" ${PYTHON_USE_WITH_ATOM}"
+	RDEPEND+=" ${PYTHON_USE_WITH_ATOM}"
+fi
 
-# @FUNCTION: python_set_active_version
-# @USAGE: <Python_ABI|2|3>
+# ================================================================================================
+# ======== FUNCTIONS FOR PACKAGES SUPPORTING INSTALLATION FOR MULTIPLE VERSIONS OF PYTHON ========
+# ================================================================================================
+
+# @ECLASS-VARIABLE: PYTHON_DEFINE_DEFAULT_FUNCTIONS
 # @DESCRIPTION:
-# Set active version of Python.
-python_set_active_version() {
-	if [[ "$#" -ne "1" ]]; then
-		die "${FUNCNAME}() requires 1 argument"
-	fi
+# Set this to define default functions for the following ebuild phases:
+# src_prepare, src_configure, src_compile, src_test, src_install.
+if ! has "${EAPI:-0}" 0 1 && [[ -n "${PYTHON_DEFINE_DEFAULT_FUNCTIONS}" ]]; then
+	python_src_prepare() {
+		python_copy_sources
+	}
 
-	if [[ "$1" =~ ^[[:digit:]]+\.[[:digit:]]+$ ]]; then
-		if ! _python_implementation && ! has_version "dev-lang/python:$1"; then
-			die "${FUNCNAME}(): 'dev-lang/python:$1' is not installed"
-		fi
-		export EPYTHON="$(PYTHON "$1")"
-	elif [[ "$1" == "2" ]]; then
-		if ! _python_implementation && ! has_version "=dev-lang/python-2*"; then
-			die "${FUNCNAME}(): '=dev-lang/python-2*' is not installed"
-		fi
-		export EPYTHON="$(PYTHON -2)"
-	elif [[ "$1" == "3" ]]; then
-		if ! _python_implementation && ! has_version "=dev-lang/python-3*"; then
-			die "${FUNCNAME}(): '=dev-lang/python-3*' is not installed"
-		fi
-		export EPYTHON="$(PYTHON -3)"
-	else
-		die "${FUNCNAME}(): Unrecognized argument '$1'"
-	fi
+	for python_default_function in src_configure src_compile src_test src_install; do
+		eval "python_${python_default_function}() { python_execute_function -d -s; }"
+	done
+	unset python_default_function
 
-	# PYTHON_ABI variable is intended to be used only in ebuilds/eclasses,
-	# so it does not need to be exported to subprocesses.
-	PYTHON_ABI="${EPYTHON#python}"
-	PYTHON_ABI="${PYTHON_ABI%%-*}"
-}
+	EXPORT_FUNCTIONS src_prepare src_configure src_compile src_test src_install
+fi
 
 unset PYTHON_ABIS
 unset PYTHON_ABIS_SANITY_CHECKS
@@ -397,67 +295,6 @@
 	fi
 }
 
-# @FUNCTION: python_copy_sources
-# @USAGE: [--no-link] [--] [directory]
-# @DESCRIPTION:
-# Copy unpacked sources of given package for each Python ABI.
-python_copy_sources() {
-	local dir dirs=() no_link="0" PYTHON_ABI
-
-	while (($#)); do
-		case "$1" in
-			--no-link)
-				no_link="1"
-				;;
-			--)
-				break
-				;;
-			-*)
-				die "${FUNCNAME}(): Unrecognized option '$1'"
-				;;
-			*)
-				break
-				;;
-		esac
-		shift
-	done
-
-	if [[ "$#" -eq 0 ]]; then
-		if [[ "${WORKDIR}" == "${S}" ]]; then
-			die "${FUNCNAME}() cannot be used"
-		fi
-		dirs="${S}"
-	else
-		dirs="$@"
-	fi
-
-	validate_PYTHON_ABIS
-	for PYTHON_ABI in ${PYTHON_ABIS}; do
-		for dir in "${dirs[@]}"; do
-			if [[ "${no_link}" == "1" ]]; then
-				cp -pr "${dir}" "${dir}-${PYTHON_ABI}" > /dev/null || die "Copying of sources failed"
-			else
-				cp -lpr "${dir}" "${dir}-${PYTHON_ABI}" > /dev/null || die "Copying of sources failed"
-			fi
-		done
-	done
-}
-
-# @FUNCTION: python_set_build_dir_symlink
-# @USAGE: [directory="build"]
-# @DESCRIPTION:
-# Create build directory symlink.
-python_set_build_dir_symlink() {
-	local dir="$1"
-
-	[[ -z "${PYTHON_ABI}" ]] && die "PYTHON_ABI variable not set"
-	[[ -z "${dir}" ]] && dir="build"
-
-	# Do not delete preexistent directories.
-	rm -f "${dir}" || die "Deletion of '${dir}' failed"
-	ln -s "${dir}-${PYTHON_ABI}" "${dir}" || die "Creation of '${dir}' directory symlink failed"
-}
-
 # @FUNCTION: python_execute_function
 # @USAGE: [--action-message message] [-d|--default-function] [--failure-message message] [--nonfatal] [-q|--quiet] [-s|--separate-build-dirs] [--source-dir source_directory] [--] <function> [arguments]
 # @DESCRIPTION:
@@ -680,23 +517,17 @@
 	fi
 }
 
-# @FUNCTION: python_convert_shebangs
-# @USAGE: [-q|--quiet] [-r|--recursive] [-x|--only-executables] [--] <Python_version> <file|directory> [files|directories]
+# @FUNCTION: python_copy_sources
+# @USAGE: [--no-link] [--] [directory]
 # @DESCRIPTION:
-# Convert shebangs in specified files. Directories can be specified only with --recursive option.
-python_convert_shebangs() {
-	local argument file files=() only_executables="0" python_version quiet="0" recursive="0"
+# Copy unpacked sources of given package for each Python ABI.
+python_copy_sources() {
+	local dir dirs=() no_link="0" PYTHON_ABI
 
 	while (($#)); do
 		case "$1" in
-			-r|--recursive)
-				recursive="1"
-				;;
-			-q|--quiet)
-				quiet="1"
-				;;
-			-x|--only-executables)
-				only_executables="1"
+			--no-link)
+				no_link="1"
 				;;
 			--)
 				break
@@ -712,48 +543,39 @@
 	done
 
 	if [[ "$#" -eq 0 ]]; then
-		die "${FUNCNAME}(): Missing Python version and files or directories"
-	elif [[ "$#" -eq 1 ]]; then
-		die "${FUNCNAME}(): Missing files or directories"
+		if [[ "${WORKDIR}" == "${S}" ]]; then
+			die "${FUNCNAME}() cannot be used"
+		fi
+		dirs="${S}"
+	else
+		dirs="$@"
 	fi
 
-	python_version="$1"
-	shift
-
-	for argument in "$@"; do
-		if [[ ! -e "${argument}" ]]; then
-			die "${FUNCNAME}(): '${argument}' does not exist"
-		elif [[ -f "${argument}" ]]; then
-			files+=("${argument}")
-		elif [[ -d "${argument}" ]]; then
-			if [[ "${recursive}" == "1" ]]; then
-				if [[ "${only_executables}" == "1" ]]; then
-					files+=($(find "${argument}" -perm /111 -type f))
-				else
-					files+=($(find "${argument}" -type f))
-				fi
+	validate_PYTHON_ABIS
+	for PYTHON_ABI in ${PYTHON_ABIS}; do
+		for dir in "${dirs[@]}"; do
+			if [[ "${no_link}" == "1" ]]; then
+				cp -pr "${dir}" "${dir}-${PYTHON_ABI}" > /dev/null || die "Copying of sources failed"
 			else
-				die "${FUNCNAME}(): '${argument}' is not a regular file"
+				cp -lpr "${dir}" "${dir}-${PYTHON_ABI}" > /dev/null || die "Copying of sources failed"
 			fi
-		else
-			die "${FUNCNAME}(): '${argument}' is not a regular file or a directory"
-		fi
+		done
 	done
+}
 
-	for file in "${files[@]}"; do
-		file="${file#./}"
-		[[ "${only_executables}" == "1" && ! -x "${file}" ]] && continue
+# @FUNCTION: python_set_build_dir_symlink
+# @USAGE: [directory="build"]
+# @DESCRIPTION:
+# Create build directory symlink.
+python_set_build_dir_symlink() {
+	local dir="$1"
 
-		if [[ "$(head -n1 "${file}")" =~ ^'#!'.*python ]]; then
-			if [[ "${quiet}" == "0" ]]; then
-				einfo "Converting shebang in '${file}'"
-			fi
-			sed -e "1s/python\([[:digit:]]\+\(\.[[:digit:]]\+\)\?\)\?/python${python_version}/" -i "${file}" || die "Conversion of shebang in '${file}' failed"
+	[[ -z "${PYTHON_ABI}" ]] && die "PYTHON_ABI variable not set"
+	[[ -z "${dir}" ]] && dir="build"
 
-			# Delete potential whitespace after "#!".
-			sed -e '1s/\(^#!\)[[:space:]]*/\1/' -i "${file}" || die "sed '${file}' failed"
-		fi
-	done
+	# Do not delete preexistent directories.
+	rm -f "${dir}" || die "Deletion of '${dir}' failed"
+	ln -s "${dir}-${PYTHON_ABI}" "${dir}" || die "Creation of '${dir}' directory symlink failed"
 }
 
 # @FUNCTION: python_generate_wrapper_scripts
@@ -918,127 +740,175 @@
 	done
 }
 
-# @ECLASS-VARIABLE: PYTHON_USE_WITH
-# @DESCRIPTION:
-# Set this to a space separated list of use flags
-# the python slot in use must be built with.
-
-# @ECLASS-VARIABLE: PYTHON_USE_WITH_OR
-# @DESCRIPTION:
-# Set this to a space separated list of use flags
-# of which one must be turned on for the slot of
-# in use.
-
-# @ECLASS-VARIABLE: PYTHON_USE_WITH_OPT
-# @DESCRIPTION:
-# Set this if you need to make either PYTHON_USE_WITH or
-# PYTHON_USE_WITH_OR atoms conditional under a use flag.
+# ================================================================================================
+# ====== FUNCTIONS FOR PACKAGES NOT SUPPORTING INSTALLATION FOR MULTIPLE VERSIONS OF PYTHON ======
+# ================================================================================================
 
-# @FUNCTION: python_pkg_setup
+# @FUNCTION: python_set_active_version
+# @USAGE: <Python_ABI|2|3>
 # @DESCRIPTION:
-# Makes sure PYTHON_USE_WITH or PYTHON_USE_WITH_OR listed use flags
-# are respected. Only exported if one of those variables is set.
-if ! has "${EAPI:-0}" 0 1 && [[ -n ${PYTHON_USE_WITH} || -n ${PYTHON_USE_WITH_OR} ]]; then
-	python_pkg_setup() {
-		python_pkg_setup_fail() {
-			eerror "${1}"
-			die "${1}"
-		}
-
-		[[ ${PYTHON_USE_WITH_OPT} ]] && use !${PYTHON_USE_WITH_OPT} && return
-
-		python_pkg_setup_check_USE_flags() {
-			local pyatom use
-			if [[ -n "${PYTHON_ABI}" ]]; then
-				pyatom="dev-lang/python:${PYTHON_ABI}"
-			else
-				pyatom="dev-lang/python:$(PYTHON -A --ABI)"
-			fi
-
-			for use in ${PYTHON_USE_WITH}; do
-				if ! has_version "${pyatom}[${use}]"; then
-					python_pkg_setup_fail "Please rebuild ${pyatom} with the following USE flags enabled: ${PYTHON_USE_WITH}"
-				fi
-			done
-
-			for use in ${PYTHON_USE_WITH_OR}; do
-				if has_version "${pyatom}[${use}]"; then
-					return
-				fi
-			done
-
-			if [[ ${PYTHON_USE_WITH_OR} ]]; then
-				python_pkg_setup_fail "Please rebuild ${pyatom} with at least one of the following USE flags enabled: ${PYTHON_USE_WITH_OR}"
-			fi
-		}
+# Set active version of Python.
+python_set_active_version() {
+	if [[ "$#" -ne "1" ]]; then
+		die "${FUNCNAME}() requires 1 argument"
+	fi
 
-		if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
-			python_execute_function -q python_pkg_setup_check_USE_flags
-		else
-			python_pkg_setup_check_USE_flags
+	if [[ "$1" =~ ^[[:digit:]]+\.[[:digit:]]+$ ]]; then
+		if ! _python_implementation && ! has_version "dev-lang/python:$1"; then
+			die "${FUNCNAME}(): 'dev-lang/python:$1' is not installed"
 		fi
-	}
+		export EPYTHON="$(PYTHON "$1")"
+	elif [[ "$1" == "2" ]]; then
+		if ! _python_implementation && ! has_version "=dev-lang/python-2*"; then
+			die "${FUNCNAME}(): '=dev-lang/python-2*' is not installed"
+		fi
+		export EPYTHON="$(PYTHON -2)"
+	elif [[ "$1" == "3" ]]; then
+		if ! _python_implementation && ! has_version "=dev-lang/python-3*"; then
+			die "${FUNCNAME}(): '=dev-lang/python-3*' is not installed"
+		fi
+		export EPYTHON="$(PYTHON -3)"
+	else
+		die "${FUNCNAME}(): Unrecognized argument '$1'"
+	fi
 
-	EXPORT_FUNCTIONS pkg_setup
+	# PYTHON_ABI variable is intended to be used only in ebuilds/eclasses,
+	# so it does not need to be exported to subprocesses.
+	PYTHON_ABI="${EPYTHON#python}"
+	PYTHON_ABI="${PYTHON_ABI%%-*}"
+}
 
-	if [[ -n "${PYTHON_USE_WITH}" ]]; then
-		PYTHON_USE_WITH_ATOM="${PYTHON_ATOM}[${PYTHON_USE_WITH/ /,}]"
-	elif [[ -n "${PYTHON_USE_WITH_OR}" ]]; then
-		PYTHON_USE_WITH_ATOM="|| ( "
-		for use in ${PYTHON_USE_WITH_OR}; do
-			PYTHON_USE_WITH_ATOM+=" ${PYTHON_ATOM}[${use}]"
-		done
-		unset use
-		PYTHON_USE_WITH_ATOM+=" )"
-	fi
-	if [[ -n "${PYTHON_USE_WITH_OPT}" ]]; then
-		PYTHON_USE_WITH_ATOM="${PYTHON_USE_WITH_OPT}? ( ${PYTHON_USE_WITH_ATOM} )"
-	fi
-	DEPEND+=" ${PYTHON_USE_WITH_ATOM}"
-	RDEPEND+=" ${PYTHON_USE_WITH_ATOM}"
-fi
+# @FUNCTION: python_need_rebuild
+# @DESCRIPTION: Run without arguments, specifies that the package should be
+# rebuilt after a python upgrade.
+# Do not use this function in ebuilds of packages supporting installation
+# for multiple versions of Python.
+python_need_rebuild() {
+	export PYTHON_NEED_REBUILD="$(PYTHON -A --ABI)"
+}
 
-# @ECLASS-VARIABLE: PYTHON_DEFINE_DEFAULT_FUNCTIONS
+# ================================================================================================
+# ======================================= GETTER FUNCTIONS =======================================
+# ================================================================================================
+
+# @FUNCTION: PYTHON
+# @USAGE: [-2] [-3] [--ABI] [-A|--active] [-a|--absolute-path] [-f|--final-ABI] [--] <Python_ABI="${PYTHON_ABI}">
 # @DESCRIPTION:
-# Set this to define default functions for the following ebuild phases:
-# src_prepare, src_configure, src_compile, src_test, src_install.
-if ! has "${EAPI:-0}" 0 1 && [[ -n "${PYTHON_DEFINE_DEFAULT_FUNCTIONS}" ]]; then
-	python_src_prepare() {
-		python_copy_sources
-	}
+# Get Python interpreter filename for specified Python ABI. If Python_ABI argument
+# is ommitted, then PYTHON_ABI environment variable must be set and is used.
+# If -2 option is specified, then active version of Python 2 is used.
+# If -3 option is specified, then active version of Python 3 is used.
+# If --active option is specified, then active version of Python is used.
+# Active version of Python can be set by python_set_active_version().
+# If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
+# -2, -3, --active and --final-ABI options and Python_ABI argument cannot be specified simultaneously.
+# If --ABI option is specified, then only specified Python ABI is printed instead of
+# Python interpreter filename.
+# --ABI and --absolute-path options cannot be specified simultaneously.
+PYTHON() {
+	local ABI_output="0" absolute_path_output="0" active="0" final_ABI="0" python2="0" python3="0" slot=
 
-	for python_default_function in src_configure src_compile src_test src_install; do
-		eval "python_${python_default_function}() { python_execute_function -d -s; }"
+	while (($#)); do
+		case "$1" in
+			-2)
+				python2="1"
+				;;
+			-3)
+				python3="1"
+				;;
+			--ABI)
+				ABI_output="1"
+				;;
+			-A|--active)
+				active="1"
+				;;
+			-a|--absolute-path)
+				absolute_path_output="1"
+				;;
+			-f|--final-ABI)
+				final_ABI="1"
+				;;
+			--)
+				break
+				;;
+			-*)
+				die "${FUNCNAME}(): Unrecognized option '$1'"
+				;;
+			*)
+				break
+				;;
+		esac
+		shift
 	done
-	unset python_default_function
 
-	EXPORT_FUNCTIONS src_prepare src_configure src_compile src_test src_install
-fi
+	if [[ "${ABI_output}" == "1" && "${absolute_path_output}" == "1" ]]; then
+		die "${FUNCNAME}(): '--ABI and '--absolute-path' options cannot be specified simultaneously"
+	fi
 
-# @FUNCTION: python_disable_pyc
-# @DESCRIPTION:
-# Tell Python not to automatically recompile modules to .pyc/.pyo
-# even if the timestamps/version stamps do not match. This is done
-# to protect sandbox.
-python_disable_pyc() {
-	export PYTHONDONTWRITEBYTECODE="1"
-}
+	if [[ "$((${python2} + ${python3} + ${active} + ${final_ABI}))" -gt 1 ]]; then
+		die "${FUNCNAME}(): '-2', '-3', '--active' or '--final-ABI' options cannot be specified simultaneously"
+	fi
+
+	if [[ "$#" -eq 0 ]]; then
+		if [[ "${active}" == "1" ]]; then
+			if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
+				die "${FUNCNAME}(): '--active' option cannot be used in ebuilds of packages supporting installation for multiple versions of Python"
+			fi
+			slot="$(/usr/bin/python -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')"
+		elif [[ "${final_ABI}" == "1" ]]; then
+			validate_PYTHON_ABIS
+			slot="${PYTHON_ABIS##* }"
+		elif [[ "${python2}" == "1" ]]; then
+			slot="$(eselect python show --python2)"
+			if [[ -z "${slot}" ]]; then
+				die "${FUNCNAME}(): Active Python 2 interpreter not set"
+			elif [[ "${slot}" != "python2."* ]]; then
+				die "${FUNCNAME}(): Internal error in \`eselect python show --python2\`"
+			fi
+			slot="${slot#python}"
+		elif [[ "${python3}" == "1" ]]; then
+			slot="$(eselect python show --python3)"
+			if [[ -z "${slot}" ]]; then
+				die "${FUNCNAME}(): Active Python 3 interpreter not set"
+			elif [[ "${slot}" != "python3."* ]]; then
+				die "${FUNCNAME}(): Internal error in \`eselect python show --python3\`"
+			fi
+			slot="${slot#python}"
+		elif [[ -n "${PYTHON_ABI}" ]]; then
+			slot="${PYTHON_ABI}"
+		else
+			die "${FUNCNAME}(): Invalid usage"
+		fi
+	elif [[ "$#" -eq 1 ]]; then
+		if [[ "${active}" == "1" ]]; then
+			die "${FUNCNAME}(): '--active' option and Python ABI cannot be specified simultaneously"
+		fi
+		if [[ "${final_ABI}" == "1" ]]; then
+			die "${FUNCNAME}(): '--final-ABI' option and Python ABI cannot be specified simultaneously"
+		fi
+		if [[ "${python2}" == "1" ]]; then
+			die "${FUNCNAME}(): '-2' option and Python ABI cannot be specified simultaneously"
+		fi
+		if [[ "${python3}" == "1" ]]; then
+			die "${FUNCNAME}(): '-3' option and Python ABI cannot be specified simultaneously"
+		fi
+		slot="$1"
+	else
+		die "${FUNCNAME}(): Invalid usage"
+	fi
 
-# @FUNCTION: python_enable_pyc
-# @DESCRIPTION:
-# Tell Python to automatically recompile modules to .pyc/.pyo if the
-# timestamps/version stamps have changed.
-python_enable_pyc() {
-	unset PYTHONDONTWRITEBYTECODE
-}
+	if [[ "${ABI_output}" == "1" ]]; then
+		echo -n "${slot}"
+		return
+	elif [[ "${absolute_path_output}" == "1" ]]; then
+		echo -n "/usr/bin/python${slot}"
+	else
+		echo -n "python${slot}"
+	fi
 
-# @FUNCTION: python_need_rebuild
-# @DESCRIPTION: Run without arguments, specifies that the package should be
-# rebuilt after a python upgrade.
-# Do not use this function in ebuilds of packages supporting installation
-# for multiple versions of Python.
-python_need_rebuild() {
-	export PYTHON_NEED_REBUILD="$(PYTHON -A --ABI)"
+	if [[ -n "${ABI}" && "${ABI}" != "${DEFAULT_ABI}" && "${DEFAULT_ABI}" != "default" ]]; then
+		echo -n "-${ABI}"
+	fi
 }
 
 # @FUNCTION: python_get_includedir
@@ -1070,18 +940,92 @@
 	echo "$(python_get_libdir)/site-packages"
 }
 
-# @FUNCTION: python_tkinter_exists
+# ================================================================================================
+# =================================== MISCELLANEOUS FUNCTIONS ====================================
+# ================================================================================================
+
+_python_implementation() {
+	if [[ "${CATEGORY}/${PN}" == "dev-lang/python" ]]; then
+		return 0
+	else
+		return 1
+	fi
+}
+
+# @FUNCTION: python_convert_shebangs
+# @USAGE: [-q|--quiet] [-r|--recursive] [-x|--only-executables] [--] <Python_version> <file|directory> [files|directories]
 # @DESCRIPTION:
-# Run without arguments, checks if python was compiled with Tkinter
-# support.  If not, prints an error message and dies.
-python_tkinter_exists() {
-	if ! python -c "import Tkinter" >/dev/null 2>&1; then
-		eerror "You need to recompile python with Tkinter support."
-		eerror "Try adding: 'dev-lang/python tk'"
-		eerror "in to /etc/portage/package.use"
-		echo
-		die "missing tkinter support with installed python"
+# Convert shebangs in specified files. Directories can be specified only with --recursive option.
+python_convert_shebangs() {
+	local argument file files=() only_executables="0" python_version quiet="0" recursive="0"
+
+	while (($#)); do
+		case "$1" in
+			-r|--recursive)
+				recursive="1"
+				;;
+			-q|--quiet)
+				quiet="1"
+				;;
+			-x|--only-executables)
+				only_executables="1"
+				;;
+			--)
+				break
+				;;
+			-*)
+				die "${FUNCNAME}(): Unrecognized option '$1'"
+				;;
+			*)
+				break
+				;;
+		esac
+		shift
+	done
+
+	if [[ "$#" -eq 0 ]]; then
+		die "${FUNCNAME}(): Missing Python version and files or directories"
+	elif [[ "$#" -eq 1 ]]; then
+		die "${FUNCNAME}(): Missing files or directories"
 	fi
+
+	python_version="$1"
+	shift
+
+	for argument in "$@"; do
+		if [[ ! -e "${argument}" ]]; then
+			die "${FUNCNAME}(): '${argument}' does not exist"
+		elif [[ -f "${argument}" ]]; then
+			files+=("${argument}")
+		elif [[ -d "${argument}" ]]; then
+			if [[ "${recursive}" == "1" ]]; then
+				if [[ "${only_executables}" == "1" ]]; then
+					files+=($(find "${argument}" -perm /111 -type f))
+				else
+					files+=($(find "${argument}" -type f))
+				fi
+			else
+				die "${FUNCNAME}(): '${argument}' is not a regular file"
+			fi
+		else
+			die "${FUNCNAME}(): '${argument}' is not a regular file or a directory"
+		fi
+	done
+
+	for file in "${files[@]}"; do
+		file="${file#./}"
+		[[ "${only_executables}" == "1" && ! -x "${file}" ]] && continue
+
+		if [[ "$(head -n1 "${file}")" =~ ^'#!'.*python ]]; then
+			if [[ "${quiet}" == "0" ]]; then
+				einfo "Converting shebang in '${file}'"
+			fi
+			sed -e "1s/python\([[:digit:]]\+\(\.[[:digit:]]\+\)\?\)\?/python${python_version}/" -i "${file}" || die "Conversion of shebang in '${file}' failed"
+
+			# Delete potential whitespace after "#!".
+			sed -e '1s/\(^#!\)[[:space:]]*/\1/' -i "${file}" || die "sed '${file}' failed"
+		fi
+	done
 }
 
 # @FUNCTION: python_mod_exists
@@ -1101,40 +1045,39 @@
 	python -c "import $1" &>/dev/null
 }
 
-# @FUNCTION: python_mod_compile
-# @USAGE: <file> [more files ...]
+# @FUNCTION: python_tkinter_exists
 # @DESCRIPTION:
-# Given filenames, it will pre-compile the module's .pyc and .pyo.
-# This function should only be run in pkg_postinst()
-#
-# Example:
-#         python_mod_compile /usr/lib/python2.3/site-packages/pygoogle.py
-#
-python_mod_compile() {
-	if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
-		die "${FUNCNAME}() cannot be used in this EAPI"
+# Run without arguments, checks if python was compiled with Tkinter
+# support.  If not, prints an error message and dies.
+python_tkinter_exists() {
+	if ! python -c "import Tkinter" >/dev/null 2>&1; then
+		eerror "You need to recompile python with Tkinter support."
+		eerror "Try adding: 'dev-lang/python tk'"
+		eerror "in to /etc/portage/package.use"
+		echo
+		die "missing tkinter support with installed python"
 	fi
+}
 
-	local f myroot myfiles=()
-
-	# Check if phase is pkg_postinst()
-	[[ ${EBUILD_PHASE} != postinst ]] &&\
-		die "${FUNCNAME} should only be run in pkg_postinst()"
-
-	# strip trailing slash
-	myroot="${ROOT%/}"
+# ================================================================================================
+# ======================= FUNCTIONS FOR HANDLING OF BYTE-COMPILED MODULES ========================
+# ================================================================================================
 
-	# respect ROOT
-	for f in "$@"; do
-		[[ -f "${myroot}/${f}" ]] && myfiles+=("${myroot}/${f}")
-	done
+# @FUNCTION: python_enable_pyc
+# @DESCRIPTION:
+# Tell Python to automatically recompile modules to .pyc/.pyo if the
+# timestamps/version stamps have changed.
+python_enable_pyc() {
+	unset PYTHONDONTWRITEBYTECODE
+}
 
-	if ((${#myfiles[@]})); then
-		"$(PYTHON -A)" "${myroot}$(python_get_libdir)/py_compile.py" "${myfiles[@]}"
-		"$(PYTHON -A)" -O "${myroot}$(python_get_libdir)/py_compile.py" "${myfiles[@]}" &> /dev/null
-	else
-		ewarn "No files to compile!"
-	fi
+# @FUNCTION: python_disable_pyc
+# @DESCRIPTION:
+# Tell Python not to automatically recompile modules to .pyc/.pyo
+# even if the timestamps/version stamps do not match. This is done
+# to protect sandbox.
+python_disable_pyc() {
+	export PYTHONDONTWRITEBYTECODE="1"
 }
 
 # @FUNCTION: python_mod_optimize
@@ -1382,3 +1325,84 @@
 		fi
 	done
 }
+
+# ================================================================================================
+# ===================================== DEPRECATED FUNCTIONS =====================================
+# ================================================================================================
+
+__python_eclass_test() {
+	__python_version_extract 2.3
+	echo -n "2.3 -> PYVER: $PYVER PYVER_MAJOR: $PYVER_MAJOR"
+	echo " PYVER_MINOR: $PYVER_MINOR PYVER_MICRO: $PYVER_MICRO"
+	__python_version_extract 2.3.4
+	echo -n "2.3.4 -> PYVER: $PYVER PYVER_MAJOR: $PYVER_MAJOR"
+	echo " PYVER_MINOR: $PYVER_MINOR PYVER_MICRO: $PYVER_MICRO"
+	__python_version_extract 2.3.5
+	echo -n "2.3.5 -> PYVER: $PYVER PYVER_MAJOR: $PYVER_MAJOR"
+	echo " PYVER_MINOR: $PYVER_MINOR PYVER_MICRO: $PYVER_MICRO"
+	__python_version_extract 2.4
+	echo -n "2.4 -> PYVER: $PYVER PYVER_MAJOR: $PYVER_MAJOR"
+	echo " PYVER_MINOR: $PYVER_MINOR PYVER_MICRO: $PYVER_MICRO"
+	__python_version_extract 2.5b3
+	echo -n "2.5b3 -> PYVER: $PYVER PYVER_MAJOR: $PYVER_MAJOR"
+	echo " PYVER_MINOR: $PYVER_MINOR PYVER_MICRO: $PYVER_MICRO"
+}
+
+# @FUNCTION: python_version
+# @DESCRIPTION:
+# Run without arguments and it will export the version of python
+# currently in use as $PYVER; sets PYVER/PYVER_MAJOR/PYVER_MINOR
+__python_version_extract() {
+	local verstr=$1
+	export PYVER_MAJOR=${verstr:0:1}
+	export PYVER_MINOR=${verstr:2:1}
+	if [[ ${verstr:3:1} == . ]]; then
+		export PYVER_MICRO=${verstr:4}
+	fi
+	export PYVER="${PYVER_MAJOR}.${PYVER_MINOR}"
+}
+
+python_version() {
+	[[ -n "${PYVER}" ]] && return 0
+	local tmpstr
+	python=${python:-/usr/bin/python}
+	tmpstr="$(EPYTHON= ${python} -V 2>&1 )"
+	export PYVER_ALL="${tmpstr#Python }"
+	__python_version_extract $PYVER_ALL
+}
+
+# @FUNCTION: python_mod_compile
+# @USAGE: <file> [more files ...]
+# @DESCRIPTION:
+# Given filenames, it will pre-compile the module's .pyc and .pyo.
+# This function should only be run in pkg_postinst()
+#
+# Example:
+#         python_mod_compile /usr/lib/python2.3/site-packages/pygoogle.py
+#
+python_mod_compile() {
+	if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
+		die "${FUNCNAME}() cannot be used in this EAPI"
+	fi
+
+	local f myroot myfiles=()
+
+	# Check if phase is pkg_postinst()
+	[[ ${EBUILD_PHASE} != postinst ]] &&\
+		die "${FUNCNAME} should only be run in pkg_postinst()"
+
+	# strip trailing slash
+	myroot="${ROOT%/}"
+
+	# respect ROOT
+	for f in "$@"; do
+		[[ -f "${myroot}/${f}" ]] && myfiles+=("${myroot}/${f}")
+	done
+
+	if ((${#myfiles[@]})); then
+		"$(PYTHON -A)" "${myroot}$(python_get_libdir)/py_compile.py" "${myfiles[@]}"
+		"$(PYTHON -A)" -O "${myroot}$(python_get_libdir)/py_compile.py" "${myfiles[@]}" &> /dev/null
+	else
+		ewarn "No files to compile!"
+	fi
+}






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2010-01-15 14:46 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2010-01-15 14:46 UTC (permalink / raw
  To: gentoo-commits

arfrever    10/01/15 14:46:20

  Modified:             python.eclass
  Log:
  Update EAPI checks.
  Add support for -f / --final-ABI option of python_get_includedir(), python_get_libdir() and python_get_sitedir().
  Optimize calls to PYTHON() in python_mod_optimize() and python_mod_compile().
  Delete __python_eclass_test().
  Merge __python_version_extract() with python_version().

Revision  Changes    Path
1.86                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.86&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.86&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.85&r2=1.86

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -r1.85 -r1.86
--- python.eclass	14 Jan 2010 19:23:02 -0000	1.85
+++ python.eclass	15 Jan 2010 14:46:20 -0000	1.86
@@ -1,6 +1,6 @@
 # Copyright 1999-2010 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.85 2010/01/14 19:23:02 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.86 2010/01/15 14:46:20 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -109,6 +109,11 @@
 # ======== FUNCTIONS FOR PACKAGES SUPPORTING INSTALLATION FOR MULTIPLE VERSIONS OF PYTHON ========
 # ================================================================================================
 
+# @ECLASS-VARIABLE: SUPPORT_PYTHON_ABIS
+# @DESCRIPTION:
+# Set this in EAPI <= 4 to indicate that given package supports installation for
+# multiple versions of Python.
+
 # @ECLASS-VARIABLE: PYTHON_DEFINE_DEFAULT_FUNCTIONS
 # @DESCRIPTION:
 # Set this to define default functions for the following ebuild phases:
@@ -132,9 +137,10 @@
 # @FUNCTION: validate_PYTHON_ABIS
 # @DESCRIPTION:
 # Ensure that PYTHON_ABIS variable has valid value.
+# This function usually should not be directly called in ebuilds.
 validate_PYTHON_ABIS() {
-	# Ensure that some functions cannot be accidentally successfully used in EAPI <= 2 without setting SUPPORT_PYTHON_ABIS variable.
-	if has "${EAPI:-0}" 0 1 2 && [[ -z "${SUPPORT_PYTHON_ABIS}" ]]; then
+	# Ensure that some functions cannot be accidentally successfully used in EAPI <= 4 without setting SUPPORT_PYTHON_ABIS variable.
+	if has "${EAPI:-0}" 0 1 2 3 4 && [[ -z "${SUPPORT_PYTHON_ABIS}" ]]; then
 		die "${FUNCNAME}() cannot be used in this EAPI without setting SUPPORT_PYTHON_ABIS variable"
 	fi
 
@@ -856,6 +862,9 @@
 			fi
 			slot="$(/usr/bin/python -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')"
 		elif [[ "${final_ABI}" == "1" ]]; then
+			if has "${EAPI:-0}" 0 1 2 3 4 && [[ -z "${SUPPORT_PYTHON_ABIS}" ]]; then
+				die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple versions of Python"
+			fi
 			validate_PYTHON_ABIS
 			slot="${PYTHON_ABIS##* }"
 		elif [[ "${python2}" == "1" ]]; then
@@ -912,10 +921,31 @@
 }
 
 # @FUNCTION: python_get_includedir
+# @USAGE: [-f|--final-ABI]
 # @DESCRIPTION:
-# Run without arguments, returns the Python include directory.
+# Print Python include directory.
+# If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
 python_get_includedir() {
-	if [[ -n "${PYTHON_ABI}" ]]; then
+	local final_ABI="0"
+
+	while (($#)); do
+		case "$1" in
+			-f|--final-ABI)
+				final_ABI="1"
+				;;
+			-*)
+				die "${FUNCNAME}(): Unrecognized option '$1'"
+				;;
+			*)
+				die "${FUNCNAME}(): Invalid usage"
+				;;
+		esac
+		shift
+	done
+
+	if [[ "${final_ABI}" == "1" ]]; then
+		echo "/usr/include/python$(PYTHON -f --ABI)"
+	elif [[ -n "${PYTHON_ABI}" ]]; then
 		echo "/usr/include/python${PYTHON_ABI}"
 	else
 		echo "/usr/include/python$(PYTHON -A --ABI)"
@@ -923,10 +953,31 @@
 }
 
 # @FUNCTION: python_get_libdir
+# @USAGE: [-f|--final-ABI]
 # @DESCRIPTION:
-# Run without arguments, returns the Python library directory.
+# Print Python library directory.
+# If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
 python_get_libdir() {
-	if [[ -n "${PYTHON_ABI}" ]]; then
+	local final_ABI="0"
+
+	while (($#)); do
+		case "$1" in
+			-f|--final-ABI)
+				final_ABI="1"
+				;;
+			-*)
+				die "${FUNCNAME}(): Unrecognized option '$1'"
+				;;
+			*)
+				die "${FUNCNAME}(): Invalid usage"
+				;;
+		esac
+		shift
+	done
+
+	if [[ "${final_ABI}" == "1" ]]; then
+		echo "/usr/$(get_libdir)/python$(PYTHON -f --ABI)"
+	elif [[ -n "${PYTHON_ABI}" ]]; then
 		echo "/usr/$(get_libdir)/python${PYTHON_ABI}"
 	else
 		echo "/usr/$(get_libdir)/python$(PYTHON -A --ABI)"
@@ -934,10 +985,29 @@
 }
 
 # @FUNCTION: python_get_sitedir
+# @USAGE: [-f|--final-ABI]
 # @DESCRIPTION:
-# Run without arguments, returns the Python site-packages directory.
+# Print Python site-packages directory.
+# If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
 python_get_sitedir() {
-	echo "$(python_get_libdir)/site-packages"
+	local options=()
+
+	while (($#)); do
+		case "$1" in
+			-f|--final-ABI)
+				options+=("$1")
+				;;
+			-*)
+				die "${FUNCNAME}(): Unrecognized option '$1'"
+				;;
+			*)
+				die "${FUNCNAME}(): Invalid usage"
+				;;
+		esac
+		shift
+	done
+
+	echo "$(python_get_libdir "${options[@]}")/site-packages"
 }
 
 # ================================================================================================
@@ -1099,7 +1169,7 @@
 	[[ ${EBUILD_PHASE} != "postinst" ]] && die "${FUNCNAME} should only be run in pkg_postinst()"
 
 	if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
-		local dir file options=() other_dirs=() other_files=() PYTHON_ABI return_code root site_packages_absolute_dirs=() site_packages_dirs=() site_packages_absolute_files=() site_packages_files=()
+		local dir file options=() other_dirs=() other_files=() previous_PYTHON_ABI="${PYTHON_ABI}" PYTHON_ABI return_code root site_packages_absolute_dirs=() site_packages_dirs=() site_packages_absolute_files=() site_packages_files=()
 
 		# Strip trailing slash from ROOT.
 		root="${ROOT%/}"
@@ -1115,7 +1185,7 @@
 					shift
 					;;
 				-*)
-					ewarn "${FUNCNAME}: Ignoring compile option $1"
+					ewarn "${FUNCNAME}: Ignoring option '$1'"
 					;;
 				*)
 					if ! _python_implementation && [[ "$1" =~ ^/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then
@@ -1176,19 +1246,23 @@
 			unset site_packages_absolute_dirs site_packages_absolute_files
 		done
 
-		# Do not use PYTHON_ABI in next calls to python_get_libdir().
-		unset PYTHON_ABI
+		# Restore previous value of PYTHON_ABI.
+		if [[ -n "${previous_PYTHON_ABI}" ]]; then
+			PYTHON_ABI="${previous_PYTHON_ABI}"
+		else
+			unset PYTHON_ABI
+		fi
 
 		if ((${#other_dirs[@]})) || ((${#other_files[@]})); then
 			return_code="0"
 			ebegin "Compilation and optimization of Python modules placed outside of site-packages directories for Python $(PYTHON -A --ABI)"
 			if ((${#other_dirs[@]})); then
-				"$(PYTHON -A)" "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" || return_code="1"
-				"$(PYTHON -A)" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" &> /dev/null || return_code="1"
+				"$(PYTHON "${PYTHON_ABI--A}")" "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" || return_code="1"
+				"$(PYTHON "${PYTHON_ABI--A}")" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" &> /dev/null || return_code="1"
 			fi
 			if ((${#other_files[@]})); then
-				"$(PYTHON -A)" "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" || return_code="1"
-				"$(PYTHON -A)" -O "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" &> /dev/null || return_code="1"
+				"$(PYTHON "${PYTHON_ABI--A}")" "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" || return_code="1"
+				"$(PYTHON "${PYTHON_ABI--A}")" -O "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" &> /dev/null || return_code="1"
 			fi
 			eend "${return_code}"
 		fi
@@ -1209,7 +1283,7 @@
 					shift
 					;;
 				-*)
-					ewarn "${FUNCNAME}: Ignoring compile option $1"
+					ewarn "${FUNCNAME}: Ignoring option '$1'"
 					;;
 				*)
 					if [[ -d "${myroot}"/$1 ]]; then
@@ -1232,8 +1306,8 @@
 
 		ebegin "Compilation and optimization of Python modules for Python $(PYTHON -A --ABI)"
 		if ((${#mydirs[@]})); then
-			"$(PYTHON -A)" "${myroot}$(python_get_libdir)/compileall.py" "${myopts[@]}" "${mydirs[@]}" || return_code="1"
-			"$(PYTHON -A)" -O "${myroot}$(python_get_libdir)/compileall.py" "${myopts[@]}" "${mydirs[@]}" &> /dev/null || return_code="1"
+			"$(PYTHON "${PYTHON_ABI--A}")" "${myroot}$(python_get_libdir)/compileall.py" "${myopts[@]}" "${mydirs[@]}" || return_code="1"
+			"$(PYTHON "${PYTHON_ABI--A}")" -O "${myroot}$(python_get_libdir)/compileall.py" "${myopts[@]}" "${mydirs[@]}" &> /dev/null || return_code="1"
 		fi
 
 		if ((${#myfiles[@]})); then
@@ -1330,45 +1404,22 @@
 # ===================================== DEPRECATED FUNCTIONS =====================================
 # ================================================================================================
 
-__python_eclass_test() {
-	__python_version_extract 2.3
-	echo -n "2.3 -> PYVER: $PYVER PYVER_MAJOR: $PYVER_MAJOR"
-	echo " PYVER_MINOR: $PYVER_MINOR PYVER_MICRO: $PYVER_MICRO"
-	__python_version_extract 2.3.4
-	echo -n "2.3.4 -> PYVER: $PYVER PYVER_MAJOR: $PYVER_MAJOR"
-	echo " PYVER_MINOR: $PYVER_MINOR PYVER_MICRO: $PYVER_MICRO"
-	__python_version_extract 2.3.5
-	echo -n "2.3.5 -> PYVER: $PYVER PYVER_MAJOR: $PYVER_MAJOR"
-	echo " PYVER_MINOR: $PYVER_MINOR PYVER_MICRO: $PYVER_MICRO"
-	__python_version_extract 2.4
-	echo -n "2.4 -> PYVER: $PYVER PYVER_MAJOR: $PYVER_MAJOR"
-	echo " PYVER_MINOR: $PYVER_MINOR PYVER_MICRO: $PYVER_MICRO"
-	__python_version_extract 2.5b3
-	echo -n "2.5b3 -> PYVER: $PYVER PYVER_MAJOR: $PYVER_MAJOR"
-	echo " PYVER_MINOR: $PYVER_MINOR PYVER_MICRO: $PYVER_MICRO"
-}
-
 # @FUNCTION: python_version
 # @DESCRIPTION:
 # Run without arguments and it will export the version of python
 # currently in use as $PYVER; sets PYVER/PYVER_MAJOR/PYVER_MINOR
-__python_version_extract() {
-	local verstr=$1
-	export PYVER_MAJOR=${verstr:0:1}
-	export PYVER_MINOR=${verstr:2:1}
-	if [[ ${verstr:3:1} == . ]]; then
-		export PYVER_MICRO=${verstr:4}
-	fi
-	export PYVER="${PYVER_MAJOR}.${PYVER_MINOR}"
-}
-
 python_version() {
 	[[ -n "${PYVER}" ]] && return 0
 	local tmpstr
-	python=${python:-/usr/bin/python}
+	python="${python:-/usr/bin/python}"
 	tmpstr="$(EPYTHON= ${python} -V 2>&1 )"
 	export PYVER_ALL="${tmpstr#Python }"
-	__python_version_extract $PYVER_ALL
+	export PYVER_MAJOR="${PYVER_ALL:0:1}"
+	export PYVER_MINOR="${PYVER_ALL:2:1}"
+	if [[ "${PYVER_ALL:3:1}" == "." ]]; then
+		export PYVER_MICRO="${PYVER_ALL:4}"
+	fi
+	export PYVER="${PYVER_MAJOR}.${PYVER_MINOR}"
 }
 
 # @FUNCTION: python_mod_compile
@@ -1400,8 +1451,8 @@
 	done
 
 	if ((${#myfiles[@]})); then
-		"$(PYTHON -A)" "${myroot}$(python_get_libdir)/py_compile.py" "${myfiles[@]}"
-		"$(PYTHON -A)" -O "${myroot}$(python_get_libdir)/py_compile.py" "${myfiles[@]}" &> /dev/null
+		"$(PYTHON "${PYTHON_ABI--A}")" "${myroot}$(python_get_libdir)/py_compile.py" "${myfiles[@]}"
+		"$(PYTHON "${PYTHON_ABI--A}")" -O "${myroot}$(python_get_libdir)/py_compile.py" "${myfiles[@]}" &> /dev/null
 	else
 		ewarn "No files to compile!"
 	fi






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2010-02-02 18:55 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2010-02-02 18:55 UTC (permalink / raw
  To: gentoo-commits

arfrever    10/02/02 18:55:00

  Modified:             python.eclass
  Log:
  Support EAPI="3".
  Define _PYTHON2_SUPPORTED_VERSIONS and _PYTHON3_SUPPORTED_VERSIONS to avoid code duplication.
  Support PYTHON_DEPEND.
  Disallow using of NEED_PYTHON in EAPI >=3.
  Use prefix variables (bug #302525).
  Fix handling of -- option in some functions.
  Ensure that python_execute_function() isn't called by a function, which is called by python_execute_function().
  Set PYTHON_REQUESTED_ACTIVE_VERSION in python_set_active_version().
  Add python_get_library() and python_get_version().
  Use PYTHON() in python_mod_exists() and python_tkinter_exists().
  Support Python 3 in python_tkinter_exists().
  Support PYTHON_TEST_VERBOSITY.
  Add python_execute_nosetests(), python_execute_py.test() and python_execute_trial().
  Disallow using of python_version() in EAPI >=3.

Revision  Changes    Path
1.87                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.87&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.87&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.86&r2=1.87

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -r1.86 -r1.87
--- python.eclass	15 Jan 2010 14:46:20 -0000	1.86
+++ python.eclass	2 Feb 2010 18:55:00 -0000	1.87
@@ -1,6 +1,6 @@
 # Copyright 1999-2010 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.86 2010/01/15 14:46:20 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.87 2010/02/02 18:55:00 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -11,35 +11,161 @@
 
 inherit multilib
 
-if ! has "${EAPI:-0}" 0 1 2; then
+if ! has "${EAPI:-0}" 0 1 2 3; then
 	die "API of python.eclass in EAPI=\"${EAPI}\" not established"
 fi
 
-if [[ -n "${NEED_PYTHON}" ]]; then
-	PYTHON_ATOM=">=dev-lang/python-${NEED_PYTHON}"
-	DEPEND="${PYTHON_ATOM}"
-	RDEPEND="${DEPEND}"
+_PYTHON2_SUPPORTED_VERSIONS=(2.4 2.5 2.6 2.7)
+_PYTHON3_SUPPORTED_VERSIONS=(3.0 3.1 3.2)
+
+# @ECLASS-VARIABLE: PYTHON_DEPEND
+# @DESCRIPTION:
+# Specification of dependency on dev-lang/python.
+# Syntax:
+#   PYTHON_DEPEND:             [[!]USE_flag? ]<version_components_group>[ version_components_group]
+#   version_components_group:  <major_version[:[minimal_version][:maximal_version]]>
+#   major_version:             <2|3|*>
+#   minimal_version:           <minimal_major_version.minimal_minor_version>
+#   maximal_version:           <maximal_major_version.maximal_minor_version>
+
+_parse_PYTHON_DEPEND() {
+	local accepted_version accepted_versions=() major_version maximal_version minimal_version python_all="0" python_atoms= python_maximal_version python_minimal_version python_versions=() python2="0" python2_maximal_version python2_minimal_version python3="0" python3_maximal_version python3_minimal_version USE_flag= version_components_group version_components_group_regex version_components_groups
+
+	version_components_group_regex="(2|3|\*)(:([[:digit:]]+\.[[:digit:]]+)?(:([[:digit:]]+\.[[:digit:]]+)?)?)?"
+	version_components_groups="${PYTHON_DEPEND}"
+
+	if [[ "${version_components_groups}" =~ ^((\!)?[[:alnum:]_-]+\?\ )?${version_components_group_regex}(\ ${version_components_group_regex})?$ ]]; then
+		if [[ "${version_components_groups}" =~ ^(\!)?[[:alnum:]_-]+\? ]]; then
+			USE_flag="${version_components_groups%\? *}"
+			version_components_groups="${version_components_groups#* }"
+		fi
+		if [[ "${version_components_groups}" =~ ("*".*" "|" *"|^2.*\ (2|\*)|^3.*\ (3|\*)) ]]; then
+			die "Invalid syntax of PYTHON_DEPEND: Incorrectly specified groups of versions"
+		fi
+
+		version_components_groups="${version_components_groups// /$'\n'}"
+		while read version_components_group; do
+			major_version="${version_components_group:0:1}"
+			minimal_version="${version_components_group:2}"
+			minimal_version="${minimal_version%:*}"
+			maximal_version="${version_components_group:$((3 + ${#minimal_version}))}"
+
+			if [[ "${major_version}" =~ ^(2|3)$ ]]; then
+				if [[ -n "${minimal_version}" && "${major_version}" != "${minimal_version:0:1}" ]]; then
+					die "Invalid syntax of PYTHON_DEPEND: Minimal version '${minimal_version}' not in specified group of versions"
+				fi
+				if [[ -n "${maximal_version}" && "${major_version}" != "${maximal_version:0:1}" ]]; then
+					die "Invalid syntax of PYTHON_DEPEND: Maximal version '${maximal_version}' not in specified group of versions"
+				fi
+			fi
+
+			if [[ "${major_version}" == "2" ]]; then
+				python2="1"
+				python_versions=("${_PYTHON2_SUPPORTED_VERSIONS[@]}")
+				python2_minimal_version="${minimal_version}"
+				python2_maximal_version="${maximal_version}"
+			elif [[ "${major_version}" == "3" ]]; then
+				python3="1"
+				python_versions=("${_PYTHON3_SUPPORTED_VERSIONS[@]}")
+				python3_minimal_version="${minimal_version}"
+				python3_maximal_version="${maximal_version}"
+			else
+				python_all="1"
+				python_versions=("${_PYTHON2_SUPPORTED_VERSIONS[@]}" "${_PYTHON3_SUPPORTED_VERSIONS[@]}")
+				python_minimal_version="${minimal_version}"
+				python_maximal_version="${maximal_version}"
+			fi
+
+			if [[ -n "${minimal_version}" ]] && ! has "${minimal_version}" "${python_versions[@]}"; then
+				die "Invalid syntax of PYTHON_DEPEND: Unrecognized minimal version '${minimal_version}'"
+			fi
+			if [[ -n "${maximal_version}" ]] && ! has "${maximal_version}" "${python_versions[@]}"; then
+				die "Invalid syntax of PYTHON_DEPEND: Unrecognized maximal version '${maximal_version}'"
+			fi
+
+			if [[ -n "${minimal_version}" && -n "${maximal_version}" && "${minimal_version}" > "${maximal_version}" ]]; then
+				die "Invalid syntax of PYTHON_DEPEND: Minimal version '${minimal_version}' greater than maximal version '${maximal_version}'"
+			fi
+		done <<< "${version_components_groups}"
+
+		_create_accepted_versions_range() {
+			local accepted_version="0" i
+			for ((i = "${#python_versions[@]}"; i >= 0; i--)); do
+				if [[ "${python_versions[${i}]}" == "${python_maximal_version}" ]]; then
+					accepted_version="1"
+				fi
+				if [[ "${accepted_version}" == "1" ]]; then
+					accepted_versions+=("${python_versions[${i}]}")
+				fi
+				if [[ "${python_versions[${i}]}" == "${python_minimal_version}" ]]; then
+					accepted_version="0"
+				fi
+			done
+		}
+
+		if [[ "${python_all}" == "1" ]]; then
+			python_versions=("${_PYTHON2_SUPPORTED_VERSIONS[@]}" "${_PYTHON3_SUPPORTED_VERSIONS[@]}")
+			python_minimal_version="${python_minimal_version:-${python_versions[0]}}"
+			python_maximal_version="${python_maximal_version:-${python_versions[${#python_versions[@]}-1]}}"
+			_create_accepted_versions_range
+		else
+			if [[ "${python3}" == "1" ]]; then
+				python_versions=("${_PYTHON3_SUPPORTED_VERSIONS[@]}")
+				python_minimal_version="${python3_minimal_version:-${python_versions[0]}}"
+				python_maximal_version="${python3_maximal_version:-${python_versions[${#python_versions[@]}-1]}}"
+				_create_accepted_versions_range
+			fi
+			if [[ "${python2}" == "1" ]]; then
+				python_versions=("${_PYTHON2_SUPPORTED_VERSIONS[@]}")
+				python_minimal_version="${python2_minimal_version:-${python_versions[0]}}"
+				python_maximal_version="${python2_maximal_version:-${python_versions[${#python_versions[@]}-1]}}"
+				_create_accepted_versions_range
+			fi
+		fi
+
+		for accepted_version in "${accepted_versions[@]}"; do
+			python_atoms+="${python_atoms:+ }=dev-lang/python-${accepted_version}*"
+		done
+
+		_PYTHON_ATOMS="${python_atoms// /$'\n'}"
+		DEPEND+="${DEPEND:+ }${USE_flag}${USE_flag:+? ( }|| ( ${python_atoms} )${USE_flag:+ )}"
+		RDEPEND+="${RDEPEND:+ }${USE_flag}${USE_flag:+? ( }|| ( ${python_atoms} )${USE_flag:+ )}"
+	else
+		die "Invalid syntax of PYTHON_DEPEND"
+	fi
+}
+
+DEPEND=">=app-admin/eselect-python-20090804"
+RDEPEND="${DEPEND}"
+
+if [[ -n "${PYTHON_DEPEND}" && -n "${NEED_PYTHON}" ]]; then
+	die "PYTHON_DEPEND and NEED_PYTHON cannot be set simultaneously"
+elif [[ -n "${PYTHON_DEPEND}" ]]; then
+	_parse_PYTHON_DEPEND
+elif [[ -n "${NEED_PYTHON}" ]]; then
+	if ! has "${EAPI:-0}" 0 1 2; then
+		eerror "Use PYTHON_DEPEND instead of NEED_PYTHON."
+		die "NEED_PYTHON cannot be used in this EAPI"
+	fi
+	_PYTHON_ATOMS=">=dev-lang/python-${NEED_PYTHON}"
+	DEPEND+="${DEPEND:+ }${_PYTHON_ATOMS}"
+	RDEPEND+="${RDEPEND:+ }${_PYTHON_ATOMS}"
 else
-	PYTHON_ATOM="dev-lang/python"
+	_PYTHON_ATOMS="dev-lang/python"
 fi
 
-DEPEND+=" >=app-admin/eselect-python-20090804"
-
 # @ECLASS-VARIABLE: PYTHON_USE_WITH
 # @DESCRIPTION:
-# Set this to a space separated list of use flags
-# the python slot in use must be built with.
+# Set this to a space separated list of USE flags the Python slot in use must be built with.
 
 # @ECLASS-VARIABLE: PYTHON_USE_WITH_OR
 # @DESCRIPTION:
-# Set this to a space separated list of use flags
-# of which one must be turned on for the slot of
-# in use.
+# Set this to a space separated list of USE flags of which one must be turned on for the slot in use.
 
 # @ECLASS-VARIABLE: PYTHON_USE_WITH_OPT
 # @DESCRIPTION:
-# Set this if you need to make either PYTHON_USE_WITH or
-# PYTHON_USE_WITH_OR atoms conditional under a use flag.
+# Set this to a name of a USE flag if you need to make either PYTHON_USE_WITH or
+# PYTHON_USE_WITH_OR atoms conditional under a USE flag.
 
 # @FUNCTION: python_pkg_setup
 # @DESCRIPTION:
@@ -88,23 +214,31 @@
 
 	EXPORT_FUNCTIONS pkg_setup
 
+	_PYTHON_USE_WITH_ATOM=""
 	if [[ -n "${PYTHON_USE_WITH}" ]]; then
-		PYTHON_USE_WITH_ATOM="${PYTHON_ATOM}[${PYTHON_USE_WITH/ /,}]"
+		while read _PYTHON_ATOM; do
+			_PYTHON_USE_WITH_ATOM+="${_PYTHON_USE_WITH_ATOM:+ }${_PYTHON_ATOM}[${PYTHON_USE_WITH/ /,}]"
+		done <<< "${_PYTHON_ATOMS}"
+		_PYTHON_USE_WITH_ATOM="|| ( ${_PYTHON_USE_WITH_ATOM} )"
 	elif [[ -n "${PYTHON_USE_WITH_OR}" ]]; then
-		PYTHON_USE_WITH_ATOM="|| ( "
-		for use in ${PYTHON_USE_WITH_OR}; do
-			PYTHON_USE_WITH_ATOM+=" ${PYTHON_ATOM}[${use}]"
+		for _USE_flag in ${PYTHON_USE_WITH_OR}; do
+			while read _PYTHON_ATOM; do
+				_PYTHON_USE_WITH_ATOM+="${_PYTHON_USE_WITH_ATOM:+ }${_PYTHON_ATOM}[${_USE_flag}]"
+			done <<< "${_PYTHON_ATOMS}"
 		done
-		unset use
-		PYTHON_USE_WITH_ATOM+=" )"
+		unset _USE_flag
+		_PYTHON_USE_WITH_ATOM="|| ( ${_PYTHON_USE_WITH_ATOM} )"
 	fi
 	if [[ -n "${PYTHON_USE_WITH_OPT}" ]]; then
-		PYTHON_USE_WITH_ATOM="${PYTHON_USE_WITH_OPT}? ( ${PYTHON_USE_WITH_ATOM} )"
+		_PYTHON_USE_WITH_ATOM="${PYTHON_USE_WITH_OPT}? ( ${_PYTHON_USE_WITH_ATOM} )"
 	fi
-	DEPEND+=" ${PYTHON_USE_WITH_ATOM}"
-	RDEPEND+=" ${PYTHON_USE_WITH_ATOM}"
+	DEPEND+=" ${_PYTHON_USE_WITH_ATOM}"
+	RDEPEND+=" ${_PYTHON_USE_WITH_ATOM}"
+	unset _PYTHON_ATOM _PYTHON_USE_WITH_ATOM
 fi
 
+unset _PYTHON_ATOMS
+
 # ================================================================================================
 # ======== FUNCTIONS FOR PACKAGES SUPPORTING INSTALLATION FOR MULTIPLE VERSIONS OF PYTHON ========
 # ================================================================================================
@@ -145,23 +279,21 @@
 	fi
 
 	# Ensure that /usr/bin/python and /usr/bin/python-config are valid.
-	if [[ "$(readlink /usr/bin/python)" != "python-wrapper" ]]; then
-		eerror "'/usr/bin/python' is not valid symlink."
+	if [[ "$(readlink "${EPREFIX}/usr/bin/python")" != "python-wrapper" ]]; then
+		eerror "'${EPREFIX}/usr/bin/python' is not valid symlink."
 		eerror "Use \`eselect python set \${python_interpreter}\` to fix this problem."
-		die "'/usr/bin/python' is not valid symlink"
+		die "'${EPREFIX}/usr/bin/python' is not valid symlink"
 	fi
-	if [[ "$(</usr/bin/python-config)" != *"Gentoo python-config wrapper script"* ]]; then
-		eerror "'/usr/bin/python-config' is not valid script"
+	if [[ "$(<"${EPREFIX}/usr/bin/python-config")" != *"Gentoo python-config wrapper script"* ]]; then
+		eerror "'${EPREFIX}/usr/bin/python-config' is not valid script"
 		eerror "Use \`eselect python set \${python_interpreter}\` to fix this problem."
-		die "'/usr/bin/python-config' is not valid script"
+		die "'${EPREFIX}/usr/bin/python-config' is not valid script"
 	fi
 
 	# USE_${ABI_TYPE^^} and RESTRICT_${ABI_TYPE^^}_ABIS variables hopefully will be included in EAPI >= 5.
 	if [[ "$(declare -p PYTHON_ABIS 2> /dev/null)" != "declare -x PYTHON_ABIS="* ]] && has "${EAPI:-0}" 0 1 2 3 4; then
-		local PYTHON_ABI python2_supported_versions python3_supported_versions restricted_ABI support_ABI supported_PYTHON_ABIS=
-		PYTHON_ABI_SUPPORTED_VALUES="2.4 2.5 2.6 2.7 3.0 3.1 3.2"
-		python2_supported_versions="2.4 2.5 2.6 2.7"
-		python3_supported_versions="3.0 3.1 3.2"
+		local PYTHON_ABI restricted_ABI support_ABI supported_PYTHON_ABIS=
+		PYTHON_ABI_SUPPORTED_VALUES="${_PYTHON2_SUPPORTED_VERSIONS[@]} ${_PYTHON3_SUPPORTED_VERSIONS[@]}"
 
 		if [[ "$(declare -p USE_PYTHON 2> /dev/null)" == "declare -x USE_PYTHON="* ]]; then
 			local python2_enabled="0" python3_enabled="0"
@@ -175,10 +307,10 @@
 					die "USE_PYTHON variable contains invalid value '${PYTHON_ABI}'"
 				fi
 
-				if has "${PYTHON_ABI}" ${python2_supported_versions}; then
+				if has "${PYTHON_ABI}" "${_PYTHON2_SUPPORTED_VERSIONS[@]}"; then
 					python2_enabled="1"
 				fi
-				if has "${PYTHON_ABI}" ${python3_supported_versions}; then
+				if has "${PYTHON_ABI}" "${_PYTHON3_SUPPORTED_VERSIONS[@]}"; then
 					python3_enabled="1"
 				fi
 
@@ -205,16 +337,16 @@
 		else
 			local python_version python2_version= python3_version= support_python_major_version
 
-			python_version="$(/usr/bin/python -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')"
+			python_version="$("${EPREFIX}/usr/bin/python" -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')"
 
 			if has_version "=dev-lang/python-2*"; then
-				if [[ "$(readlink /usr/bin/python2)" != "python2."* ]]; then
-					die "'/usr/bin/python2' is not valid symlink"
+				if [[ "$(readlink "${EPREFIX}/usr/bin/python2")" != "python2."* ]]; then
+					die "'${EPREFIX}/usr/bin/python2' is not valid symlink"
 				fi
 
-				python2_version="$(/usr/bin/python2 -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')"
+				python2_version="$("${EPREFIX}/usr/bin/python2" -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')"
 
-				for PYTHON_ABI in ${python2_supported_versions}; do
+				for PYTHON_ABI in "${_PYTHON2_SUPPORTED_VERSIONS[@]}"; do
 					support_python_major_version="1"
 					for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
 						if [[ "${PYTHON_ABI}" == ${restricted_ABI} ]]; then
@@ -235,13 +367,13 @@
 			fi
 
 			if has_version "=dev-lang/python-3*"; then
-				if [[ "$(readlink /usr/bin/python3)" != "python3."* ]]; then
-					die "'/usr/bin/python3' is not valid symlink"
+				if [[ "$(readlink "${EPREFIX}/usr/bin/python3")" != "python3."* ]]; then
+					die "'${EPREFIX}/usr/bin/python3' is not valid symlink"
 				fi
 
-				python3_version="$(/usr/bin/python3 -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')"
+				python3_version="$("${EPREFIX}/usr/bin/python3" -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')"
 
-				for PYTHON_ABI in ${python3_supported_versions}; do
+				for PYTHON_ABI in "${_PYTHON3_SUPPORTED_VERSIONS[@]}"; do
 					support_python_major_version="1"
 					for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
 						if [[ "${PYTHON_ABI}" == ${restricted_ABI} ]]; then
@@ -262,12 +394,12 @@
 			fi
 
 			if [[ -n "${python2_version}" && "${python_version}" == "2."* && "${python_version}" != "${python2_version}" ]]; then
-				eerror "Python wrapper is configured incorrectly or /usr/bin/python2 symlink"
+				eerror "Python wrapper is configured incorrectly or '${EPREFIX}/usr/bin/python2' symlink"
 				eerror "is set incorrectly. Use \`eselect python\` to fix configuration."
 				die "Incorrect configuration of Python"
 			fi
 			if [[ -n "${python3_version}" && "${python_version}" == "3."* && "${python_version}" != "${python3_version}" ]]; then
-				eerror "Python wrapper is configured incorrectly or /usr/bin/python3 symlink"
+				eerror "Python wrapper is configured incorrectly or '${EPREFIX}/usr/bin/python3' symlink"
 				eerror "is set incorrectly. Use \`eselect python\` to fix configuration."
 				die "Incorrect configuration of Python"
 			fi
@@ -307,7 +439,7 @@
 # Execute specified function for each value of PYTHON_ABIS, optionally passing additional
 # arguments. The specified function can use PYTHON_ABI and BUILDDIR variables.
 python_execute_function() {
-	local action action_message action_message_template= default_function="0" failure_message failure_message_template= function nonfatal="0" previous_directory previous_directory_stack previous_directory_stack_length PYTHON_ABI quiet="0" separate_build_dirs="0" source_dir=
+	local action action_message action_message_template= default_function="0" failure_message failure_message_template= function i nonfatal="0" previous_directory previous_directory_stack previous_directory_stack_length PYTHON_ABI quiet="0" separate_build_dirs="0" source_dir=
 
 	while (($#)); do
 		case "$1" in
@@ -336,6 +468,7 @@
 				shift
 				;;
 			--)
+				shift
 				break
 				;;
 			-*)
@@ -363,7 +496,7 @@
 			die "${FUNCNAME}(): '${function}' function is not defined"
 		fi
 	else
-		if [[ "$#" -ne "0" ]]; then
+		if [[ "$#" -ne 0 ]]; then
 			die "${FUNCNAME}(): '--default-function' option and function name cannot be specified simultaneously"
 		fi
 		if has "${EAPI:-0}" 0 1; then
@@ -402,6 +535,12 @@
 		function="python_default_function"
 	fi
 
+	for ((i = 1; i < "${#FUNCNAME[@]}"; i++)); do
+		if [[ "${FUNCNAME[${i}]}" == "python_execute_function" ]]; then
+			die "${FUNCNAME}(): Invalid call stack"
+		fi
+	done
+
 	if [[ "${quiet}" == "0" ]]; then
 		[[ "${EBUILD_PHASE}" == "setup" ]] && action="Setting up"
 		[[ "${EBUILD_PHASE}" == "unpack" ]] && action="Unpacking"
@@ -526,7 +665,7 @@
 # @FUNCTION: python_copy_sources
 # @USAGE: [--no-link] [--] [directory]
 # @DESCRIPTION:
-# Copy unpacked sources of given package for each Python ABI.
+# Copy unpacked sources of given package to separate build directory for each Python ABI.
 python_copy_sources() {
 	local dir dirs=() no_link="0" PYTHON_ABI
 
@@ -536,6 +675,7 @@
 				no_link="1"
 				;;
 			--)
+				shift
 				break
 				;;
 			-*)
@@ -591,9 +731,9 @@
 # If --respect-EPYTHON option is specified, then generated wrapper scripts will
 # respect EPYTHON variable at run time.
 python_generate_wrapper_scripts() {
-	local eselect_python_option file force="0" quiet="0" PYTHON_ABI python2_enabled="0" python2_supported_versions python3_enabled="0" python3_supported_versions respect_EPYTHON="0"
-	python2_supported_versions="2.4 2.5 2.6 2.7"
-	python3_supported_versions="3.0 3.1 3.2"
+	_python_initialize_prefix_variables
+
+	local eselect_python_option file force="0" quiet="0" PYTHON_ABI python2_enabled="0" python3_enabled="0" respect_EPYTHON="0"
 
 	while (($#)); do
 		case "$1" in
@@ -607,6 +747,7 @@
 				quiet="1"
 				;;
 			--)
+				shift
 				break
 				;;
 			-*)
@@ -624,12 +765,12 @@
 	fi
 
 	validate_PYTHON_ABIS
-	for PYTHON_ABI in ${python2_supported_versions}; do
+	for PYTHON_ABI in "${_PYTHON2_SUPPORTED_VERSIONS[@]}"; do
 		if has "${PYTHON_ABI}" ${PYTHON_ABIS}; then
 			python2_enabled="1"
 		fi
 	done
-	for PYTHON_ABI in ${python3_supported_versions}; do
+	for PYTHON_ABI in "${_PYTHON3_SUPPORTED_VERSIONS[@]}"; do
 		if has "${PYTHON_ABI}" ${PYTHON_ABIS}; then
 			python3_enabled="1"
 		fi
@@ -681,7 +822,7 @@
 		sys.exit(1)
 else:
 	try:
-		eselect_process = subprocess.Popen(["/usr/bin/eselect", "python", "show"${eselect_python_option:+, $(echo "\"")}${eselect_python_option}${eselect_python_option:+$(echo "\"")}], stdout=subprocess.PIPE)
+		eselect_process = subprocess.Popen(["${EPREFIX}/usr/bin/eselect", "python", "show"${eselect_python_option:+, $(echo "\"")}${eselect_python_option}${eselect_python_option:+$(echo "\"")}], stdout=subprocess.PIPE)
 		if eselect_process.wait() != 0:
 			raise ValueError
 	except (OSError, ValueError):
@@ -706,7 +847,7 @@
 		else
 			cat << EOF >> "${file}"
 try:
-	eselect_process = subprocess.Popen(["/usr/bin/eselect", "python", "show"${eselect_python_option:+, $(echo "\"")}${eselect_python_option}${eselect_python_option:+$(echo "\"")}], stdout=subprocess.PIPE)
+	eselect_process = subprocess.Popen(["${EPREFIX}/usr/bin/eselect", "python", "show"${eselect_python_option:+, $(echo "\"")}${eselect_python_option}${eselect_python_option:+$(echo "\"")}], stdout=subprocess.PIPE)
 	if eselect_process.wait() != 0:
 		raise ValueError
 except (OSError, ValueError):
@@ -742,7 +883,7 @@
 		if [[ "$?" != "0" ]]; then
 			die "${FUNCNAME}(): Generation of '$1' failed"
 		fi
-		fperms +x "${file#${D%/}}" || die "fperms '${file}' failed"
+		fperms +x "${file#${ED%/}}" || die "fperms '${file}' failed"
 	done
 }
 
@@ -755,7 +896,7 @@
 # @DESCRIPTION:
 # Set active version of Python.
 python_set_active_version() {
-	if [[ "$#" -ne "1" ]]; then
+	if [[ "$#" -ne 1 ]]; then
 		die "${FUNCNAME}() requires 1 argument"
 	fi
 
@@ -782,6 +923,9 @@
 	# so it does not need to be exported to subprocesses.
 	PYTHON_ABI="${EPYTHON#python}"
 	PYTHON_ABI="${PYTHON_ABI%%-*}"
+
+	# python-updater checks PYTHON_REQUESTED_ACTIVE_VERSION variable.
+	PYTHON_REQUESTED_ACTIVE_VERSION="$1"
 }
 
 # @FUNCTION: python_need_rebuild
@@ -800,7 +944,7 @@
 # @FUNCTION: PYTHON
 # @USAGE: [-2] [-3] [--ABI] [-A|--active] [-a|--absolute-path] [-f|--final-ABI] [--] <Python_ABI="${PYTHON_ABI}">
 # @DESCRIPTION:
-# Get Python interpreter filename for specified Python ABI. If Python_ABI argument
+# Print Python interpreter filename for specified Python ABI. If Python_ABI argument
 # is ommitted, then PYTHON_ABI environment variable must be set and is used.
 # If -2 option is specified, then active version of Python 2 is used.
 # If -3 option is specified, then active version of Python 3 is used.
@@ -835,6 +979,7 @@
 				final_ABI="1"
 				;;
 			--)
+				shift
 				break
 				;;
 			-*)
@@ -860,7 +1005,7 @@
 			if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
 				die "${FUNCNAME}(): '--active' option cannot be used in ebuilds of packages supporting installation for multiple versions of Python"
 			fi
-			slot="$(/usr/bin/python -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')"
+			slot="$("${EPREFIX}/usr/bin/python" -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')"
 		elif [[ "${final_ABI}" == "1" ]]; then
 			if has "${EAPI:-0}" 0 1 2 3 4 && [[ -z "${SUPPORT_PYTHON_ABIS}" ]]; then
 				die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple versions of Python"
@@ -910,7 +1055,7 @@
 		echo -n "${slot}"
 		return
 	elif [[ "${absolute_path_output}" == "1" ]]; then
-		echo -n "/usr/bin/python${slot}"
+		echo -n "${EPREFIX}/usr/bin/python${slot}"
 	else
 		echo -n "python${slot}"
 	fi
@@ -923,7 +1068,7 @@
 # @FUNCTION: python_get_includedir
 # @USAGE: [-f|--final-ABI]
 # @DESCRIPTION:
-# Print Python include directory.
+# Print path to Python include directory.
 # If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
 python_get_includedir() {
 	local final_ABI="0"
@@ -955,7 +1100,7 @@
 # @FUNCTION: python_get_libdir
 # @USAGE: [-f|--final-ABI]
 # @DESCRIPTION:
-# Print Python library directory.
+# Print path to Python library directory.
 # If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
 python_get_libdir() {
 	local final_ABI="0"
@@ -987,7 +1132,7 @@
 # @FUNCTION: python_get_sitedir
 # @USAGE: [-f|--final-ABI]
 # @DESCRIPTION:
-# Print Python site-packages directory.
+# Print path to Python site-packages directory.
 # If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
 python_get_sitedir() {
 	local options=()
@@ -1010,6 +1155,103 @@
 	echo "$(python_get_libdir "${options[@]}")/site-packages"
 }
 
+# @FUNCTION: python_get_library
+# @USAGE: [-f|--final-ABI] [-l|--linker-option]
+# @DESCRIPTION:
+# Print path to Python library.
+# If --linker-option is specified, then "-l${library}" linker option is printed.
+# If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
+python_get_library() {
+	local final_ABI="0" linker_option="0" python_version
+
+	while (($#)); do
+		case "$1" in
+			-f|--final-ABI)
+				final_ABI="1"
+				;;
+			-l|--linker-option)
+				linker_option="1"
+				;;
+			-*)
+				die "${FUNCNAME}(): Unrecognized option '$1'"
+				;;
+			*)
+				die "${FUNCNAME}(): Invalid usage"
+				;;
+		esac
+		shift
+	done
+
+	if [[ "${final_ABI}" == "1" ]]; then
+		python_version="$(PYTHON -f --ABI)"
+	elif [[ -n "${PYTHON_ABI}" ]]; then
+		python_version="${PYTHON_ABI}"
+	else
+		python_version="$(PYTHON -A --ABI)"
+	fi
+
+	if [[ "${linker_option}" == "1" ]]; then
+		echo "-lpython${python_version}"
+	else
+		echo "/usr/$(get_libdir)/libpython${python_version}$(get_libname)"
+	fi
+}
+
+# @FUNCTION: python_get_version
+# @USAGE: [-f|--final-ABI] [--major] [--minor] [--micro]
+# @DESCRIPTION:
+# Print Python version.
+# --major, --minor and --micro options cannot be specified simultaneously.
+# If --major, --minor and --micro options are not specified, then "${major_version}.${minor_version}" is printed.
+# If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
+python_get_version() {
+	local final_ABI="0" major="0" minor="0" micro="0" python_command
+
+	while (($#)); do
+		case "$1" in
+			-f|--final-ABI)
+				final_ABI="1"
+				;;
+			--major)
+				major="1"
+				;;
+			--minor)
+				minor="1"
+				;;
+			--micro)
+				micro="1"
+				;;
+			-*)
+				die "${FUNCNAME}(): Unrecognized option '$1'"
+				;;
+			*)
+				die "${FUNCNAME}(): Invalid usage"
+				;;
+		esac
+		shift
+	done
+
+	if [[ "$((${major} + ${minor} + ${micro}))" -gt 1 ]]; then
+		die "${FUNCNAME}(): '--major', '--minor' or '--micro' options cannot be specified simultaneously"
+	fi
+
+	if [[ "${major}" == "1" ]]; then
+		python_command="from sys import version_info; print(version_info[0])"
+	elif [[ "${minor}" == "1" ]]; then
+		python_command="from sys import version_info; print(version_info[1])"
+	elif [[ "${micro}" == "1" ]]; then
+		python_command="from sys import version_info; print(version_info[2])"
+	else
+		python_command="from sys import version_info; print('.'.join([str(x) for x in version_info[:2]]))"
+	fi
+
+	if [[ "${final_ABI}" == "1" ]]; then
+		"$(PYTHON -f)" -c "${python_command}"
+	else
+		"$(PYTHON "${PYTHON_ABI--A}")" -c "${python_command}"
+	fi
+}
+
 # ================================================================================================
 # =================================== MISCELLANEOUS FUNCTIONS ====================================
 # ================================================================================================
@@ -1022,6 +1264,17 @@
 	fi
 }
 
+_python_initialize_prefix_variables() {
+	if has "${EAPI:-0}" 0 1 2; then
+		if [[ -n "${ROOT}" && -z "${EROOT}" ]]; then
+			EROOT="${ROOT%/}${EPREFIX}/"
+		fi
+		if [[ -n "${D}" && -z "${ED}" ]]; then
+			ED="${D%/}${EPREFIX}/"
+		fi
+	fi
+}
+
 # @FUNCTION: python_convert_shebangs
 # @USAGE: [-q|--quiet] [-r|--recursive] [-x|--only-executables] [--] <Python_version> <file|directory> [files|directories]
 # @DESCRIPTION:
@@ -1041,6 +1294,7 @@
 				only_executables="1"
 				;;
 			--)
+				shift
 				break
 				;;
 			-*)
@@ -1101,8 +1355,8 @@
 # @FUNCTION: python_mod_exists
 # @USAGE: <module>
 # @DESCRIPTION:
-# Run with the module name as an argument. it will check if a
-# python module is installed and loadable. it will return
+# Run with the module name as an argument. It will check if a
+# Python module is installed and loadable. It will return
 # TRUE(0) if the module exists, and FALSE(1) if the module does
 # not exist.
 #
@@ -1111,21 +1365,210 @@
 #             echo "gtk support enabled"
 #         fi
 python_mod_exists() {
-	[[ "$1" ]] || die "${FUNCNAME} requires an argument!"
-	python -c "import $1" &>/dev/null
+	if [[ "$#" -ne 1 ]]; then
+		die "${FUNCNAME}() requires 1 argument"
+	fi
+	"$(PYTHON "${PYTHON_ABI--A}")" -c "import $1" &> /dev/null
 }
 
 # @FUNCTION: python_tkinter_exists
 # @DESCRIPTION:
-# Run without arguments, checks if python was compiled with Tkinter
+# Run without arguments, checks if Python was compiled with Tkinter
 # support.  If not, prints an error message and dies.
 python_tkinter_exists() {
-	if ! python -c "import Tkinter" >/dev/null 2>&1; then
-		eerror "You need to recompile python with Tkinter support."
-		eerror "Try adding: 'dev-lang/python tk'"
-		eerror "in to /etc/portage/package.use"
-		echo
-		die "missing tkinter support with installed python"
+	if ! "$(PYTHON "${PYTHON_ABI--A}")" -c "from sys import version_info
+if version_info[0] == 3:
+	import tkinter
+else:
+	import Tkinter" &> /dev/null; then
+		eerror "Python needs to be rebuilt with tkinter support enabled."
+		eerror "Add the following line to '${EPREFIX}/etc/portage/package.use' and rebuild Python"
+		eerror "dev-lang/python tk"
+		die "Python installed without support for tkinter"
+	fi
+}
+
+# ================================================================================================
+# ================================ FUNCTIONS FOR RUNNING OF TESTS ================================
+# ================================================================================================
+
+# @ECLASS-VARIABLE: PYTHON_TEST_VERBOSITY
+# @DESCRIPTION:
+# User-configurable verbosity of tests of Python modules.
+# Supported values: 0, 1, 2, 3, 4.
+PYTHON_TEST_VERBOSITY="${PYTHON_TEST_VERBOSITY:-1}"
+
+# @FUNCTION: python_execute_nosetests
+# @USAGE: [-P|--PYTHONPATH PYTHONPATH] [-s|--separate-build-dirs] [--] [arguments]
+# @DESCRIPTION:
+# Execute nosetests for all enabled versions of Python.
+python_execute_nosetests() {
+	local PYTHONPATH_template= separate_build_dirs=
+
+	while (($#)); do
+		case "$1" in
+			-P|--PYTHONPATH)
+				PYTHONPATH_template="$2"
+				shift
+				;;
+			-s|--separate-build-dirs)
+				separate_build_dirs="1"
+				;;
+			--)
+				shift
+				break
+				;;
+			-*)
+				die "${FUNCNAME}(): Unrecognized option '$1'"
+				;;
+			*)
+				break
+				;;
+		esac
+		shift
+	done
+
+	python_test_function() {
+		local evaluated_PYTHONPATH=
+
+		if [[ -n "${PYTHONPATH_template}" ]]; then
+			evaluated_PYTHONPATH="$(eval echo -n "${PYTHONPATH_template}")"
+			if [[ ! -e "${evaluated_PYTHONPATH}" ]]; then
+				unset evaluated_PYTHONPATH
+			fi
+		fi
+
+		if [[ -n "${evaluated_PYTHONPATH}" ]]; then
+			echo PYTHONPATH="${evaluated_PYTHONPATH}" nosetests --verbosity="${PYTHON_TEST_VERBOSITY}" "$@"
+			PYTHONPATH="${evaluated_PYTHONPATH}" nosetests --verbosity="${PYTHON_TEST_VERBOSITY}" "$@"
+		else
+			echo nosetests --verbosity="${PYTHON_TEST_VERBOSITY}" "$@"
+			nosetests --verbosity="${PYTHON_TEST_VERBOSITY}" "$@"
+		fi
+	}
+	if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
+		python_execute_function ${separate_build_dirs:+-s} python_test_function "$@"
+	else
+		if [[ -n "${separate_build_dirs}" ]]; then
+			die "${FUNCNAME}(): Invalid usage"
+		fi
+		python_test_function "$@"
+	fi
+}
+
+# @FUNCTION: python_execute_py.test
+# @USAGE: [-P|--PYTHONPATH PYTHONPATH] [-s|--separate-build-dirs] [--] [arguments]
+# @DESCRIPTION:
+# Execute py.test for all enabled versions of Python.
+python_execute_py.test() {
+	local PYTHONPATH_template= separate_build_dirs=
+
+	while (($#)); do
+		case "$1" in
+			-P|--PYTHONPATH)
+				PYTHONPATH_template="$2"
+				shift
+				;;
+			-s|--separate-build-dirs)
+				separate_build_dirs="1"
+				;;
+			--)
+				shift
+				break
+				;;
+			-*)
+				die "${FUNCNAME}(): Unrecognized option '$1'"
+				;;
+			*)
+				break
+				;;
+		esac
+		shift
+	done
+
+	python_test_function() {
+		local evaluated_PYTHONPATH=
+
+		if [[ -n "${PYTHONPATH_template}" ]]; then
+			evaluated_PYTHONPATH="$(eval echo -n "${PYTHONPATH_template}")"
+			if [[ ! -e "${evaluated_PYTHONPATH}" ]]; then
+				unset evaluated_PYTHONPATH
+			fi
+		fi
+
+		if [[ -n "${evaluated_PYTHONPATH}" ]]; then
+			echo PYTHONPATH="${evaluated_PYTHONPATH}" py.test $([[ "${PYTHON_TEST_VERBOSITY}" -ge 2 ]] && echo -v) "$@"
+			PYTHONPATH="${evaluated_PYTHONPATH}" py.test $([[ "${PYTHON_TEST_VERBOSITY}" -ge 2 ]] && echo -v) "$@"
+		else
+			echo py.test $([[ "${PYTHON_TEST_VERBOSITY}" -gt 1 ]] && echo -v) "$@"
+			py.test $([[ "${PYTHON_TEST_VERBOSITY}" -gt 1 ]] && echo -v) "$@"
+		fi
+	}
+	if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
+		python_execute_function ${separate_build_dirs:+-s} python_test_function "$@"
+	else
+		if [[ -n "${separate_build_dirs}" ]]; then
+			die "${FUNCNAME}(): Invalid usage"
+		fi
+		python_test_function "$@"
+	fi
+}
+
+# @FUNCTION: python_execute_trial
+# @USAGE: [-P|--PYTHONPATH PYTHONPATH] [-s|--separate-build-dirs] [--] [arguments]
+# @DESCRIPTION:
+# Execute trial for all enabled versions of Python.
+python_execute_trial() {
+	local PYTHONPATH_template= separate_build_dirs=
+
+	while (($#)); do
+		case "$1" in
+			-P|--PYTHONPATH)
+				PYTHONPATH_template="$2"
+				shift
+				;;
+			-s|--separate-build-dirs)
+				separate_build_dirs="1"
+				;;
+			--)
+				shift
+				break
+				;;
+			-*)
+				die "${FUNCNAME}(): Unrecognized option '$1'"
+				;;
+			*)
+				break
+				;;
+		esac
+		shift
+	done
+
+	python_test_function() {
+		local evaluated_PYTHONPATH=
+
+		if [[ -n "${PYTHONPATH_template}" ]]; then
+			evaluated_PYTHONPATH="$(eval echo -n "${PYTHONPATH_template}")"
+			if [[ ! -e "${evaluated_PYTHONPATH}" ]]; then
+				unset evaluated_PYTHONPATH
+			fi
+		fi
+
+		if [[ -n "${evaluated_PYTHONPATH}" ]]; then
+			echo PYTHONPATH="${evaluated_PYTHONPATH}" trial $([[ "${PYTHON_TEST_VERBOSITY}" -ge 4 ]] && echo --spew) "$@"
+			PYTHONPATH="${evaluated_PYTHONPATH}" trial $([[ "${PYTHON_TEST_VERBOSITY}" -ge 4 ]] && echo --spew) "$@"
+		else
+			echo trial $([[ "${PYTHON_TEST_VERBOSITY}" -ge 4 ]] && echo --spew) "$@"
+			trial $([[ "${PYTHON_TEST_VERBOSITY}" -ge 4 ]] && echo --spew) "$@"
+		fi
+	}
+	if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
+		python_execute_function ${separate_build_dirs:+-s} python_test_function "$@"
+	else
+		if [[ -n "${separate_build_dirs}" ]]; then
+			die "${FUNCNAME}(): Invalid usage"
+		fi
+		python_test_function "$@"
 	fi
 }
 
@@ -1165,14 +1608,16 @@
 # Example:
 #         python_mod_optimize ctypesgencore
 python_mod_optimize() {
+	_python_initialize_prefix_variables
+
 	# Check if phase is pkg_postinst().
-	[[ ${EBUILD_PHASE} != "postinst" ]] && die "${FUNCNAME} should only be run in pkg_postinst()"
+	[[ ${EBUILD_PHASE} != "postinst" ]] && die "${FUNCNAME}() should only be run in pkg_postinst()"
 
 	if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
 		local dir file options=() other_dirs=() other_files=() previous_PYTHON_ABI="${PYTHON_ABI}" PYTHON_ABI return_code root site_packages_absolute_dirs=() site_packages_dirs=() site_packages_absolute_files=() site_packages_files=()
 
 		# Strip trailing slash from ROOT.
-		root="${ROOT%/}"
+		root="${EROOT%/}"
 
 		# Respect ROOT and options passed to compileall.py.
 		while (($#)); do
@@ -1185,11 +1630,11 @@
 					shift
 					;;
 				-*)
-					ewarn "${FUNCNAME}: Ignoring option '$1'"
+					ewarn "${FUNCNAME}(): Ignoring option '$1'"
 					;;
 				*)
-					if ! _python_implementation && [[ "$1" =~ ^/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then
-						die "${FUNCNAME} does not support absolute paths of directories/files in site-packages directories"
+					if ! _python_implementation && [[ "$1" =~ ^"${EPREFIX}"/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then
+						die "${FUNCNAME}() does not support absolute paths of directories/files in site-packages directories"
 					elif [[ "$1" =~ ^/ ]]; then
 						if [[ -d "${root}/$1" ]]; then
 							other_dirs+=("${root}/$1")
@@ -1270,7 +1715,7 @@
 		local myroot mydirs=() myfiles=() myopts=() return_code="0"
 
 		# strip trailing slash
-		myroot="${ROOT%/}"
+		myroot="${EROOT%/}"
 
 		# respect ROOT and options passed to compileall.py
 		while (($#)); do
@@ -1283,7 +1728,7 @@
 					shift
 					;;
 				-*)
-					ewarn "${FUNCNAME}: Ignoring option '$1'"
+					ewarn "${FUNCNAME}(): Ignoring option '$1'"
 					;;
 				*)
 					if [[ -d "${myroot}"/$1 ]]; then
@@ -1330,19 +1775,21 @@
 #
 # This function should only be run in pkg_postrm().
 python_mod_cleanup() {
+	_python_initialize_prefix_variables
+
 	local path py_file PYTHON_ABI SEARCH_PATH=() root
 
 	# Check if phase is pkg_postrm().
-	[[ ${EBUILD_PHASE} != "postrm" ]] && die "${FUNCNAME} should only be run in pkg_postrm()"
+	[[ ${EBUILD_PHASE} != "postrm" ]] && die "${FUNCNAME}() should only be run in pkg_postrm()"
 
 	# Strip trailing slash from ROOT.
-	root="${ROOT%/}"
+	root="${EROOT%/}"
 
 	if (($#)); then
 		if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
 			while (($#)); do
-				if ! _python_implementation && [[ "$1" =~ ^/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then
-					die "${FUNCNAME} does not support absolute paths of directories/files in site-packages directories"
+				if ! _python_implementation && [[ "$1" =~ ^"${EPREFIX}"/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then
+					die "${FUNCNAME}() does not support absolute paths of directories/files in site-packages directories"
 				elif [[ "$1" =~ ^/ ]]; then
 					SEARCH_PATH+=("${root}/${1#/}")
 				else
@@ -1409,9 +1856,14 @@
 # Run without arguments and it will export the version of python
 # currently in use as $PYVER; sets PYVER/PYVER_MAJOR/PYVER_MINOR
 python_version() {
+	if ! has "${EAPI:-0}" 0 1 2; then
+		eerror "Use PYTHON() and/or python_get_*() instead of python_version()."
+		die "${FUNCNAME}() cannot be used in this EAPI"
+	fi
+
 	[[ -n "${PYVER}" ]] && return 0
 	local tmpstr
-	python="${python:-/usr/bin/python}"
+	python="${python:-${EPREFIX}/usr/bin/python}"
 	tmpstr="$(EPYTHON= ${python} -V 2>&1 )"
 	export PYVER_ALL="${tmpstr#Python }"
 	export PYVER_MAJOR="${PYVER_ALL:0:1}"
@@ -1433,17 +1885,19 @@
 #
 python_mod_compile() {
 	if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
+		eerror "Use python_mod_optimize() instead of python_mod_compile()."
 		die "${FUNCNAME}() cannot be used in this EAPI"
 	fi
 
+	_python_initialize_prefix_variables
+
 	local f myroot myfiles=()
 
 	# Check if phase is pkg_postinst()
-	[[ ${EBUILD_PHASE} != postinst ]] &&\
-		die "${FUNCNAME} should only be run in pkg_postinst()"
+	[[ ${EBUILD_PHASE} != postinst ]] && die "${FUNCNAME}() should only be run in pkg_postinst()"
 
 	# strip trailing slash
-	myroot="${ROOT%/}"
+	myroot="${EROOT%/}"
 
 	# respect ROOT
 	for f in "$@"; do






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2010-02-11 18:52 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2010-02-11 18:52 UTC (permalink / raw
  To: gentoo-commits

arfrever    10/02/11 18:52:44

  Modified:             python.eclass
  Log:
  Add initial support for Jython.
  Improve dependencies generated by _parse_PYTHON_DEPEND().
  Fix and improve python_pkg_setup().
  Ensure that python_set_active_version() cannot be used in ebuilds of packages supporting installation for multiple versions of Python.
  Add _PYTHON_ABI_EXTRACTION_COMMAND, _python_get_implementation(), python_get_implementation() and python_get_implementational_package().
  Improve python_execute_nosetests(), python_execute_py.test() and python_execute_trial().

Revision  Changes    Path
1.88                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.88&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.88&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.87&r2=1.88

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.87
retrieving revision 1.88
diff -u -r1.87 -r1.88
--- python.eclass	2 Feb 2010 18:55:00 -0000	1.87
+++ python.eclass	11 Feb 2010 18:52:44 -0000	1.88
@@ -1,13 +1,13 @@
 # Copyright 1999-2010 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.87 2010/02/02 18:55:00 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.88 2010/02/11 18:52:44 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
-# python@gentoo.org
-# @BLURB: A utility eclass that should be inherited by anything that deals with Python or Python modules.
+# Gentoo Python Project <python@gentoo.org>
+# @BLURB: Eclass for Python packages
 # @DESCRIPTION:
-# Some useful functions for dealing with Python.
+# The python eclass contains miscellaneous, useful functions for Python packages.
 
 inherit multilib
 
@@ -15,8 +15,9 @@
 	die "API of python.eclass in EAPI=\"${EAPI}\" not established"
 fi
 
-_PYTHON2_SUPPORTED_VERSIONS=(2.4 2.5 2.6 2.7)
-_PYTHON3_SUPPORTED_VERSIONS=(3.0 3.1 3.2)
+_CPYTHON2_SUPPORTED_ABIS=(2.4 2.5 2.6 2.7)
+_CPYTHON3_SUPPORTED_ABIS=(3.0 3.1 3.2)
+_JYTHON_SUPPORTED_ABIS=(2.5-jython)
 
 # @ECLASS-VARIABLE: PYTHON_DEPEND
 # @DESCRIPTION:
@@ -29,7 +30,7 @@
 #   maximal_version:           <maximal_major_version.maximal_minor_version>
 
 _parse_PYTHON_DEPEND() {
-	local accepted_version accepted_versions=() major_version maximal_version minimal_version python_all="0" python_atoms= python_maximal_version python_minimal_version python_versions=() python2="0" python2_maximal_version python2_minimal_version python3="0" python3_maximal_version python3_minimal_version USE_flag= version_components_group version_components_group_regex version_components_groups
+	local major_version maximal_version minimal_version python_all="0" python_maximal_version python_minimal_version python_versions=() python2="0" python2_maximal_version python2_minimal_version python3="0" python3_maximal_version python3_minimal_version USE_flag= version_components_group version_components_group_regex version_components_groups
 
 	version_components_group_regex="(2|3|\*)(:([[:digit:]]+\.[[:digit:]]+)?(:([[:digit:]]+\.[[:digit:]]+)?)?)?"
 	version_components_groups="${PYTHON_DEPEND}"
@@ -61,17 +62,17 @@
 
 			if [[ "${major_version}" == "2" ]]; then
 				python2="1"
-				python_versions=("${_PYTHON2_SUPPORTED_VERSIONS[@]}")
+				python_versions=("${_CPYTHON2_SUPPORTED_ABIS[@]}")
 				python2_minimal_version="${minimal_version}"
 				python2_maximal_version="${maximal_version}"
 			elif [[ "${major_version}" == "3" ]]; then
 				python3="1"
-				python_versions=("${_PYTHON3_SUPPORTED_VERSIONS[@]}")
+				python_versions=("${_CPYTHON3_SUPPORTED_ABIS[@]}")
 				python3_minimal_version="${minimal_version}"
 				python3_maximal_version="${maximal_version}"
 			else
 				python_all="1"
-				python_versions=("${_PYTHON2_SUPPORTED_VERSIONS[@]}" "${_PYTHON3_SUPPORTED_VERSIONS[@]}")
+				python_versions=("${_CPYTHON2_SUPPORTED_ABIS[@]}" "${_CPYTHON3_SUPPORTED_ABIS[@]}")
 				python_minimal_version="${minimal_version}"
 				python_maximal_version="${maximal_version}"
 			fi
@@ -88,14 +89,16 @@
 			fi
 		done <<< "${version_components_groups}"
 
-		_create_accepted_versions_range() {
+		_PYTHON_ATOMS=()
+
+		_append_accepted_versions_range() {
 			local accepted_version="0" i
 			for ((i = "${#python_versions[@]}"; i >= 0; i--)); do
 				if [[ "${python_versions[${i}]}" == "${python_maximal_version}" ]]; then
 					accepted_version="1"
 				fi
 				if [[ "${accepted_version}" == "1" ]]; then
-					accepted_versions+=("${python_versions[${i}]}")
+					_PYTHON_ATOMS+=("=dev-lang/python-${python_versions[${i}]}*")
 				fi
 				if [[ "${python_versions[${i}]}" == "${python_minimal_version}" ]]; then
 					accepted_version="0"
@@ -104,32 +107,46 @@
 		}
 
 		if [[ "${python_all}" == "1" ]]; then
-			python_versions=("${_PYTHON2_SUPPORTED_VERSIONS[@]}" "${_PYTHON3_SUPPORTED_VERSIONS[@]}")
-			python_minimal_version="${python_minimal_version:-${python_versions[0]}}"
-			python_maximal_version="${python_maximal_version:-${python_versions[${#python_versions[@]}-1]}}"
-			_create_accepted_versions_range
+			if [[ -z "${python_minimal_version}" && -z "${python_maximal_version}" ]]; then
+				_PYTHON_ATOMS+=("dev-lang/python")
+			else
+				python_versions=("${_CPYTHON2_SUPPORTED_ABIS[@]}" "${_CPYTHON3_SUPPORTED_ABIS[@]}")
+				python_minimal_version="${python_minimal_version:-${python_versions[0]}}"
+				python_maximal_version="${python_maximal_version:-${python_versions[${#python_versions[@]}-1]}}"
+				_append_accepted_versions_range
+			fi
 		else
 			if [[ "${python3}" == "1" ]]; then
-				python_versions=("${_PYTHON3_SUPPORTED_VERSIONS[@]}")
-				python_minimal_version="${python3_minimal_version:-${python_versions[0]}}"
-				python_maximal_version="${python3_maximal_version:-${python_versions[${#python_versions[@]}-1]}}"
-				_create_accepted_versions_range
+				if [[ -z "${python3_minimal_version}" && -z "${python3_maximal_version}" ]]; then
+					_PYTHON_ATOMS+=("=dev-lang/python-3*")
+				else
+					python_versions=("${_CPYTHON3_SUPPORTED_ABIS[@]}")
+					python_minimal_version="${python3_minimal_version:-${python_versions[0]}}"
+					python_maximal_version="${python3_maximal_version:-${python_versions[${#python_versions[@]}-1]}}"
+					_append_accepted_versions_range
+				fi
 			fi
 			if [[ "${python2}" == "1" ]]; then
-				python_versions=("${_PYTHON2_SUPPORTED_VERSIONS[@]}")
-				python_minimal_version="${python2_minimal_version:-${python_versions[0]}}"
-				python_maximal_version="${python2_maximal_version:-${python_versions[${#python_versions[@]}-1]}}"
-				_create_accepted_versions_range
+				if [[ -z "${python2_minimal_version}" && -z "${python2_maximal_version}" ]]; then
+					_PYTHON_ATOMS+=("=dev-lang/python-2*")
+				else
+					python_versions=("${_CPYTHON2_SUPPORTED_ABIS[@]}")
+					python_minimal_version="${python2_minimal_version:-${python_versions[0]}}"
+					python_maximal_version="${python2_maximal_version:-${python_versions[${#python_versions[@]}-1]}}"
+					_append_accepted_versions_range
+				fi
 			fi
 		fi
 
-		for accepted_version in "${accepted_versions[@]}"; do
-			python_atoms+="${python_atoms:+ }=dev-lang/python-${accepted_version}*"
-		done
+		unset -f _append_accepted_versions_range
 
-		_PYTHON_ATOMS="${python_atoms// /$'\n'}"
-		DEPEND+="${DEPEND:+ }${USE_flag}${USE_flag:+? ( }|| ( ${python_atoms} )${USE_flag:+ )}"
-		RDEPEND+="${RDEPEND:+ }${USE_flag}${USE_flag:+? ( }|| ( ${python_atoms} )${USE_flag:+ )}"
+		if [[ "${#_PYTHON_ATOMS[@]}" -gt 1 ]]; then
+			DEPEND+="${DEPEND:+ }${USE_flag}${USE_flag:+? ( }|| ( ${_PYTHON_ATOMS[@]} )${USE_flag:+ )}"
+			RDEPEND+="${RDEPEND:+ }${USE_flag}${USE_flag:+? ( }|| ( ${_PYTHON_ATOMS[@]} )${USE_flag:+ )}"
+		else
+			DEPEND+="${DEPEND:+ }${USE_flag}${USE_flag:+? ( }${_PYTHON_ATOMS[@]}${USE_flag:+ )}"
+			RDEPEND+="${RDEPEND:+ }${USE_flag}${USE_flag:+? ( }${_PYTHON_ATOMS[@]}${USE_flag:+ )}"
+		fi
 	else
 		die "Invalid syntax of PYTHON_DEPEND"
 	fi
@@ -147,11 +164,11 @@
 		eerror "Use PYTHON_DEPEND instead of NEED_PYTHON."
 		die "NEED_PYTHON cannot be used in this EAPI"
 	fi
-	_PYTHON_ATOMS=">=dev-lang/python-${NEED_PYTHON}"
-	DEPEND+="${DEPEND:+ }${_PYTHON_ATOMS}"
-	RDEPEND+="${RDEPEND:+ }${_PYTHON_ATOMS}"
+	_PYTHON_ATOMS=(">=dev-lang/python-${NEED_PYTHON}")
+	DEPEND+="${DEPEND:+ }${_PYTHON_ATOMS[@]}"
+	RDEPEND+="${RDEPEND:+ }${_PYTHON_ATOMS[@]}"
 else
-	_PYTHON_ATOMS="dev-lang/python"
+	_PYTHON_ATOMS=("dev-lang/python")
 fi
 
 # @ECLASS-VARIABLE: PYTHON_USE_WITH
@@ -182,11 +199,7 @@
 
 		python_pkg_setup_check_USE_flags() {
 			local pyatom use
-			if [[ -n "${PYTHON_ABI}" ]]; then
-				pyatom="dev-lang/python:${PYTHON_ABI}"
-			else
-				pyatom="dev-lang/python:$(PYTHON -A --ABI)"
-			fi
+			pyatom="$(python_get_implementational_package)"
 
 			for use in ${PYTHON_USE_WITH}; do
 				if ! has_version "${pyatom}[${use}]"; then
@@ -205,26 +218,28 @@
 			fi
 		}
 
-		if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
+		if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
 			python_execute_function -q python_pkg_setup_check_USE_flags
 		else
 			python_pkg_setup_check_USE_flags
 		fi
+
+		unset -f python_pkg_setup_check_USE_flags python_pkg_setup_fail
 	}
 
 	EXPORT_FUNCTIONS pkg_setup
 
 	_PYTHON_USE_WITH_ATOM=""
 	if [[ -n "${PYTHON_USE_WITH}" ]]; then
-		while read _PYTHON_ATOM; do
+		for _PYTHON_ATOM in "${_PYTHON_ATOMS[@]}"; do
 			_PYTHON_USE_WITH_ATOM+="${_PYTHON_USE_WITH_ATOM:+ }${_PYTHON_ATOM}[${PYTHON_USE_WITH/ /,}]"
-		done <<< "${_PYTHON_ATOMS}"
+		done
 		_PYTHON_USE_WITH_ATOM="|| ( ${_PYTHON_USE_WITH_ATOM} )"
 	elif [[ -n "${PYTHON_USE_WITH_OR}" ]]; then
 		for _USE_flag in ${PYTHON_USE_WITH_OR}; do
-			while read _PYTHON_ATOM; do
+			for _PYTHON_ATOM in "${_PYTHON_ATOMS[@]}"; do
 				_PYTHON_USE_WITH_ATOM+="${_PYTHON_USE_WITH_ATOM:+ }${_PYTHON_ATOM}[${_USE_flag}]"
-			done <<< "${_PYTHON_ATOMS}"
+			done
 		done
 		unset _USE_flag
 		_PYTHON_USE_WITH_ATOM="|| ( ${_PYTHON_USE_WITH_ATOM} )"
@@ -245,7 +260,7 @@
 
 # @ECLASS-VARIABLE: SUPPORT_PYTHON_ABIS
 # @DESCRIPTION:
-# Set this in EAPI <= 4 to indicate that given package supports installation for
+# Set this in EAPI <= 4 to indicate that current package supports installation for
 # multiple versions of Python.
 
 # @ECLASS-VARIABLE: PYTHON_DEFINE_DEFAULT_FUNCTIONS
@@ -293,7 +308,7 @@
 	# USE_${ABI_TYPE^^} and RESTRICT_${ABI_TYPE^^}_ABIS variables hopefully will be included in EAPI >= 5.
 	if [[ "$(declare -p PYTHON_ABIS 2> /dev/null)" != "declare -x PYTHON_ABIS="* ]] && has "${EAPI:-0}" 0 1 2 3 4; then
 		local PYTHON_ABI restricted_ABI support_ABI supported_PYTHON_ABIS=
-		PYTHON_ABI_SUPPORTED_VALUES="${_PYTHON2_SUPPORTED_VERSIONS[@]} ${_PYTHON3_SUPPORTED_VERSIONS[@]}"
+		PYTHON_ABI_SUPPORTED_VALUES="${_CPYTHON2_SUPPORTED_ABIS[@]} ${_CPYTHON3_SUPPORTED_ABIS[@]} ${_JYTHON_SUPPORTED_ABIS[@]}"
 
 		if [[ "$(declare -p USE_PYTHON 2> /dev/null)" == "declare -x USE_PYTHON="* ]]; then
 			local python2_enabled="0" python3_enabled="0"
@@ -307,10 +322,10 @@
 					die "USE_PYTHON variable contains invalid value '${PYTHON_ABI}'"
 				fi
 
-				if has "${PYTHON_ABI}" "${_PYTHON2_SUPPORTED_VERSIONS[@]}"; then
+				if has "${PYTHON_ABI}" "${_CPYTHON2_SUPPORTED_ABIS[@]}"; then
 					python2_enabled="1"
 				fi
-				if has "${PYTHON_ABI}" "${_PYTHON3_SUPPORTED_VERSIONS[@]}"; then
+				if has "${PYTHON_ABI}" "${_CPYTHON3_SUPPORTED_ABIS[@]}"; then
 					python3_enabled="1"
 				fi
 
@@ -334,19 +349,22 @@
 			if [[ "${python3_enabled}" == "0" ]]; then
 				ewarn "USE_PYTHON variable does not enable any version of Python 3. This configuration is unsupported."
 			fi
+			if [[ "${python2_enabled}" == "0" && "${python3_enabled}" == "0" ]]; then
+				die "USE_PYTHON variable does not enable any version of CPython"
+			fi
 		else
 			local python_version python2_version= python3_version= support_python_major_version
 
-			python_version="$("${EPREFIX}/usr/bin/python" -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')"
+			python_version="$("${EPREFIX}/usr/bin/python" -c 'from sys import version_info; print(".".join(str(x) for x in version_info[:2]))')"
 
 			if has_version "=dev-lang/python-2*"; then
 				if [[ "$(readlink "${EPREFIX}/usr/bin/python2")" != "python2."* ]]; then
 					die "'${EPREFIX}/usr/bin/python2' is not valid symlink"
 				fi
 
-				python2_version="$("${EPREFIX}/usr/bin/python2" -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')"
+				python2_version="$("${EPREFIX}/usr/bin/python2" -c 'from sys import version_info; print(".".join(str(x) for x in version_info[:2]))')"
 
-				for PYTHON_ABI in "${_PYTHON2_SUPPORTED_VERSIONS[@]}"; do
+				for PYTHON_ABI in "${_CPYTHON2_SUPPORTED_ABIS[@]}"; do
 					support_python_major_version="1"
 					for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
 						if [[ "${PYTHON_ABI}" == ${restricted_ABI} ]]; then
@@ -371,9 +389,9 @@
 					die "'${EPREFIX}/usr/bin/python3' is not valid symlink"
 				fi
 
-				python3_version="$("${EPREFIX}/usr/bin/python3" -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')"
+				python3_version="$("${EPREFIX}/usr/bin/python3" -c 'from sys import version_info; print(".".join(str(x) for x in version_info[:2]))')"
 
-				for PYTHON_ABI in "${_PYTHON3_SUPPORTED_VERSIONS[@]}"; do
+				for PYTHON_ABI in "${_CPYTHON3_SUPPORTED_ABIS[@]}"; do
 					support_python_major_version="1"
 					for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
 						if [[ "${PYTHON_ABI}" == ${restricted_ABI} ]]; then
@@ -414,18 +432,18 @@
 		local PYTHON_ABI
 		for PYTHON_ABI in ${PYTHON_ABIS}; do
 			# Ensure that appropriate version of Python is installed.
-			if ! has_version "dev-lang/python:${PYTHON_ABI}"; then
-				die "dev-lang/python:${PYTHON_ABI} is not installed"
+			if ! has_version "$(python_get_implementational_package)"; then
+				die "$(python_get_implementational_package) is not installed"
 			fi
 
 			# Ensure that EPYTHON variable is respected.
-			if [[ "$(EPYTHON="$(PYTHON)" python -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')" != "${PYTHON_ABI}" ]]; then
+			if [[ "$(EPYTHON="$(PYTHON)" python -c "${_PYTHON_ABI_EXTRACTION_COMMAND}")" != "${PYTHON_ABI}" ]]; then
 				eerror "python:                    '$(type -p python)'"
 				eerror "ABI:                       '${ABI}'"
 				eerror "DEFAULT_ABI:               '${DEFAULT_ABI}'"
 				eerror "EPYTHON:                   '$(PYTHON)'"
 				eerror "PYTHON_ABI:                '${PYTHON_ABI}'"
-				eerror "Version of enabled Python: '$(EPYTHON="$(PYTHON)" python -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')'"
+				eerror "Version of enabled Python: '$(EPYTHON="$(PYTHON)" python -c "${_PYTHON_ABI_EXTRACTION_COMMAND}")'"
 				die "'python' does not respect EPYTHON variable"
 			fi
 		done
@@ -536,7 +554,7 @@
 	fi
 
 	for ((i = 1; i < "${#FUNCNAME[@]}"; i++)); do
-		if [[ "${FUNCNAME[${i}]}" == "python_execute_function" ]]; then
+		if [[ "${FUNCNAME[${i}]}" == "${FUNCNAME}" ]]; then
 			die "${FUNCNAME}(): Invalid call stack"
 		fi
 	done
@@ -574,7 +592,7 @@
 			if [[ -n "${action_message_template}" ]]; then
 				action_message="$(eval echo -n "${action_message_template}")"
 			else
-				action_message="${action} of ${CATEGORY}/${PF} with Python ${PYTHON_ABI}..."
+				action_message="${action} of ${CATEGORY}/${PF} with $(python_get_implementation) $(python_get_version)..."
 			fi
 			echo " ${GREEN}*${NORMAL} ${BLUE}${action_message}${NORMAL}"
 		fi
@@ -604,7 +622,7 @@
 			if [[ -n "${failure_message_template}" ]]; then
 				failure_message="$(eval echo -n "${failure_message_template}")"
 			else
-				failure_message="${action} failed with Python ${PYTHON_ABI} in ${function}() function"
+				failure_message="${action} failed with $(python_get_implementation) $(python_get_version) in ${function}() function"
 			fi
 
 			if [[ "${nonfatal}" == "1" ]]; then
@@ -665,7 +683,7 @@
 # @FUNCTION: python_copy_sources
 # @USAGE: [--no-link] [--] [directory]
 # @DESCRIPTION:
-# Copy unpacked sources of given package to separate build directory for each Python ABI.
+# Copy unpacked sources of current package to separate build directory for each Python ABI.
 python_copy_sources() {
 	local dir dirs=() no_link="0" PYTHON_ABI
 
@@ -765,12 +783,12 @@
 	fi
 
 	validate_PYTHON_ABIS
-	for PYTHON_ABI in "${_PYTHON2_SUPPORTED_VERSIONS[@]}"; do
+	for PYTHON_ABI in "${_CPYTHON2_SUPPORTED_ABIS[@]}"; do
 		if has "${PYTHON_ABI}" ${PYTHON_ABIS}; then
 			python2_enabled="1"
 		fi
 	done
-	for PYTHON_ABI in "${_PYTHON3_SUPPORTED_VERSIONS[@]}"; do
+	for PYTHON_ABI in "${_CPYTHON3_SUPPORTED_ABIS[@]}"; do
 		if has "${PYTHON_ABI}" ${PYTHON_ABIS}; then
 			python3_enabled="1"
 		fi
@@ -892,10 +910,14 @@
 # ================================================================================================
 
 # @FUNCTION: python_set_active_version
-# @USAGE: <Python_ABI|2|3>
+# @USAGE: <CPython_ABI|2|3>
 # @DESCRIPTION:
-# Set active version of Python.
+# Set specified version of CPython as active version of Python.
 python_set_active_version() {
+	if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
+		die "${FUNCNAME}() cannot be used in ebuilds of packages supporting installation for multiple versions of Python"
+	fi
+
 	if [[ "$#" -ne 1 ]]; then
 		die "${FUNCNAME}() requires 1 argument"
 	fi
@@ -929,10 +951,8 @@
 }
 
 # @FUNCTION: python_need_rebuild
-# @DESCRIPTION: Run without arguments, specifies that the package should be
-# rebuilt after a python upgrade.
-# Do not use this function in ebuilds of packages supporting installation
-# for multiple versions of Python.
+# @DESCRIPTION: Mark current package for rebuilding by python-updater after
+# switching of active version of Python.
 python_need_rebuild() {
 	export PYTHON_NEED_REBUILD="$(PYTHON -A --ABI)"
 }
@@ -941,10 +961,30 @@
 # ======================================= GETTER FUNCTIONS =======================================
 # ================================================================================================
 
+_PYTHON_ABI_EXTRACTION_COMMAND='import platform
+import sys
+sys.stdout.write(".".join(str(x) for x in sys.version_info[:2]))
+if platform.system()[:4] == "Java":
+	sys.stdout.write("-jython")'
+
+_python_get_implementation() {
+	if [[ "$#" -ne 1 ]]; then
+		die "${FUNCNAME}() requires 1 argument"
+	fi
+
+	if [[ "$1" =~ ^[[:digit:]]+\.[[:digit:]]+$ ]]; then
+		echo "CPython"
+	elif [[ "$1" =~ ^[[:digit:]]+\.[[:digit:]]+-jython$ ]]; then
+		echo "Jython"
+	else
+		die "${FUNCNAME}(): Unrecognized Python ABI '$1'"
+	fi
+}
+
 # @FUNCTION: PYTHON
 # @USAGE: [-2] [-3] [--ABI] [-A|--active] [-a|--absolute-path] [-f|--final-ABI] [--] <Python_ABI="${PYTHON_ABI}">
 # @DESCRIPTION:
-# Print Python interpreter filename for specified Python ABI. If Python_ABI argument
+# Print filename of Python interpreter for specified Python ABI. If Python_ABI argument
 # is ommitted, then PYTHON_ABI environment variable must be set and is used.
 # If -2 option is specified, then active version of Python 2 is used.
 # If -3 option is specified, then active version of Python 3 is used.
@@ -953,10 +993,11 @@
 # If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
 # -2, -3, --active and --final-ABI options and Python_ABI argument cannot be specified simultaneously.
 # If --ABI option is specified, then only specified Python ABI is printed instead of
-# Python interpreter filename.
+# filename of Python interpreter.
+# If --absolute-path option is specified, then absolute path to Python interpreter is printed.
 # --ABI and --absolute-path options cannot be specified simultaneously.
 PYTHON() {
-	local ABI_output="0" absolute_path_output="0" active="0" final_ABI="0" python2="0" python3="0" slot=
+	local ABI_output="0" absolute_path_output="0" active="0" final_ABI="0" PYTHON_ABI="${PYTHON_ABI}" python_interpreter python2="0" python3="0"
 
 	while (($#)); do
 		case "$1" in
@@ -1005,33 +1046,33 @@
 			if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
 				die "${FUNCNAME}(): '--active' option cannot be used in ebuilds of packages supporting installation for multiple versions of Python"
 			fi
-			slot="$("${EPREFIX}/usr/bin/python" -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')"
+			PYTHON_ABI="$("${EPREFIX}/usr/bin/python" -c "${_PYTHON_ABI_EXTRACTION_COMMAND}")"
 		elif [[ "${final_ABI}" == "1" ]]; then
 			if has "${EAPI:-0}" 0 1 2 3 4 && [[ -z "${SUPPORT_PYTHON_ABIS}" ]]; then
 				die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple versions of Python"
 			fi
 			validate_PYTHON_ABIS
-			slot="${PYTHON_ABIS##* }"
+			PYTHON_ABI="${PYTHON_ABIS##* }"
 		elif [[ "${python2}" == "1" ]]; then
-			slot="$(eselect python show --python2)"
-			if [[ -z "${slot}" ]]; then
+			# PYTHON_ABI="$(eselect python show --python2 --ABI)"
+			PYTHON_ABI="$(eselect python show --python2)"
+			if [[ -z "${PYTHON_ABI}" ]]; then
 				die "${FUNCNAME}(): Active Python 2 interpreter not set"
-			elif [[ "${slot}" != "python2."* ]]; then
+			elif [[ "${PYTHON_ABI}" != "python2."* ]]; then
 				die "${FUNCNAME}(): Internal error in \`eselect python show --python2\`"
 			fi
-			slot="${slot#python}"
+			PYTHON_ABI="${PYTHON_ABI#python}"
 		elif [[ "${python3}" == "1" ]]; then
-			slot="$(eselect python show --python3)"
-			if [[ -z "${slot}" ]]; then
+			# PYTHON_ABI="$(eselect python show --python3 --ABI)"
+			PYTHON_ABI="$(eselect python show --python3)"
+			if [[ -z "${PYTHON_ABI}" ]]; then
 				die "${FUNCNAME}(): Active Python 3 interpreter not set"
-			elif [[ "${slot}" != "python3."* ]]; then
+			elif [[ "${PYTHON_ABI}" != "python3."* ]]; then
 				die "${FUNCNAME}(): Internal error in \`eselect python show --python3\`"
 			fi
-			slot="${slot#python}"
-		elif [[ -n "${PYTHON_ABI}" ]]; then
-			slot="${PYTHON_ABI}"
-		else
-			die "${FUNCNAME}(): Invalid usage"
+			PYTHON_ABI="${PYTHON_ABI#python}"
+		elif [[ -z "${PYTHON_ABI}" ]]; then
+			die "${FUNCNAME}(): Invalid usage: Python ABI not specified"
 		fi
 	elif [[ "$#" -eq 1 ]]; then
 		if [[ "${active}" == "1" ]]; then
@@ -1046,18 +1087,26 @@
 		if [[ "${python3}" == "1" ]]; then
 			die "${FUNCNAME}(): '-3' option and Python ABI cannot be specified simultaneously"
 		fi
-		slot="$1"
+		PYTHON_ABI="$1"
 	else
 		die "${FUNCNAME}(): Invalid usage"
 	fi
 
 	if [[ "${ABI_output}" == "1" ]]; then
-		echo -n "${slot}"
+		echo -n "${PYTHON_ABI}"
 		return
-	elif [[ "${absolute_path_output}" == "1" ]]; then
-		echo -n "${EPREFIX}/usr/bin/python${slot}"
 	else
-		echo -n "python${slot}"
+		if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
+			python_interpreter="python${PYTHON_ABI}"
+		elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
+			python_interpreter="jython-${PYTHON_ABI%-jython}"
+		fi
+
+		if [[ "${absolute_path_output}" == "1" ]]; then
+			echo -n "${EPREFIX}/usr/bin/${python_interpreter}"
+		else
+			echo -n "${python_interpreter}"
+		fi
 	fi
 
 	if [[ -n "${ABI}" && "${ABI}" != "${DEFAULT_ABI}" && "${DEFAULT_ABI}" != "default" ]]; then
@@ -1065,13 +1114,81 @@
 	fi
 }
 
+# @FUNCTION: python_get_implementation
+# @USAGE: [-f|--final-ABI]
+# @DESCRIPTION:
+# Print name of Python implementation.
+# If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
+python_get_implementation() {
+	local final_ABI="0" PYTHON_ABI="${PYTHON_ABI}"
+
+	while (($#)); do
+		case "$1" in
+			-f|--final-ABI)
+				final_ABI="1"
+				;;
+			-*)
+				die "${FUNCNAME}(): Unrecognized option '$1'"
+				;;
+			*)
+				die "${FUNCNAME}(): Invalid usage"
+				;;
+		esac
+		shift
+	done
+
+	if [[ "${final_ABI}" == "1" ]]; then
+		PYTHON_ABI="$(PYTHON -f --ABI)"
+	elif [[ -z "${PYTHON_ABI}" ]]; then
+		PYTHON_ABI="$(PYTHON -A --ABI)"
+	fi
+
+	echo "$(_python_get_implementation "${PYTHON_ABI}")"
+}
+
+# @FUNCTION: python_get_implementational_package
+# @USAGE: [-f|--final-ABI]
+# @DESCRIPTION:
+# Print category, name and slot of package providing Python implementation.
+# If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
+python_get_implementational_package() {
+	local final_ABI="0" PYTHON_ABI="${PYTHON_ABI}"
+
+	while (($#)); do
+		case "$1" in
+			-f|--final-ABI)
+				final_ABI="1"
+				;;
+			-*)
+				die "${FUNCNAME}(): Unrecognized option '$1'"
+				;;
+			*)
+				die "${FUNCNAME}(): Invalid usage"
+				;;
+		esac
+		shift
+	done
+
+	if [[ "${final_ABI}" == "1" ]]; then
+		PYTHON_ABI="$(PYTHON -f --ABI)"
+	elif [[ -z "${PYTHON_ABI}" ]]; then
+		PYTHON_ABI="$(PYTHON -A --ABI)"
+	fi
+
+	if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
+		echo "dev-lang/python:${PYTHON_ABI}"
+	elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
+		echo "dev-java/jython:${PYTHON_ABI%-jython}"
+	fi
+}
+
 # @FUNCTION: python_get_includedir
 # @USAGE: [-f|--final-ABI]
 # @DESCRIPTION:
 # Print path to Python include directory.
 # If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
 python_get_includedir() {
-	local final_ABI="0"
+	local final_ABI="0" PYTHON_ABI="${PYTHON_ABI}"
 
 	while (($#)); do
 		case "$1" in
@@ -1089,11 +1206,15 @@
 	done
 
 	if [[ "${final_ABI}" == "1" ]]; then
-		echo "/usr/include/python$(PYTHON -f --ABI)"
-	elif [[ -n "${PYTHON_ABI}" ]]; then
+		PYTHON_ABI="$(PYTHON -f --ABI)"
+	elif [[ -z "${PYTHON_ABI}" ]]; then
+		PYTHON_ABI="$(PYTHON -A --ABI)"
+	fi
+
+	if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
 		echo "/usr/include/python${PYTHON_ABI}"
-	else
-		echo "/usr/include/python$(PYTHON -A --ABI)"
+	elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
+		echo "/usr/share/jython-${PYTHON_ABI%-jython}/Include"
 	fi
 }
 
@@ -1103,7 +1224,7 @@
 # Print path to Python library directory.
 # If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
 python_get_libdir() {
-	local final_ABI="0"
+	local final_ABI="0" PYTHON_ABI="${PYTHON_ABI}"
 
 	while (($#)); do
 		case "$1" in
@@ -1121,11 +1242,15 @@
 	done
 
 	if [[ "${final_ABI}" == "1" ]]; then
-		echo "/usr/$(get_libdir)/python$(PYTHON -f --ABI)"
-	elif [[ -n "${PYTHON_ABI}" ]]; then
+		PYTHON_ABI="$(PYTHON -f --ABI)"
+	elif [[ -z "${PYTHON_ABI}" ]]; then
+		PYTHON_ABI="$(PYTHON -A --ABI)"
+	fi
+
+	if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
 		echo "/usr/$(get_libdir)/python${PYTHON_ABI}"
-	else
-		echo "/usr/$(get_libdir)/python$(PYTHON -A --ABI)"
+	elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
+		echo "/usr/share/jython-${PYTHON_ABI%-jython}/Lib"
 	fi
 }
 
@@ -1162,7 +1287,7 @@
 # If --linker-option is specified, then "-l${library}" linker option is printed.
 # If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
 python_get_library() {
-	local final_ABI="0" linker_option="0" python_version
+	local final_ABI="0" linker_option="0" PYTHON_ABI="${PYTHON_ABI}"
 
 	while (($#)); do
 		case "$1" in
@@ -1183,17 +1308,19 @@
 	done
 
 	if [[ "${final_ABI}" == "1" ]]; then
-		python_version="$(PYTHON -f --ABI)"
-	elif [[ -n "${PYTHON_ABI}" ]]; then
-		python_version="${PYTHON_ABI}"
-	else
-		python_version="$(PYTHON -A --ABI)"
+		PYTHON_ABI="$(PYTHON -f --ABI)"
+	elif [[ -z "${PYTHON_ABI}" ]]; then
+		PYTHON_ABI="$(PYTHON -A --ABI)"
 	fi
 
-	if [[ "${linker_option}" == "1" ]]; then
-		echo "-lpython${python_version}"
-	else
-		echo "/usr/$(get_libdir)/libpython${python_version}$(get_libname)"
+	if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
+		if [[ "${linker_option}" == "1" ]]; then
+			echo "-lpython${PYTHON_ABI}"
+		else
+			echo "/usr/$(get_libdir)/libpython${PYTHON_ABI}$(get_libname)"
+		fi
+	elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
+		die "${FUNCNAME}(): Jython does not have shared library"
 	fi
 }
 
@@ -1242,7 +1369,7 @@
 	elif [[ "${micro}" == "1" ]]; then
 		python_command="from sys import version_info; print(version_info[2])"
 	else
-		python_command="from sys import version_info; print('.'.join([str(x) for x in version_info[:2]]))"
+		python_command="from sys import version_info; print('.'.join(str(x) for x in version_info[:2]))"
 	fi
 
 	if [[ "${final_ABI}" == "1" ]]; then
@@ -1259,6 +1386,8 @@
 _python_implementation() {
 	if [[ "${CATEGORY}/${PN}" == "dev-lang/python" ]]; then
 		return 0
+	elif [[ "${CATEGORY}/${PN}" == "dev-java/jython" ]]; then
+		return 0
 	else
 		return 1
 	fi
@@ -1452,8 +1581,10 @@
 		if [[ -n "${separate_build_dirs}" ]]; then
 			die "${FUNCNAME}(): Invalid usage"
 		fi
-		python_test_function "$@"
+		python_test_function "$@" || die "Testing failed"
 	fi
+
+	unset -f python_test_function
 }
 
 # @FUNCTION: python_execute_py.test
@@ -1510,8 +1641,10 @@
 		if [[ -n "${separate_build_dirs}" ]]; then
 			die "${FUNCNAME}(): Invalid usage"
 		fi
-		python_test_function "$@"
+		python_test_function "$@" || die "Testing failed"
 	fi
+
+	unset -f python_test_function
 }
 
 # @FUNCTION: python_execute_trial
@@ -1568,8 +1701,10 @@
 		if [[ -n "${separate_build_dirs}" ]]; then
 			die "${FUNCNAME}(): Invalid usage"
 		fi
-		python_test_function "$@"
+		python_test_function "$@" || die "Testing failed"
 	fi
+
+	unset -f python_test_function
 }
 
 # ================================================================================================
@@ -1671,20 +1806,24 @@
 		for PYTHON_ABI in ${PYTHON_ABIS-${PYTHON_ABI-$(PYTHON -A --ABI)}}; do
 			if ((${#site_packages_dirs[@]})) || ((${#site_packages_files[@]})); then
 				return_code="0"
-				ebegin "Compilation and optimization of Python modules for Python ${PYTHON_ABI}"
+				ebegin "Compilation and optimization of Python modules for $(python_get_implementation) $(python_get_version)"
 				if ((${#site_packages_dirs[@]})); then
 					for dir in "${site_packages_dirs[@]}"; do
 						site_packages_absolute_dirs+=("${root}$(python_get_sitedir)/${dir}")
 					done
 					"$(PYTHON)" "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${site_packages_absolute_dirs[@]}" || return_code="1"
-					"$(PYTHON)" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${site_packages_absolute_dirs[@]}" &> /dev/null || return_code="1"
+					if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
+						"$(PYTHON)" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${site_packages_absolute_dirs[@]}" &> /dev/null || return_code="1"
+					fi
 				fi
 				if ((${#site_packages_files[@]})); then
 					for file in "${site_packages_files[@]}"; do
 						site_packages_absolute_files+=("${root}$(python_get_sitedir)/${file}")
 					done
 					"$(PYTHON)" "${root}$(python_get_libdir)/py_compile.py" "${site_packages_absolute_files[@]}" || return_code="1"
-					"$(PYTHON)" -O "${root}$(python_get_libdir)/py_compile.py" "${site_packages_absolute_files[@]}" &> /dev/null || return_code="1"
+					if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
+						"$(PYTHON)" -O "${root}$(python_get_libdir)/py_compile.py" "${site_packages_absolute_files[@]}" &> /dev/null || return_code="1"
+					fi
 				fi
 				eend "${return_code}"
 			fi
@@ -1703,11 +1842,15 @@
 			ebegin "Compilation and optimization of Python modules placed outside of site-packages directories for Python $(PYTHON -A --ABI)"
 			if ((${#other_dirs[@]})); then
 				"$(PYTHON "${PYTHON_ABI--A}")" "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" || return_code="1"
-				"$(PYTHON "${PYTHON_ABI--A}")" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" &> /dev/null || return_code="1"
+				if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
+					"$(PYTHON "${PYTHON_ABI--A}")" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" &> /dev/null || return_code="1"
+				fi
 			fi
 			if ((${#other_files[@]})); then
 				"$(PYTHON "${PYTHON_ABI--A}")" "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" || return_code="1"
-				"$(PYTHON "${PYTHON_ABI--A}")" -O "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" &> /dev/null || return_code="1"
+				if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
+					"$(PYTHON "${PYTHON_ABI--A}")" -O "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" &> /dev/null || return_code="1"
+				fi
 			fi
 			eend "${return_code}"
 		fi
@@ -1814,6 +1957,11 @@
 				done
 			fi
 		done
+		for sitedir in "${root}"/usr/share/jython-*/Lib/site-packages; do
+			if [[ -d "${sitedir}" ]]; then
+				SEARCH_PATH+=("${sitedir}")
+			fi
+		done
 	fi
 
 	local BLUE CYAN NORMAL
@@ -1829,20 +1977,33 @@
 
 	for path in "${SEARCH_PATH[@]}"; do
 		if [[ -d "${path}" ]]; then
-			find "${path}" -name '*.py[co]' -print0 | while read -rd ''; do
-				py_file="${REPLY%[co]}"
-				[[ -f "${py_file}" || (! -f "${py_file}c" && ! -f "${py_file}o") ]] && continue
-				einfo "${BLUE}<<< ${py_file}[co]${NORMAL}"
-				rm -f "${py_file}"[co]
+			find "${path}" "(" -name "*.py[co]" -o -name "*\$py.class" ")" -print0 | while read -rd ''; do
+				if [[ "${REPLY}" == *[co] ]]; then
+					py_file="${REPLY%[co]}"
+					[[ -f "${py_file}" || (! -f "${py_file}c" && ! -f "${py_file}o") ]] && continue
+					einfo "${BLUE}<<< ${py_file}[co]${NORMAL}"
+					rm -f "${py_file}"[co]
+				elif [[ "${REPLY}" == *\$py.class ]]; then
+					py_file="${REPLY%\$py.class}.py"
+					[[ -f "${py_file}" || ! -f "${py_file%.py}\$py.class" ]] && continue
+					einfo "${BLUE}<<< ${py_file%.py}\$py.class${NORMAL}"
+					rm -f "${py_file%.py}\$py.class"
+				fi
 			done
 
 			# Attempt to delete directories, which may be empty.
 			find "${path}" -type d | sort -r | while read -r dir; do
 				rmdir "${dir}" 2>/dev/null && einfo "${CYAN}<<< ${dir}${NORMAL}"
 			done
-		elif [[ "${path}" == *.py && ! -f "${path}" && (-f "${path}c" || -f "${path}o") ]]; then
-			einfo "${BLUE}<<< ${path}[co]${NORMAL}"
-			rm -f "${path}"[co]
+		elif [[ "${path}" == *.py && ! -f "${path}" ]]; then
+			if [[ (-f "${path}c" || -f "${path}o") ]]; then
+				einfo "${BLUE}<<< ${path}[co]${NORMAL}"
+				rm -f "${path}"[co]
+			fi
+			if [[ -f "${path%.py}\$py.class" ]]; then
+				einfo "${BLUE}<<< ${path%.py}\$py.class${NORMAL}"
+				rm -f "${path%.py}\$py.class"
+			fi
 		fi
 	done
 }
@@ -1857,7 +2018,7 @@
 # currently in use as $PYVER; sets PYVER/PYVER_MAJOR/PYVER_MINOR
 python_version() {
 	if ! has "${EAPI:-0}" 0 1 2; then
-		eerror "Use PYTHON() and/or python_get_*() instead of python_version()."
+		eerror "Use PYTHON() and/or python_get_*() instead of ${FUNCNAME}()."
 		die "${FUNCNAME}() cannot be used in this EAPI"
 	fi
 
@@ -1885,7 +2046,7 @@
 #
 python_mod_compile() {
 	if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
-		eerror "Use python_mod_optimize() instead of python_mod_compile()."
+		eerror "Use python_mod_optimize() instead of ${FUNCNAME}()."
 		die "${FUNCNAME}() cannot be used in this EAPI"
 	fi
 






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2010-02-14 18:53 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2010-02-14 18:53 UTC (permalink / raw
  To: gentoo-commits

arfrever    10/02/14 18:53:12

  Modified:             python.eclass
  Log:
  Depend on >=app-admin/eselect-python-20091230, which allows to use --ABI option of `eselect python show`.
  Set PYTHON_SCRIPT_NAME variable in wrapper scripts generated by python_generate_wrapper_scripts().
  Simplify PYTHON() by using of --ABI option of `eselect python show`.
  Fix checks for Jython and improve messages in python_mod_optimize().

Revision  Changes    Path
1.89                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.89&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.89&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.88&r2=1.89

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -r1.88 -r1.89
--- python.eclass	11 Feb 2010 18:52:44 -0000	1.88
+++ python.eclass	14 Feb 2010 18:53:11 -0000	1.89
@@ -1,6 +1,6 @@
 # Copyright 1999-2010 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.88 2010/02/11 18:52:44 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.89 2010/02/14 18:53:11 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -152,7 +152,7 @@
 	fi
 }
 
-DEPEND=">=app-admin/eselect-python-20090804"
+DEPEND=">=app-admin/eselect-python-20091230"
 RDEPEND="${DEPEND}"
 
 if [[ -n "${PYTHON_DEPEND}" && -n "${NEED_PYTHON}" ]]; then
@@ -890,7 +890,7 @@
 		fi
 		cat << EOF >> "${file}"
 
-os.environ["PYTHON_PROCESS_NAME"] = sys.argv[0]
+os.environ["PYTHON_SCRIPT_NAME"] = sys.argv[0]
 target_executable = "%s-%s" % (os.path.realpath(sys.argv[0]), PYTHON_ABI)
 if not os.path.exists(target_executable):
 	sys.stderr.write("'%s' does not exist\n" % target_executable)
@@ -1054,23 +1054,19 @@
 			validate_PYTHON_ABIS
 			PYTHON_ABI="${PYTHON_ABIS##* }"
 		elif [[ "${python2}" == "1" ]]; then
-			# PYTHON_ABI="$(eselect python show --python2 --ABI)"
-			PYTHON_ABI="$(eselect python show --python2)"
+			PYTHON_ABI="$(eselect python show --python2 --ABI)"
 			if [[ -z "${PYTHON_ABI}" ]]; then
 				die "${FUNCNAME}(): Active Python 2 interpreter not set"
-			elif [[ "${PYTHON_ABI}" != "python2."* ]]; then
+			elif [[ "${PYTHON_ABI}" != "2."* ]]; then
 				die "${FUNCNAME}(): Internal error in \`eselect python show --python2\`"
 			fi
-			PYTHON_ABI="${PYTHON_ABI#python}"
 		elif [[ "${python3}" == "1" ]]; then
-			# PYTHON_ABI="$(eselect python show --python3 --ABI)"
-			PYTHON_ABI="$(eselect python show --python3)"
+			PYTHON_ABI="$(eselect python show --python3 --ABI)"
 			if [[ -z "${PYTHON_ABI}" ]]; then
 				die "${FUNCNAME}(): Active Python 3 interpreter not set"
-			elif [[ "${PYTHON_ABI}" != "python3."* ]]; then
+			elif [[ "${PYTHON_ABI}" != "3."* ]]; then
 				die "${FUNCNAME}(): Internal error in \`eselect python show --python3\`"
 			fi
-			PYTHON_ABI="${PYTHON_ABI#python}"
 		elif [[ -z "${PYTHON_ABI}" ]]; then
 			die "${FUNCNAME}(): Invalid usage: Python ABI not specified"
 		fi
@@ -1839,16 +1835,16 @@
 
 		if ((${#other_dirs[@]})) || ((${#other_files[@]})); then
 			return_code="0"
-			ebegin "Compilation and optimization of Python modules placed outside of site-packages directories for Python $(PYTHON -A --ABI)"
+			ebegin "Compilation and optimization of Python modules placed outside of site-packages directories for $(python_get_implementation) $(python_get_version)"
 			if ((${#other_dirs[@]})); then
 				"$(PYTHON "${PYTHON_ABI--A}")" "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" || return_code="1"
-				if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
+				if [[ "$(_python_get_implementation "${PYTHON_ABI-$(PYTHON -A --ABI)}")" != "Jython" ]]; then
 					"$(PYTHON "${PYTHON_ABI--A}")" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" &> /dev/null || return_code="1"
 				fi
 			fi
 			if ((${#other_files[@]})); then
 				"$(PYTHON "${PYTHON_ABI--A}")" "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" || return_code="1"
-				if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
+				if [[ "$(_python_get_implementation "${PYTHON_ABI-$(PYTHON -A --ABI)}")" != "Jython" ]]; then
 					"$(PYTHON "${PYTHON_ABI--A}")" -O "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" &> /dev/null || return_code="1"
 				fi
 			fi
@@ -1892,7 +1888,7 @@
 		# set additional opts
 		myopts+=(-q)
 
-		ebegin "Compilation and optimization of Python modules for Python $(PYTHON -A --ABI)"
+		ebegin "Compilation and optimization of Python modules for $(python_get_implementation) $(python_get_version)"
 		if ((${#mydirs[@]})); then
 			"$(PYTHON "${PYTHON_ABI--A}")" "${myroot}$(python_get_libdir)/compileall.py" "${myopts[@]}" "${mydirs[@]}" || return_code="1"
 			"$(PYTHON "${PYTHON_ABI--A}")" -O "${myroot}$(python_get_libdir)/compileall.py" "${myopts[@]}" "${mydirs[@]}" &> /dev/null || return_code="1"






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2010-02-28 11:48 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2010-02-28 11:48 UTC (permalink / raw
  To: gentoo-commits

arfrever    10/02/28 11:48:41

  Modified:             python.eclass
  Log:
  Define phase functions always in packages supporting installation for multiple versions of Python. Export phase functions when PYTHON_DEFINE_DEFAULT_FUNCTIONS is defined.
  Extract sanity checks from validate_PYTHON_ABIS() to _python_initial_sanity_checks() and _python_final_sanity_checks().
  Support --final-ABI option of python_execute_function().
  Extract setting of color variables to _python_set_color_variables().
  Simplify python_copy_sources() by not supporting --no-link option and always creating real copies of files.
  Call _python_initial_sanity_checks() and _python_final_sanity_checks() in python_set_active_version().
  Simplify PYTHON() by not supporting --active option.
  Deprecate python_tkinter_exists().

Revision  Changes    Path
1.90                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.90&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.90&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.89&r2=1.90

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.89
retrieving revision 1.90
diff -u -r1.89 -r1.90
--- python.eclass	14 Feb 2010 18:53:11 -0000	1.89
+++ python.eclass	28 Feb 2010 11:48:40 -0000	1.90
@@ -1,6 +1,6 @@
 # Copyright 1999-2010 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.89 2010/02/14 18:53:11 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.90 2010/02/28 11:48:40 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -263,11 +263,11 @@
 # Set this in EAPI <= 4 to indicate that current package supports installation for
 # multiple versions of Python.
 
-# @ECLASS-VARIABLE: PYTHON_DEFINE_DEFAULT_FUNCTIONS
+# @ECLASS-VARIABLE: PYTHON_EXPORT_PHASE_FUNCTIONS
 # @DESCRIPTION:
-# Set this to define default functions for the following ebuild phases:
+# Set this to export phase functions for the following ebuild phases:
 # src_prepare, src_configure, src_compile, src_test, src_install.
-if ! has "${EAPI:-0}" 0 1 && [[ -n "${PYTHON_DEFINE_DEFAULT_FUNCTIONS}" ]]; then
+if ! has "${EAPI:-0}" 0 1 && [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
 	python_src_prepare() {
 		python_copy_sources
 	}
@@ -277,11 +277,12 @@
 	done
 	unset python_default_function
 
-	EXPORT_FUNCTIONS src_prepare src_configure src_compile src_test src_install
+	if [[ -n "${PYTHON_EXPORT_PHASE_FUNCTIONS}" ]]; then
+		EXPORT_FUNCTIONS src_prepare src_configure src_compile src_test src_install
+	fi
 fi
 
 unset PYTHON_ABIS
-unset PYTHON_ABIS_SANITY_CHECKS
 
 # @FUNCTION: validate_PYTHON_ABIS
 # @DESCRIPTION:
@@ -293,17 +294,7 @@
 		die "${FUNCNAME}() cannot be used in this EAPI without setting SUPPORT_PYTHON_ABIS variable"
 	fi
 
-	# Ensure that /usr/bin/python and /usr/bin/python-config are valid.
-	if [[ "$(readlink "${EPREFIX}/usr/bin/python")" != "python-wrapper" ]]; then
-		eerror "'${EPREFIX}/usr/bin/python' is not valid symlink."
-		eerror "Use \`eselect python set \${python_interpreter}\` to fix this problem."
-		die "'${EPREFIX}/usr/bin/python' is not valid symlink"
-	fi
-	if [[ "$(<"${EPREFIX}/usr/bin/python-config")" != *"Gentoo python-config wrapper script"* ]]; then
-		eerror "'${EPREFIX}/usr/bin/python-config' is not valid script"
-		eerror "Use \`eselect python set \${python_interpreter}\` to fix this problem."
-		die "'${EPREFIX}/usr/bin/python-config' is not valid script"
-	fi
+	_python_initial_sanity_checks
 
 	# USE_${ABI_TYPE^^} and RESTRICT_${ABI_TYPE^^}_ABIS variables hopefully will be included in EAPI >= 5.
 	if [[ "$(declare -p PYTHON_ABIS 2> /dev/null)" != "declare -x PYTHON_ABIS="* ]] && has "${EAPI:-0}" 0 1 2 3 4; then
@@ -428,36 +419,18 @@
 		fi
 	fi
 
-	if ! _python_implementation && [[ "$(declare -p PYTHON_ABIS_SANITY_CHECKS 2> /dev/null)" != "declare -- PYTHON_ABIS_SANITY_CHECKS="* ]]; then
-		local PYTHON_ABI
-		for PYTHON_ABI in ${PYTHON_ABIS}; do
-			# Ensure that appropriate version of Python is installed.
-			if ! has_version "$(python_get_implementational_package)"; then
-				die "$(python_get_implementational_package) is not installed"
-			fi
-
-			# Ensure that EPYTHON variable is respected.
-			if [[ "$(EPYTHON="$(PYTHON)" python -c "${_PYTHON_ABI_EXTRACTION_COMMAND}")" != "${PYTHON_ABI}" ]]; then
-				eerror "python:                    '$(type -p python)'"
-				eerror "ABI:                       '${ABI}'"
-				eerror "DEFAULT_ABI:               '${DEFAULT_ABI}'"
-				eerror "EPYTHON:                   '$(PYTHON)'"
-				eerror "PYTHON_ABI:                '${PYTHON_ABI}'"
-				eerror "Version of enabled Python: '$(EPYTHON="$(PYTHON)" python -c "${_PYTHON_ABI_EXTRACTION_COMMAND}")'"
-				die "'python' does not respect EPYTHON variable"
-			fi
-		done
-		PYTHON_ABIS_SANITY_CHECKS="1"
-	fi
+	_python_final_sanity_checks
 }
 
 # @FUNCTION: python_execute_function
-# @USAGE: [--action-message message] [-d|--default-function] [--failure-message message] [--nonfatal] [-q|--quiet] [-s|--separate-build-dirs] [--source-dir source_directory] [--] <function> [arguments]
+# @USAGE: [--action-message message] [-d|--default-function] [--failure-message message] [-f|--final-ABI] [--nonfatal] [-q|--quiet] [-s|--separate-build-dirs] [--source-dir source_directory] [--] <function> [arguments]
 # @DESCRIPTION:
 # Execute specified function for each value of PYTHON_ABIS, optionally passing additional
 # arguments. The specified function can use PYTHON_ABI and BUILDDIR variables.
 python_execute_function() {
-	local action action_message action_message_template= default_function="0" failure_message failure_message_template= function i nonfatal="0" previous_directory previous_directory_stack previous_directory_stack_length PYTHON_ABI quiet="0" separate_build_dirs="0" source_dir=
+	_python_set_color_variables
+
+	local action action_message action_message_template= default_function="0" failure_message failure_message_template= final_ABI="0" function i iterated_PYTHON_ABIS nonfatal="0" previous_directory previous_directory_stack previous_directory_stack_length PYTHON_ABI quiet="0" separate_build_dirs="0" source_dir=
 
 	while (($#)); do
 		case "$1" in
@@ -472,6 +445,9 @@
 				failure_message_template="$2"
 				shift
 				;;
+			-f|--final-ABI)
+				final_ABI="1"
+				;;
 			--nonfatal)
 				nonfatal="1"
 				;;
@@ -573,28 +549,20 @@
 		[[ "${EBUILD_PHASE}" == "postrm" ]] && action="Postuninstallation"
 	fi
 
-	local RED GREEN BLUE NORMAL
-	if [[ "${NOCOLOR:-false}" =~ ^(false|no)$ ]]; then
-		RED=$'\e[1;31m'
-		GREEN=$'\e[1;32m'
-		BLUE=$'\e[1;34m'
-		NORMAL=$'\e[0m'
+	validate_PYTHON_ABIS
+	if [[ "${final_ABI}" == "1" ]]; then
+		iterated_PYTHON_ABIS="$(PYTHON -f --ABI)"
 	else
-		RED=
-		GREEN=
-		BLUE=
-		NORMAL=
+		iterated_PYTHON_ABIS="${PYTHON_ABIS}"
 	fi
-
-	validate_PYTHON_ABIS
-	for PYTHON_ABI in ${PYTHON_ABIS}; do
+	for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
 		if [[ "${quiet}" == "0" ]]; then
 			if [[ -n "${action_message_template}" ]]; then
 				action_message="$(eval echo -n "${action_message_template}")"
 			else
 				action_message="${action} of ${CATEGORY}/${PF} with $(python_get_implementation) $(python_get_version)..."
 			fi
-			echo " ${GREEN}*${NORMAL} ${BLUE}${action_message}${NORMAL}"
+			echo " ${_GREEN}*${_NORMAL} ${_BLUE}${action_message}${_NORMAL}"
 		fi
 
 		if [[ "${separate_build_dirs}" == "1" ]]; then
@@ -627,9 +595,9 @@
 
 			if [[ "${nonfatal}" == "1" ]]; then
 				if [[ "${quiet}" == "0" ]]; then
-					ewarn "${RED}${failure_message}${NORMAL}"
+					ewarn "${_RED}${failure_message}${_NORMAL}"
 				fi
-			elif has "${PYTHON_ABI}" ${FAILURE_TOLERANT_PYTHON_ABIS}; then
+			elif [[ "${final_ABI}" == "0" ]] && has "${PYTHON_ABI}" ${FAILURE_TOLERANT_PYTHON_ABIS}; then
 				if [[ "${EBUILD_PHASE}" != "test" ]] || ! has test-fail-continue ${FEATURES}; then
 					local enabled_PYTHON_ABIS= other_PYTHON_ABI
 					for other_PYTHON_ABI in ${PYTHON_ABIS}; do
@@ -638,7 +606,7 @@
 					export PYTHON_ABIS="${enabled_PYTHON_ABIS}"
 				fi
 				if [[ "${quiet}" == "0" ]]; then
-					ewarn "${RED}${failure_message}${NORMAL}"
+					ewarn "${_RED}${failure_message}${_NORMAL}"
 				fi
 				if [[ -z "${PYTHON_ABIS}" ]]; then
 					die "${function}() function failed with all enabled versions of Python"
@@ -681,54 +649,31 @@
 }
 
 # @FUNCTION: python_copy_sources
-# @USAGE: [--no-link] [--] [directory]
+# @USAGE: <directory="${S}"> [directory]
 # @DESCRIPTION:
 # Copy unpacked sources of current package to separate build directory for each Python ABI.
 python_copy_sources() {
-	local dir dirs=() no_link="0" PYTHON_ABI
-
-	while (($#)); do
-		case "$1" in
-			--no-link)
-				no_link="1"
-				;;
-			--)
-				shift
-				break
-				;;
-			-*)
-				die "${FUNCNAME}(): Unrecognized option '$1'"
-				;;
-			*)
-				break
-				;;
-		esac
-		shift
-	done
+	local dir dirs=() PYTHON_ABI
 
 	if [[ "$#" -eq 0 ]]; then
 		if [[ "${WORKDIR}" == "${S}" ]]; then
 			die "${FUNCNAME}() cannot be used"
 		fi
-		dirs="${S}"
+		dirs=("${S}")
 	else
-		dirs="$@"
+		dirs=("$@")
 	fi
 
 	validate_PYTHON_ABIS
 	for PYTHON_ABI in ${PYTHON_ABIS}; do
 		for dir in "${dirs[@]}"; do
-			if [[ "${no_link}" == "1" ]]; then
-				cp -pr "${dir}" "${dir}-${PYTHON_ABI}" > /dev/null || die "Copying of sources failed"
-			else
-				cp -lpr "${dir}" "${dir}-${PYTHON_ABI}" > /dev/null || die "Copying of sources failed"
-			fi
+			cp -pr "${dir}" "${dir}-${PYTHON_ABI}" > /dev/null || die "Copying of sources failed"
 		done
 	done
 }
 
 # @FUNCTION: python_set_build_dir_symlink
-# @USAGE: [directory="build"]
+# @USAGE: <directory="build">
 # @DESCRIPTION:
 # Create build directory symlink.
 python_set_build_dir_symlink() {
@@ -922,6 +867,8 @@
 		die "${FUNCNAME}() requires 1 argument"
 	fi
 
+	_python_initial_sanity_checks
+
 	if [[ "$1" =~ ^[[:digit:]]+\.[[:digit:]]+$ ]]; then
 		if ! _python_implementation && ! has_version "dev-lang/python:$1"; then
 			die "${FUNCNAME}(): 'dev-lang/python:$1' is not installed"
@@ -946,6 +893,8 @@
 	PYTHON_ABI="${EPYTHON#python}"
 	PYTHON_ABI="${PYTHON_ABI%%-*}"
 
+	_python_final_sanity_checks
+
 	# python-updater checks PYTHON_REQUESTED_ACTIVE_VERSION variable.
 	PYTHON_REQUESTED_ACTIVE_VERSION="$1"
 }
@@ -954,7 +903,11 @@
 # @DESCRIPTION: Mark current package for rebuilding by python-updater after
 # switching of active version of Python.
 python_need_rebuild() {
-	export PYTHON_NEED_REBUILD="$(PYTHON -A --ABI)"
+	if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
+		die "${FUNCNAME}() cannot be used in ebuilds of packages supporting installation for multiple versions of Python"
+	fi
+
+	export PYTHON_NEED_REBUILD="$(PYTHON --ABI)"
 }
 
 # ================================================================================================
@@ -982,22 +935,20 @@
 }
 
 # @FUNCTION: PYTHON
-# @USAGE: [-2] [-3] [--ABI] [-A|--active] [-a|--absolute-path] [-f|--final-ABI] [--] <Python_ABI="${PYTHON_ABI}">
+# @USAGE: [-2] [-3] [--ABI] [-a|--absolute-path] [-f|--final-ABI] [--] <Python_ABI="${PYTHON_ABI}">
 # @DESCRIPTION:
 # Print filename of Python interpreter for specified Python ABI. If Python_ABI argument
 # is ommitted, then PYTHON_ABI environment variable must be set and is used.
 # If -2 option is specified, then active version of Python 2 is used.
 # If -3 option is specified, then active version of Python 3 is used.
-# If --active option is specified, then active version of Python is used.
-# Active version of Python can be set by python_set_active_version().
 # If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
-# -2, -3, --active and --final-ABI options and Python_ABI argument cannot be specified simultaneously.
+# -2, -3 and --final-ABI options and Python_ABI argument cannot be specified simultaneously.
 # If --ABI option is specified, then only specified Python ABI is printed instead of
 # filename of Python interpreter.
 # If --absolute-path option is specified, then absolute path to Python interpreter is printed.
 # --ABI and --absolute-path options cannot be specified simultaneously.
 PYTHON() {
-	local ABI_output="0" absolute_path_output="0" active="0" final_ABI="0" PYTHON_ABI="${PYTHON_ABI}" python_interpreter python2="0" python3="0"
+	local ABI_output="0" absolute_path_output="0" final_ABI="0" PYTHON_ABI="${PYTHON_ABI}" python_interpreter python2="0" python3="0"
 
 	while (($#)); do
 		case "$1" in
@@ -1010,9 +961,6 @@
 			--ABI)
 				ABI_output="1"
 				;;
-			-A|--active)
-				active="1"
-				;;
 			-a|--absolute-path)
 				absolute_path_output="1"
 				;;
@@ -1037,17 +985,12 @@
 		die "${FUNCNAME}(): '--ABI and '--absolute-path' options cannot be specified simultaneously"
 	fi
 
-	if [[ "$((${python2} + ${python3} + ${active} + ${final_ABI}))" -gt 1 ]]; then
-		die "${FUNCNAME}(): '-2', '-3', '--active' or '--final-ABI' options cannot be specified simultaneously"
+	if [[ "$((${python2} + ${python3} + ${final_ABI}))" -gt 1 ]]; then
+		die "${FUNCNAME}(): '-2', '-3' or '--final-ABI' options cannot be specified simultaneously"
 	fi
 
 	if [[ "$#" -eq 0 ]]; then
-		if [[ "${active}" == "1" ]]; then
-			if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
-				die "${FUNCNAME}(): '--active' option cannot be used in ebuilds of packages supporting installation for multiple versions of Python"
-			fi
-			PYTHON_ABI="$("${EPREFIX}/usr/bin/python" -c "${_PYTHON_ABI_EXTRACTION_COMMAND}")"
-		elif [[ "${final_ABI}" == "1" ]]; then
+		if [[ "${final_ABI}" == "1" ]]; then
 			if has "${EAPI:-0}" 0 1 2 3 4 && [[ -z "${SUPPORT_PYTHON_ABIS}" ]]; then
 				die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple versions of Python"
 			fi
@@ -1067,13 +1010,12 @@
 			elif [[ "${PYTHON_ABI}" != "3."* ]]; then
 				die "${FUNCNAME}(): Internal error in \`eselect python show --python3\`"
 			fi
+		elif [[ -z "${SUPPORT_PYTHON_ABIS}" ]]; then
+			PYTHON_ABI="$("${EPREFIX}/usr/bin/python" -c "${_PYTHON_ABI_EXTRACTION_COMMAND}")"
 		elif [[ -z "${PYTHON_ABI}" ]]; then
 			die "${FUNCNAME}(): Invalid usage: Python ABI not specified"
 		fi
 	elif [[ "$#" -eq 1 ]]; then
-		if [[ "${active}" == "1" ]]; then
-			die "${FUNCNAME}(): '--active' option and Python ABI cannot be specified simultaneously"
-		fi
 		if [[ "${final_ABI}" == "1" ]]; then
 			die "${FUNCNAME}(): '--final-ABI' option and Python ABI cannot be specified simultaneously"
 		fi
@@ -1136,7 +1078,7 @@
 	if [[ "${final_ABI}" == "1" ]]; then
 		PYTHON_ABI="$(PYTHON -f --ABI)"
 	elif [[ -z "${PYTHON_ABI}" ]]; then
-		PYTHON_ABI="$(PYTHON -A --ABI)"
+		PYTHON_ABI="$(PYTHON --ABI)"
 	fi
 
 	echo "$(_python_get_implementation "${PYTHON_ABI}")"
@@ -1168,7 +1110,7 @@
 	if [[ "${final_ABI}" == "1" ]]; then
 		PYTHON_ABI="$(PYTHON -f --ABI)"
 	elif [[ -z "${PYTHON_ABI}" ]]; then
-		PYTHON_ABI="$(PYTHON -A --ABI)"
+		PYTHON_ABI="$(PYTHON --ABI)"
 	fi
 
 	if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
@@ -1204,7 +1146,7 @@
 	if [[ "${final_ABI}" == "1" ]]; then
 		PYTHON_ABI="$(PYTHON -f --ABI)"
 	elif [[ -z "${PYTHON_ABI}" ]]; then
-		PYTHON_ABI="$(PYTHON -A --ABI)"
+		PYTHON_ABI="$(PYTHON --ABI)"
 	fi
 
 	if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
@@ -1240,7 +1182,7 @@
 	if [[ "${final_ABI}" == "1" ]]; then
 		PYTHON_ABI="$(PYTHON -f --ABI)"
 	elif [[ -z "${PYTHON_ABI}" ]]; then
-		PYTHON_ABI="$(PYTHON -A --ABI)"
+		PYTHON_ABI="$(PYTHON --ABI)"
 	fi
 
 	if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
@@ -1306,7 +1248,7 @@
 	if [[ "${final_ABI}" == "1" ]]; then
 		PYTHON_ABI="$(PYTHON -f --ABI)"
 	elif [[ -z "${PYTHON_ABI}" ]]; then
-		PYTHON_ABI="$(PYTHON -A --ABI)"
+		PYTHON_ABI="$(PYTHON --ABI)"
 	fi
 
 	if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
@@ -1371,7 +1313,7 @@
 	if [[ "${final_ABI}" == "1" ]]; then
 		"$(PYTHON -f)" -c "${python_command}"
 	else
-		"$(PYTHON "${PYTHON_ABI--A}")" -c "${python_command}"
+		"$(PYTHON ${PYTHON_ABI})" -c "${python_command}"
 	fi
 }
 
@@ -1400,6 +1342,66 @@
 	fi
 }
 
+unset PYTHON_SANITY_CHECKS
+
+_python_initial_sanity_checks() {
+	if [[ "$(declare -p PYTHON_SANITY_CHECKS 2> /dev/null)" != "declare -- PYTHON_SANITY_CHECKS="* ]]; then
+		# Ensure that /usr/bin/python and /usr/bin/python-config are valid.
+		if [[ "$(readlink "${EPREFIX}/usr/bin/python")" != "python-wrapper" ]]; then
+			eerror "'${EPREFIX}/usr/bin/python' is not valid symlink."
+			eerror "Use \`eselect python set \${python_interpreter}\` to fix this problem."
+			die "'${EPREFIX}/usr/bin/python' is not valid symlink"
+		fi
+		if [[ "$(<"${EPREFIX}/usr/bin/python-config")" != *"Gentoo python-config wrapper script"* ]]; then
+			eerror "'${EPREFIX}/usr/bin/python-config' is not valid script"
+			eerror "Use \`eselect python set \${python_interpreter}\` to fix this problem."
+			die "'${EPREFIX}/usr/bin/python-config' is not valid script"
+		fi
+	fi
+}
+
+_python_final_sanity_checks() {
+	if ! _python_implementation && [[ "$(declare -p PYTHON_SANITY_CHECKS 2> /dev/null)" != "declare -- PYTHON_SANITY_CHECKS="* ]]; then
+		local PYTHON_ABI="${PYTHON_ABI}"
+		for PYTHON_ABI in ${PYTHON_ABIS-${PYTHON_ABI}}; do
+			# Ensure that appropriate version of Python is installed.
+			if ! has_version "$(python_get_implementational_package)"; then
+				die "$(python_get_implementational_package) is not installed"
+			fi
+
+			# Ensure that EPYTHON variable is respected.
+			if [[ "$(EPYTHON="$(PYTHON)" python -c "${_PYTHON_ABI_EXTRACTION_COMMAND}")" != "${PYTHON_ABI}" ]]; then
+				eerror "python:                    '$(type -p python)'"
+				eerror "ABI:                       '${ABI}'"
+				eerror "DEFAULT_ABI:               '${DEFAULT_ABI}'"
+				eerror "EPYTHON:                   '$(PYTHON)'"
+				eerror "PYTHON_ABI:                '${PYTHON_ABI}'"
+				eerror "Version of enabled Python: '$(EPYTHON="$(PYTHON)" python -c "${_PYTHON_ABI_EXTRACTION_COMMAND}")'"
+				die "'python' does not respect EPYTHON variable"
+			fi
+		done
+	fi
+	PYTHON_SANITY_CHECKS="1"
+}
+
+_python_set_color_variables() {
+	if [[ "${NOCOLOR:-false}" =~ ^(false|no)$ ]]; then
+		_BOLD=$'\e[1m'
+		_RED=$'\e[1;31m'
+		_GREEN=$'\e[1;32m'
+		_BLUE=$'\e[1;34m'
+		_CYAN=$'\e[1;36m'
+		_NORMAL=$'\e[0m'
+	else
+		_BOLD=
+		_RED=
+		_GREEN=
+		_BLUE=
+		_CYAN=
+		_NORMAL=
+	fi
+}
+
 # @FUNCTION: python_convert_shebangs
 # @USAGE: [-q|--quiet] [-r|--recursive] [-x|--only-executables] [--] <Python_version> <file|directory> [files|directories]
 # @DESCRIPTION:
@@ -1493,24 +1495,7 @@
 	if [[ "$#" -ne 1 ]]; then
 		die "${FUNCNAME}() requires 1 argument"
 	fi
-	"$(PYTHON "${PYTHON_ABI--A}")" -c "import $1" &> /dev/null
-}
-
-# @FUNCTION: python_tkinter_exists
-# @DESCRIPTION:
-# Run without arguments, checks if Python was compiled with Tkinter
-# support.  If not, prints an error message and dies.
-python_tkinter_exists() {
-	if ! "$(PYTHON "${PYTHON_ABI--A}")" -c "from sys import version_info
-if version_info[0] == 3:
-	import tkinter
-else:
-	import Tkinter" &> /dev/null; then
-		eerror "Python needs to be rebuilt with tkinter support enabled."
-		eerror "Add the following line to '${EPREFIX}/etc/portage/package.use' and rebuild Python"
-		eerror "dev-lang/python tk"
-		die "Python installed without support for tkinter"
-	fi
+	"$(PYTHON ${PYTHON_ABI})" -c "import $1" &> /dev/null
 }
 
 # ================================================================================================
@@ -1528,6 +1513,8 @@
 # @DESCRIPTION:
 # Execute nosetests for all enabled versions of Python.
 python_execute_nosetests() {
+	_python_set_color_variables
+
 	local PYTHONPATH_template= separate_build_dirs=
 
 	while (($#)); do
@@ -1564,10 +1551,10 @@
 		fi
 
 		if [[ -n "${evaluated_PYTHONPATH}" ]]; then
-			echo PYTHONPATH="${evaluated_PYTHONPATH}" nosetests --verbosity="${PYTHON_TEST_VERBOSITY}" "$@"
+			echo ${_BOLD}PYTHONPATH="${evaluated_PYTHONPATH}" nosetests --verbosity="${PYTHON_TEST_VERBOSITY}" "$@"${_NORMAL}
 			PYTHONPATH="${evaluated_PYTHONPATH}" nosetests --verbosity="${PYTHON_TEST_VERBOSITY}" "$@"
 		else
-			echo nosetests --verbosity="${PYTHON_TEST_VERBOSITY}" "$@"
+			echo ${_BOLD}nosetests --verbosity="${PYTHON_TEST_VERBOSITY}" "$@"${_NORMAL}
 			nosetests --verbosity="${PYTHON_TEST_VERBOSITY}" "$@"
 		fi
 	}
@@ -1588,6 +1575,8 @@
 # @DESCRIPTION:
 # Execute py.test for all enabled versions of Python.
 python_execute_py.test() {
+	_python_set_color_variables
+
 	local PYTHONPATH_template= separate_build_dirs=
 
 	while (($#)); do
@@ -1624,10 +1613,10 @@
 		fi
 
 		if [[ -n "${evaluated_PYTHONPATH}" ]]; then
-			echo PYTHONPATH="${evaluated_PYTHONPATH}" py.test $([[ "${PYTHON_TEST_VERBOSITY}" -ge 2 ]] && echo -v) "$@"
+			echo ${_BOLD}PYTHONPATH="${evaluated_PYTHONPATH}" py.test $([[ "${PYTHON_TEST_VERBOSITY}" -ge 2 ]] && echo -v) "$@"${_NORMAL}
 			PYTHONPATH="${evaluated_PYTHONPATH}" py.test $([[ "${PYTHON_TEST_VERBOSITY}" -ge 2 ]] && echo -v) "$@"
 		else
-			echo py.test $([[ "${PYTHON_TEST_VERBOSITY}" -gt 1 ]] && echo -v) "$@"
+			echo ${_BOLD}py.test $([[ "${PYTHON_TEST_VERBOSITY}" -gt 1 ]] && echo -v) "$@"${_NORMAL}
 			py.test $([[ "${PYTHON_TEST_VERBOSITY}" -gt 1 ]] && echo -v) "$@"
 		fi
 	}
@@ -1648,6 +1637,8 @@
 # @DESCRIPTION:
 # Execute trial for all enabled versions of Python.
 python_execute_trial() {
+	_python_set_color_variables
+
 	local PYTHONPATH_template= separate_build_dirs=
 
 	while (($#)); do
@@ -1684,10 +1675,10 @@
 		fi
 
 		if [[ -n "${evaluated_PYTHONPATH}" ]]; then
-			echo PYTHONPATH="${evaluated_PYTHONPATH}" trial $([[ "${PYTHON_TEST_VERBOSITY}" -ge 4 ]] && echo --spew) "$@"
+			echo ${_BOLD}PYTHONPATH="${evaluated_PYTHONPATH}" trial $([[ "${PYTHON_TEST_VERBOSITY}" -ge 4 ]] && echo --spew) "$@"${_NORMAL}
 			PYTHONPATH="${evaluated_PYTHONPATH}" trial $([[ "${PYTHON_TEST_VERBOSITY}" -ge 4 ]] && echo --spew) "$@"
 		else
-			echo trial $([[ "${PYTHON_TEST_VERBOSITY}" -ge 4 ]] && echo --spew) "$@"
+			echo ${_BOLD}trial $([[ "${PYTHON_TEST_VERBOSITY}" -ge 4 ]] && echo --spew) "$@"${_NORMAL}
 			trial $([[ "${PYTHON_TEST_VERBOSITY}" -ge 4 ]] && echo --spew) "$@"
 		fi
 	}
@@ -1745,7 +1736,7 @@
 	[[ ${EBUILD_PHASE} != "postinst" ]] && die "${FUNCNAME}() should only be run in pkg_postinst()"
 
 	if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
-		local dir file options=() other_dirs=() other_files=() previous_PYTHON_ABI="${PYTHON_ABI}" PYTHON_ABI return_code root site_packages_absolute_dirs=() site_packages_dirs=() site_packages_absolute_files=() site_packages_files=()
+		local dir file options=() other_dirs=() other_files=() previous_PYTHON_ABI="${PYTHON_ABI}" PYTHON_ABI="${PYTHON_ABI}" return_code root site_packages_absolute_dirs=() site_packages_dirs=() site_packages_absolute_files=() site_packages_files=()
 
 		# Strip trailing slash from ROOT.
 		root="${EROOT%/}"
@@ -1777,7 +1768,7 @@
 							ewarn "'${root}/$1' does not exist!"
 						fi
 					else
-						for PYTHON_ABI in ${PYTHON_ABIS-${PYTHON_ABI-$(PYTHON -A --ABI)}}; do
+						for PYTHON_ABI in ${PYTHON_ABIS-${PYTHON_ABI:-$(PYTHON --ABI)}}; do
 							if [[ -d "${root}$(python_get_sitedir)/$1" ]]; then
 								site_packages_dirs+=("$1")
 								break
@@ -1799,7 +1790,7 @@
 		# Set additional options.
 		options+=("-q")
 
-		for PYTHON_ABI in ${PYTHON_ABIS-${PYTHON_ABI-$(PYTHON -A --ABI)}}; do
+		for PYTHON_ABI in ${PYTHON_ABIS-${PYTHON_ABI:-$(PYTHON --ABI)}}; do
 			if ((${#site_packages_dirs[@]})) || ((${#site_packages_files[@]})); then
 				return_code="0"
 				ebegin "Compilation and optimization of Python modules for $(python_get_implementation) $(python_get_version)"
@@ -1837,15 +1828,15 @@
 			return_code="0"
 			ebegin "Compilation and optimization of Python modules placed outside of site-packages directories for $(python_get_implementation) $(python_get_version)"
 			if ((${#other_dirs[@]})); then
-				"$(PYTHON "${PYTHON_ABI--A}")" "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" || return_code="1"
-				if [[ "$(_python_get_implementation "${PYTHON_ABI-$(PYTHON -A --ABI)}")" != "Jython" ]]; then
-					"$(PYTHON "${PYTHON_ABI--A}")" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" &> /dev/null || return_code="1"
+				"$(PYTHON ${PYTHON_ABI})" "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" || return_code="1"
+				if [[ "$(_python_get_implementation "${PYTHON_ABI-$(PYTHON --ABI)}")" != "Jython" ]]; then
+					"$(PYTHON ${PYTHON_ABI})" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" &> /dev/null || return_code="1"
 				fi
 			fi
 			if ((${#other_files[@]})); then
-				"$(PYTHON "${PYTHON_ABI--A}")" "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" || return_code="1"
-				if [[ "$(_python_get_implementation "${PYTHON_ABI-$(PYTHON -A --ABI)}")" != "Jython" ]]; then
-					"$(PYTHON "${PYTHON_ABI--A}")" -O "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" &> /dev/null || return_code="1"
+				"$(PYTHON ${PYTHON_ABI})" "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" || return_code="1"
+				if [[ "$(_python_get_implementation "${PYTHON_ABI-$(PYTHON --ABI)}")" != "Jython" ]]; then
+					"$(PYTHON ${PYTHON_ABI})" -O "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" &> /dev/null || return_code="1"
 				fi
 			fi
 			eend "${return_code}"
@@ -1890,8 +1881,8 @@
 
 		ebegin "Compilation and optimization of Python modules for $(python_get_implementation) $(python_get_version)"
 		if ((${#mydirs[@]})); then
-			"$(PYTHON "${PYTHON_ABI--A}")" "${myroot}$(python_get_libdir)/compileall.py" "${myopts[@]}" "${mydirs[@]}" || return_code="1"
-			"$(PYTHON "${PYTHON_ABI--A}")" -O "${myroot}$(python_get_libdir)/compileall.py" "${myopts[@]}" "${mydirs[@]}" &> /dev/null || return_code="1"
+			"$(PYTHON ${PYTHON_ABI})" "${myroot}$(python_get_libdir)/compileall.py" "${myopts[@]}" "${mydirs[@]}" || return_code="1"
+			"$(PYTHON ${PYTHON_ABI})" -O "${myroot}$(python_get_libdir)/compileall.py" "${myopts[@]}" "${mydirs[@]}" &> /dev/null || return_code="1"
 		fi
 
 		if ((${#myfiles[@]})); then
@@ -1915,8 +1906,9 @@
 # This function should only be run in pkg_postrm().
 python_mod_cleanup() {
 	_python_initialize_prefix_variables
+	_python_set_color_variables
 
-	local path py_file PYTHON_ABI SEARCH_PATH=() root
+	local path py_file PYTHON_ABI="${PYTHON_ABI}" SEARCH_PATH=() root
 
 	# Check if phase is pkg_postrm().
 	[[ ${EBUILD_PHASE} != "postrm" ]] && die "${FUNCNAME}() should only be run in pkg_postrm()"
@@ -1932,7 +1924,7 @@
 				elif [[ "$1" =~ ^/ ]]; then
 					SEARCH_PATH+=("${root}/${1#/}")
 				else
-					for PYTHON_ABI in ${PYTHON_ABIS-${PYTHON_ABI-$(PYTHON -A --ABI)}}; do
+					for PYTHON_ABI in ${PYTHON_ABIS-${PYTHON_ABI:-$(PYTHON --ABI)}}; do
 						SEARCH_PATH+=("${root}$(python_get_sitedir)/$1")
 					done
 				fi
@@ -1960,44 +1952,33 @@
 		done
 	fi
 
-	local BLUE CYAN NORMAL
-	if [[ "${NOCOLOR:-false}" =~ ^(false|no)$ ]]; then
-		BLUE=$'\e[1;34m'
-		CYAN=$'\e[1;36m'
-		NORMAL=$'\e[0m'
-	else
-		BLUE=
-		CYAN=
-		NORMAL=
-	fi
-
 	for path in "${SEARCH_PATH[@]}"; do
 		if [[ -d "${path}" ]]; then
 			find "${path}" "(" -name "*.py[co]" -o -name "*\$py.class" ")" -print0 | while read -rd ''; do
 				if [[ "${REPLY}" == *[co] ]]; then
 					py_file="${REPLY%[co]}"
 					[[ -f "${py_file}" || (! -f "${py_file}c" && ! -f "${py_file}o") ]] && continue
-					einfo "${BLUE}<<< ${py_file}[co]${NORMAL}"
+					einfo "${_BLUE}<<< ${py_file}[co]${_NORMAL}"
 					rm -f "${py_file}"[co]
 				elif [[ "${REPLY}" == *\$py.class ]]; then
 					py_file="${REPLY%\$py.class}.py"
 					[[ -f "${py_file}" || ! -f "${py_file%.py}\$py.class" ]] && continue
-					einfo "${BLUE}<<< ${py_file%.py}\$py.class${NORMAL}"
+					einfo "${_BLUE}<<< ${py_file%.py}\$py.class${_NORMAL}"
 					rm -f "${py_file%.py}\$py.class"
 				fi
 			done
 
 			# Attempt to delete directories, which may be empty.
 			find "${path}" -type d | sort -r | while read -r dir; do
-				rmdir "${dir}" 2>/dev/null && einfo "${CYAN}<<< ${dir}${NORMAL}"
+				rmdir "${dir}" 2>/dev/null && einfo "${_CYAN}<<< ${dir}${_NORMAL}"
 			done
 		elif [[ "${path}" == *.py && ! -f "${path}" ]]; then
 			if [[ (-f "${path}c" || -f "${path}o") ]]; then
-				einfo "${BLUE}<<< ${path}[co]${NORMAL}"
+				einfo "${_BLUE}<<< ${path}[co]${_NORMAL}"
 				rm -f "${path}"[co]
 			fi
 			if [[ -f "${path%.py}\$py.class" ]]; then
-				einfo "${BLUE}<<< ${path%.py}\$py.class${NORMAL}"
+				einfo "${_BLUE}<<< ${path%.py}\$py.class${_NORMAL}"
 				rm -f "${path%.py}\$py.class"
 			fi
 		fi
@@ -2013,7 +1994,7 @@
 # Run without arguments and it will export the version of python
 # currently in use as $PYVER; sets PYVER/PYVER_MAJOR/PYVER_MINOR
 python_version() {
-	if ! has "${EAPI:-0}" 0 1 2; then
+	if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
 		eerror "Use PYTHON() and/or python_get_*() instead of ${FUNCNAME}()."
 		die "${FUNCNAME}() cannot be used in this EAPI"
 	fi
@@ -2031,6 +2012,28 @@
 	export PYVER="${PYVER_MAJOR}.${PYVER_MINOR}"
 }
 
+# @FUNCTION: python_tkinter_exists
+# @DESCRIPTION:
+# Run without arguments, checks if Python was compiled with Tkinter
+# support.  If not, prints an error message and dies.
+python_tkinter_exists() {
+	if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
+		eerror "Use PYTHON_USE_WITH=\"xml\" and python_pkg_setup() instead of ${FUNCNAME}()."
+		die "${FUNCNAME}() cannot be used in this EAPI"
+	fi
+
+	if ! "$(PYTHON ${PYTHON_ABI})" -c "from sys import version_info
+if version_info[0] == 3:
+	import tkinter
+else:
+	import Tkinter" &> /dev/null; then
+		eerror "Python needs to be rebuilt with tkinter support enabled."
+		eerror "Add the following line to '${EPREFIX}/etc/portage/package.use' and rebuild Python"
+		eerror "dev-lang/python tk"
+		die "Python installed without support for tkinter"
+	fi
+}
+
 # @FUNCTION: python_mod_compile
 # @USAGE: <file> [more files ...]
 # @DESCRIPTION:
@@ -2062,8 +2065,8 @@
 	done
 
 	if ((${#myfiles[@]})); then
-		"$(PYTHON "${PYTHON_ABI--A}")" "${myroot}$(python_get_libdir)/py_compile.py" "${myfiles[@]}"
-		"$(PYTHON "${PYTHON_ABI--A}")" -O "${myroot}$(python_get_libdir)/py_compile.py" "${myfiles[@]}" &> /dev/null
+		"$(PYTHON ${PYTHON_ABI})" "${myroot}$(python_get_libdir)/py_compile.py" "${myfiles[@]}"
+		"$(PYTHON ${PYTHON_ABI})" -O "${myroot}$(python_get_libdir)/py_compile.py" "${myfiles[@]}" &> /dev/null
 	else
 		ewarn "No files to compile!"
 	fi






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2010-02-28 15:49 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2010-02-28 15:49 UTC (permalink / raw
  To: gentoo-commits

arfrever    10/02/28 15:49:33

  Modified:             python.eclass
  Log:
  Deprecate python_mod_exists().

Revision  Changes    Path
1.91                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.91&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.91&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.90&r2=1.91

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -r1.90 -r1.91
--- python.eclass	28 Feb 2010 11:48:40 -0000	1.90
+++ python.eclass	28 Feb 2010 15:49:33 -0000	1.91
@@ -1,6 +1,6 @@
 # Copyright 1999-2010 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.90 2010/02/28 11:48:40 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.91 2010/02/28 15:49:33 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -1479,25 +1479,6 @@
 	done
 }
 
-# @FUNCTION: python_mod_exists
-# @USAGE: <module>
-# @DESCRIPTION:
-# Run with the module name as an argument. It will check if a
-# Python module is installed and loadable. It will return
-# TRUE(0) if the module exists, and FALSE(1) if the module does
-# not exist.
-#
-# Example:
-#         if python_mod_exists gtk; then
-#             echo "gtk support enabled"
-#         fi
-python_mod_exists() {
-	if [[ "$#" -ne 1 ]]; then
-		die "${FUNCNAME}() requires 1 argument"
-	fi
-	"$(PYTHON ${PYTHON_ABI})" -c "import $1" &> /dev/null
-}
-
 # ================================================================================================
 # ================================ FUNCTIONS FOR RUNNING OF TESTS ================================
 # ================================================================================================
@@ -2012,6 +1993,30 @@
 	export PYVER="${PYVER_MAJOR}.${PYVER_MINOR}"
 }
 
+# @FUNCTION: python_mod_exists
+# @USAGE: <module>
+# @DESCRIPTION:
+# Run with the module name as an argument. It will check if a
+# Python module is installed and loadable. It will return
+# TRUE(0) if the module exists, and FALSE(1) if the module does
+# not exist.
+#
+# Example:
+#         if python_mod_exists gtk; then
+#             echo "gtk support enabled"
+#         fi
+python_mod_exists() {
+	if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
+		eerror "Use USE dependencies and/or has_version() instead of ${FUNCNAME}()."
+		die "${FUNCNAME}() cannot be used in this EAPI"
+	fi
+
+	if [[ "$#" -ne 1 ]]; then
+		die "${FUNCNAME}() requires 1 argument"
+	fi
+	"$(PYTHON ${PYTHON_ABI})" -c "import $1" &> /dev/null
+}
+
 # @FUNCTION: python_tkinter_exists
 # @DESCRIPTION:
 # Run without arguments, checks if Python was compiled with Tkinter






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2010-03-04 17:42 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2010-03-04 17:42 UTC (permalink / raw
  To: gentoo-commits

arfrever    10/03/04 17:42:12

  Modified:             python.eclass
  Log:
  Ensure that python_pkg_setup() is used only in pkg_setup().
  Improve handling of PYTHON_USE_WITH / PYTHON_USE_WITH_OR.
  Support --full option of python_get_version().
  Optimize python_get_version().
  Support hooks in python_execute_nosetests(), python_execute_py.test() and python_execute_trial().
  Print deprecation warnings in python_version(), python_mod_exists() and python_tkinter_exists().

Revision  Changes    Path
1.92                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.92&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.92&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.91&r2=1.92

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.91
retrieving revision 1.92
diff -u -r1.91 -r1.92
--- python.eclass	28 Feb 2010 15:49:33 -0000	1.91
+++ python.eclass	4 Mar 2010 17:42:11 -0000	1.92
@@ -1,6 +1,6 @@
 # Copyright 1999-2010 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.91 2010/02/28 15:49:33 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.92 2010/03/04 17:42:11 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -190,6 +190,9 @@
 # are respected. Only exported if one of those variables is set.
 if ! has "${EAPI:-0}" 0 1 && [[ -n ${PYTHON_USE_WITH} || -n ${PYTHON_USE_WITH_OR} ]]; then
 	python_pkg_setup() {
+		# Check if phase is pkg_setup().
+		[[ "${EBUILD_PHASE}" != "setup" ]] && die "${FUNCNAME}() can be used only in pkg_setup() phase"
+
 		python_pkg_setup_fail() {
 			eerror "${1}"
 			die "${1}"
@@ -229,27 +232,30 @@
 
 	EXPORT_FUNCTIONS pkg_setup
 
-	_PYTHON_USE_WITH_ATOM=""
+	_PYTHON_USE_WITH_ATOMS_ARRAY=()
 	if [[ -n "${PYTHON_USE_WITH}" ]]; then
 		for _PYTHON_ATOM in "${_PYTHON_ATOMS[@]}"; do
-			_PYTHON_USE_WITH_ATOM+="${_PYTHON_USE_WITH_ATOM:+ }${_PYTHON_ATOM}[${PYTHON_USE_WITH/ /,}]"
+			_PYTHON_USE_WITH_ATOMS_ARRAY+=("${_PYTHON_ATOM}[${PYTHON_USE_WITH/ /,}]")
 		done
-		_PYTHON_USE_WITH_ATOM="|| ( ${_PYTHON_USE_WITH_ATOM} )"
 	elif [[ -n "${PYTHON_USE_WITH_OR}" ]]; then
 		for _USE_flag in ${PYTHON_USE_WITH_OR}; do
 			for _PYTHON_ATOM in "${_PYTHON_ATOMS[@]}"; do
-				_PYTHON_USE_WITH_ATOM+="${_PYTHON_USE_WITH_ATOM:+ }${_PYTHON_ATOM}[${_USE_flag}]"
+				_PYTHON_USE_WITH_ATOMS_ARRAY+=("${_PYTHON_ATOM}[${_USE_flag}]")
 			done
 		done
 		unset _USE_flag
-		_PYTHON_USE_WITH_ATOM="|| ( ${_PYTHON_USE_WITH_ATOM} )"
+	fi
+	if [[ "${#_PYTHON_USE_WITH_ATOMS_ARRAY[@]}" -gt 1 ]]; then
+		_PYTHON_USE_WITH_ATOMS="|| ( ${_PYTHON_USE_WITH_ATOMS_ARRAY[@]} )"
+	else
+		_PYTHON_USE_WITH_ATOMS="${_PYTHON_USE_WITH_ATOMS_ARRAY[@]}"
 	fi
 	if [[ -n "${PYTHON_USE_WITH_OPT}" ]]; then
-		_PYTHON_USE_WITH_ATOM="${PYTHON_USE_WITH_OPT}? ( ${_PYTHON_USE_WITH_ATOM} )"
+		_PYTHON_USE_WITH_ATOMS="${PYTHON_USE_WITH_OPT}? ( ${_PYTHON_USE_WITH_ATOMS} )"
 	fi
-	DEPEND+=" ${_PYTHON_USE_WITH_ATOM}"
-	RDEPEND+=" ${_PYTHON_USE_WITH_ATOM}"
-	unset _PYTHON_ATOM _PYTHON_USE_WITH_ATOM
+	DEPEND+=" ${_PYTHON_USE_WITH_ATOMS}"
+	RDEPEND+=" ${_PYTHON_USE_WITH_ATOMS}"
+	unset _PYTHON_ATOM _PYTHON_USE_WITH_ATOMS _PYTHON_USE_WITH_ATOMS_ARRAY
 fi
 
 unset _PYTHON_ATOMS
@@ -1263,20 +1269,23 @@
 }
 
 # @FUNCTION: python_get_version
-# @USAGE: [-f|--final-ABI] [--major] [--minor] [--micro]
+# @USAGE: [-f|--final-ABI] [--full] [--major] [--minor] [--micro]
 # @DESCRIPTION:
 # Print Python version.
-# --major, --minor and --micro options cannot be specified simultaneously.
-# If --major, --minor and --micro options are not specified, then "${major_version}.${minor_version}" is printed.
+# --full, --major, --minor and --micro options cannot be specified simultaneously.
+# If --full, --major, --minor and --micro options are not specified, then "${major_version}.${minor_version}" is printed.
 # If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
 python_get_version() {
-	local final_ABI="0" major="0" minor="0" micro="0" python_command
+	local final_ABI="0" full="0" major="0" minor="0" micro="0" python_command
 
 	while (($#)); do
 		case "$1" in
 			-f|--final-ABI)
 				final_ABI="1"
 				;;
+			--full)
+				full="1"
+				;;
 			--major)
 				major="1"
 				;;
@@ -1296,17 +1305,27 @@
 		shift
 	done
 
-	if [[ "$((${major} + ${minor} + ${micro}))" -gt 1 ]]; then
-		die "${FUNCNAME}(): '--major', '--minor' or '--micro' options cannot be specified simultaneously"
+	if [[ "$((${full} + ${major} + ${minor} + ${micro}))" -gt 1 ]]; then
+		die "${FUNCNAME}(): '--full', '--major', '--minor' or '--micro' options cannot be specified simultaneously"
 	fi
 
-	if [[ "${major}" == "1" ]]; then
+	if [[ "${full}" == "1" ]]; then
+		python_command="from sys import version_info; print('.'.join(str(x) for x in version_info[:3]))"
+	elif [[ "${major}" == "1" ]]; then
 		python_command="from sys import version_info; print(version_info[0])"
 	elif [[ "${minor}" == "1" ]]; then
 		python_command="from sys import version_info; print(version_info[1])"
 	elif [[ "${micro}" == "1" ]]; then
 		python_command="from sys import version_info; print(version_info[2])"
 	else
+		if [[ -n "${PYTHON_ABI}" && "${final_ABI}" == "0" ]]; then
+			if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
+				echo "${PYTHON_ABI}"
+			elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
+				echo "${PYTHON_ABI%-jython}"
+			fi
+			return
+		fi
 		python_command="from sys import version_info; print('.'.join(str(x) for x in version_info[:2]))"
 	fi
 
@@ -1489,10 +1508,22 @@
 # Supported values: 0, 1, 2, 3, 4.
 PYTHON_TEST_VERBOSITY="${PYTHON_TEST_VERBOSITY:-1}"
 
+_python_test_hook() {
+	if [[ "$#" -ne 1 ]]; then
+		die "${FUNCNAME}() requires 1 argument"
+	fi
+
+	if [[ -n "${SUPPORT_PYTHON_ABIS}" && "$(type -t "${FUNCNAME[3]}_$1_hook")" == "function" ]]; then
+		"${FUNCNAME[3]}_$1_hook"
+	fi
+}
+
 # @FUNCTION: python_execute_nosetests
 # @USAGE: [-P|--PYTHONPATH PYTHONPATH] [-s|--separate-build-dirs] [--] [arguments]
 # @DESCRIPTION:
 # Execute nosetests for all enabled versions of Python.
+# In ebuilds of packages supporting installation for multiple versions of Python, this function
+# calls python_execute_nosetests_pre_hook() and python_execute_nosetests_post_hook(), if they are defined.
 python_execute_nosetests() {
 	_python_set_color_variables
 
@@ -1531,13 +1562,17 @@
 			fi
 		fi
 
+		_python_test_hook pre
+
 		if [[ -n "${evaluated_PYTHONPATH}" ]]; then
 			echo ${_BOLD}PYTHONPATH="${evaluated_PYTHONPATH}" nosetests --verbosity="${PYTHON_TEST_VERBOSITY}" "$@"${_NORMAL}
-			PYTHONPATH="${evaluated_PYTHONPATH}" nosetests --verbosity="${PYTHON_TEST_VERBOSITY}" "$@"
+			PYTHONPATH="${evaluated_PYTHONPATH}" nosetests --verbosity="${PYTHON_TEST_VERBOSITY}" "$@" || return "$?"
 		else
 			echo ${_BOLD}nosetests --verbosity="${PYTHON_TEST_VERBOSITY}" "$@"${_NORMAL}
-			nosetests --verbosity="${PYTHON_TEST_VERBOSITY}" "$@"
+			nosetests --verbosity="${PYTHON_TEST_VERBOSITY}" "$@" || return "$?"
 		fi
+
+		_python_test_hook post
 	}
 	if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
 		python_execute_function ${separate_build_dirs:+-s} python_test_function "$@"
@@ -1555,6 +1590,8 @@
 # @USAGE: [-P|--PYTHONPATH PYTHONPATH] [-s|--separate-build-dirs] [--] [arguments]
 # @DESCRIPTION:
 # Execute py.test for all enabled versions of Python.
+# In ebuilds of packages supporting installation for multiple versions of Python, this function
+# calls python_execute_py.test_pre_hook() and python_execute_py.test_post_hook(), if they are defined.
 python_execute_py.test() {
 	_python_set_color_variables
 
@@ -1593,13 +1630,17 @@
 			fi
 		fi
 
+		_python_test_hook pre
+
 		if [[ -n "${evaluated_PYTHONPATH}" ]]; then
 			echo ${_BOLD}PYTHONPATH="${evaluated_PYTHONPATH}" py.test $([[ "${PYTHON_TEST_VERBOSITY}" -ge 2 ]] && echo -v) "$@"${_NORMAL}
-			PYTHONPATH="${evaluated_PYTHONPATH}" py.test $([[ "${PYTHON_TEST_VERBOSITY}" -ge 2 ]] && echo -v) "$@"
+			PYTHONPATH="${evaluated_PYTHONPATH}" py.test $([[ "${PYTHON_TEST_VERBOSITY}" -ge 2 ]] && echo -v) "$@" || return "$?"
 		else
 			echo ${_BOLD}py.test $([[ "${PYTHON_TEST_VERBOSITY}" -gt 1 ]] && echo -v) "$@"${_NORMAL}
-			py.test $([[ "${PYTHON_TEST_VERBOSITY}" -gt 1 ]] && echo -v) "$@"
+			py.test $([[ "${PYTHON_TEST_VERBOSITY}" -gt 1 ]] && echo -v) "$@" || return "$?"
 		fi
+
+		_python_test_hook post
 	}
 	if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
 		python_execute_function ${separate_build_dirs:+-s} python_test_function "$@"
@@ -1617,6 +1658,8 @@
 # @USAGE: [-P|--PYTHONPATH PYTHONPATH] [-s|--separate-build-dirs] [--] [arguments]
 # @DESCRIPTION:
 # Execute trial for all enabled versions of Python.
+# In ebuilds of packages supporting installation for multiple versions of Python, this function
+# calls python_execute_trial_pre_hook() and python_execute_trial_post_hook(), if they are defined.
 python_execute_trial() {
 	_python_set_color_variables
 
@@ -1655,13 +1698,17 @@
 			fi
 		fi
 
+		_python_test_hook pre
+
 		if [[ -n "${evaluated_PYTHONPATH}" ]]; then
 			echo ${_BOLD}PYTHONPATH="${evaluated_PYTHONPATH}" trial $([[ "${PYTHON_TEST_VERBOSITY}" -ge 4 ]] && echo --spew) "$@"${_NORMAL}
-			PYTHONPATH="${evaluated_PYTHONPATH}" trial $([[ "${PYTHON_TEST_VERBOSITY}" -ge 4 ]] && echo --spew) "$@"
+			PYTHONPATH="${evaluated_PYTHONPATH}" trial $([[ "${PYTHON_TEST_VERBOSITY}" -ge 4 ]] && echo --spew) "$@" || return "$?"
 		else
 			echo ${_BOLD}trial $([[ "${PYTHON_TEST_VERBOSITY}" -ge 4 ]] && echo --spew) "$@"${_NORMAL}
-			trial $([[ "${PYTHON_TEST_VERBOSITY}" -ge 4 ]] && echo --spew) "$@"
+			trial $([[ "${PYTHON_TEST_VERBOSITY}" -ge 4 ]] && echo --spew) "$@" || return "$?"
 		fi
+
+		_python_test_hook post
 	}
 	if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
 		python_execute_function ${separate_build_dirs:+-s} python_test_function "$@"
@@ -1704,17 +1751,15 @@
 #
 # If supplied with arguments, it will recompile all modules recursively
 # in the supplied directory.
-# This function should only be run in pkg_postinst().
 #
 # Options passed to this function are passed to compileall.py.
 #
-# Example:
-#         python_mod_optimize ctypesgencore
+# This function can be used only in pkg_postinst() phase.
 python_mod_optimize() {
 	_python_initialize_prefix_variables
 
 	# Check if phase is pkg_postinst().
-	[[ ${EBUILD_PHASE} != "postinst" ]] && die "${FUNCNAME}() should only be run in pkg_postinst()"
+	[[ ${EBUILD_PHASE} != "postinst" ]] && die "${FUNCNAME}() can be used only in pkg_postinst() phase"
 
 	if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
 		local dir file options=() other_dirs=() other_files=() previous_PYTHON_ABI="${PYTHON_ABI}" PYTHON_ABI="${PYTHON_ABI}" return_code root site_packages_absolute_dirs=() site_packages_dirs=() site_packages_absolute_files=() site_packages_files=()
@@ -1884,7 +1929,7 @@
 # determine if they are orphaned (i.e. their corresponding .py files are missing.)
 # If they are, then it will remove their corresponding .pyc and .pyo files.
 #
-# This function should only be run in pkg_postrm().
+# This function can be used only in pkg_postrm() phase.
 python_mod_cleanup() {
 	_python_initialize_prefix_variables
 	_python_set_color_variables
@@ -1892,7 +1937,7 @@
 	local path py_file PYTHON_ABI="${PYTHON_ABI}" SEARCH_PATH=() root
 
 	# Check if phase is pkg_postrm().
-	[[ ${EBUILD_PHASE} != "postrm" ]] && die "${FUNCNAME}() should only be run in pkg_postrm()"
+	[[ ${EBUILD_PHASE} != "postrm" ]] && die "${FUNCNAME}() can be used only in pkg_postrm() phase"
 
 	# Strip trailing slash from ROOT.
 	root="${EROOT%/}"
@@ -1980,6 +2025,15 @@
 		die "${FUNCNAME}() cannot be used in this EAPI"
 	fi
 
+	_python_set_color_variables
+
+	if [[ "${FUNCNAME[1]}" != "distutils_python_version" ]]; then
+		eerror
+		eerror "${_RED}Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01.${_NORMAL}"
+		eerror "${_RED}Use PYTHON() instead of python variable. Use python_get_*() instead of PYVER* variables.${_NORMAL}"
+		eerror
+	fi
+
 	[[ -n "${PYVER}" ]] && return 0
 	local tmpstr
 	python="${python:-${EPREFIX}/usr/bin/python}"
@@ -2011,6 +2065,13 @@
 		die "${FUNCNAME}() cannot be used in this EAPI"
 	fi
 
+	_python_set_color_variables
+
+	eerror
+	eerror "${_RED}Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01.${_NORMAL}"
+	eerror "${_RED}Use USE dependencies and/or has_version() instead of ${FUNCNAME}().${_NORMAL}"
+	eerror
+
 	if [[ "$#" -ne 1 ]]; then
 		die "${FUNCNAME}() requires 1 argument"
 	fi
@@ -2027,6 +2088,15 @@
 		die "${FUNCNAME}() cannot be used in this EAPI"
 	fi
 
+	_python_set_color_variables
+
+	if [[ "${FUNCNAME[1]}" != "distutils_python_tkinter" ]]; then
+		eerror
+		eerror "${_RED}Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01.${_NORMAL}"
+		eerror "${_RED}Use PYTHON_USE_WITH=\"xml\" and python_pkg_setup() instead of ${FUNCNAME}().${_NORMAL}"
+		eerror
+	fi
+
 	if ! "$(PYTHON ${PYTHON_ABI})" -c "from sys import version_info
 if version_info[0] == 3:
 	import tkinter
@@ -2043,7 +2113,7 @@
 # @USAGE: <file> [more files ...]
 # @DESCRIPTION:
 # Given filenames, it will pre-compile the module's .pyc and .pyo.
-# This function should only be run in pkg_postinst()
+# This function can be used only in pkg_postinst() phase.
 #
 # Example:
 #         python_mod_compile /usr/lib/python2.3/site-packages/pygoogle.py
@@ -2059,7 +2129,7 @@
 	local f myroot myfiles=()
 
 	# Check if phase is pkg_postinst()
-	[[ ${EBUILD_PHASE} != postinst ]] && die "${FUNCNAME}() should only be run in pkg_postinst()"
+	[[ ${EBUILD_PHASE} != postinst ]] && die "${FUNCNAME}() can be used only in pkg_postinst() phase"
 
 	# strip trailing slash
 	myroot="${EROOT%/}"






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2010-03-12 18:27 Petteri Raty (betelgeuse)
  0 siblings, 0 replies; 108+ messages in thread
From: Petteri Raty (betelgeuse) @ 2010-03-12 18:27 UTC (permalink / raw
  To: gentoo-commits

betelgeuse    10/03/12 18:27:01

  Modified:             python.eclass
  Log:
  Using terminal colors to modify eerror output is not allowed. Switch to using einfo for deprecated functions so that they don't get logged by default for users.

Revision  Changes    Path
1.93                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.93&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.93&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.92&r2=1.93

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.92
retrieving revision 1.93
diff -u -r1.92 -r1.93
--- python.eclass	4 Mar 2010 17:42:11 -0000	1.92
+++ python.eclass	12 Mar 2010 18:27:01 -0000	1.93
@@ -1,6 +1,6 @@
 # Copyright 1999-2010 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.92 2010/03/04 17:42:11 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.93 2010/03/12 18:27:01 betelgeuse Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -2025,13 +2025,11 @@
 		die "${FUNCNAME}() cannot be used in this EAPI"
 	fi
 
-	_python_set_color_variables
-
 	if [[ "${FUNCNAME[1]}" != "distutils_python_version" ]]; then
-		eerror
-		eerror "${_RED}Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01.${_NORMAL}"
-		eerror "${_RED}Use PYTHON() instead of python variable. Use python_get_*() instead of PYVER* variables.${_NORMAL}"
-		eerror
+		einfo
+		einfo "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01."
+		einfo "Use PYTHON() instead of python variable. Use python_get_*() instead of PYVER* variables."
+		einfo
 	fi
 
 	[[ -n "${PYVER}" ]] && return 0
@@ -2065,12 +2063,10 @@
 		die "${FUNCNAME}() cannot be used in this EAPI"
 	fi
 
-	_python_set_color_variables
-
-	eerror
-	eerror "${_RED}Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01.${_NORMAL}"
-	eerror "${_RED}Use USE dependencies and/or has_version() instead of ${FUNCNAME}().${_NORMAL}"
-	eerror
+	einfo
+	einfo "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01."
+	einfo "Use USE dependencies and/or has_version() instead of ${FUNCNAME}()."
+	einfo
 
 	if [[ "$#" -ne 1 ]]; then
 		die "${FUNCNAME}() requires 1 argument"
@@ -2088,13 +2084,11 @@
 		die "${FUNCNAME}() cannot be used in this EAPI"
 	fi
 
-	_python_set_color_variables
-
 	if [[ "${FUNCNAME[1]}" != "distutils_python_tkinter" ]]; then
-		eerror
-		eerror "${_RED}Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01.${_NORMAL}"
-		eerror "${_RED}Use PYTHON_USE_WITH=\"xml\" and python_pkg_setup() instead of ${FUNCNAME}().${_NORMAL}"
-		eerror
+		einfo
+		einfo "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01."
+		einfo "Use PYTHON_USE_WITH=\"xml\" and python_pkg_setup() instead of ${FUNCNAME}()."
+		einfo
 	fi
 
 	if ! "$(PYTHON ${PYTHON_ABI})" -c "from sys import version_info






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2010-03-13 13:46 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2010-03-13 13:46 UTC (permalink / raw
  To: gentoo-commits

arfrever    10/03/13 13:46:20

  Modified:             python.eclass
  Log:
  Improve phase functions.
  Simplify and improve validate_PYTHON_ABIS().
  Fix handling of ${S} ending in '/' in python_copy_sources() (bug #307943).
  Improve python_generate_wrapper_scripts().
  Improve python_convert_shebangs().
  Add python_clean_sitedirs().
  Simplify python_mod_cleanup().
  Improve deprecation warnings in python_version(), python_mod_exists() and python_tkinter_exists().

Revision  Changes    Path
1.94                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.94&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.94&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.93&r2=1.94

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.93
retrieving revision 1.94
diff -u -r1.93 -r1.94
--- python.eclass	12 Mar 2010 18:27:01 -0000	1.93
+++ python.eclass	13 Mar 2010 13:46:20 -0000	1.94
@@ -1,6 +1,6 @@
 # Copyright 1999-2010 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.93 2010/03/12 18:27:01 betelgeuse Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.94 2010/03/13 13:46:20 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -273,13 +273,15 @@
 # @DESCRIPTION:
 # Set this to export phase functions for the following ebuild phases:
 # src_prepare, src_configure, src_compile, src_test, src_install.
-if ! has "${EAPI:-0}" 0 1 && [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
+if ! has "${EAPI:-0}" 0 1; then
 	python_src_prepare() {
 		python_copy_sources
 	}
 
 	for python_default_function in src_configure src_compile src_test src_install; do
-		eval "python_${python_default_function}() { python_execute_function -d -s; }"
+		eval "python_${python_default_function}() {
+			python_execute_function -d -s \"\$@\"
+		}"
 	done
 	unset python_default_function
 
@@ -308,7 +310,7 @@
 		PYTHON_ABI_SUPPORTED_VALUES="${_CPYTHON2_SUPPORTED_ABIS[@]} ${_CPYTHON3_SUPPORTED_ABIS[@]} ${_JYTHON_SUPPORTED_ABIS[@]}"
 
 		if [[ "$(declare -p USE_PYTHON 2> /dev/null)" == "declare -x USE_PYTHON="* ]]; then
-			local python2_enabled="0" python3_enabled="0"
+			local cpython_enabled="0"
 
 			if [[ -z "${USE_PYTHON}" ]]; then
 				die "USE_PYTHON variable is empty"
@@ -319,11 +321,8 @@
 					die "USE_PYTHON variable contains invalid value '${PYTHON_ABI}'"
 				fi
 
-				if has "${PYTHON_ABI}" "${_CPYTHON2_SUPPORTED_ABIS[@]}"; then
-					python2_enabled="1"
-				fi
-				if has "${PYTHON_ABI}" "${_CPYTHON3_SUPPORTED_ABIS[@]}"; then
-					python3_enabled="1"
+				if has "${PYTHON_ABI}" "${_CPYTHON2_SUPPORTED_ABIS[@]}" "${_CPYTHON3_SUPPORTED_ABIS[@]}"; then
+					cpython_enabled="1"
 				fi
 
 				support_ABI="1"
@@ -340,13 +339,7 @@
 				die "USE_PYTHON variable does not enable any version of Python supported by ${CATEGORY}/${PF}"
 			fi
 
-			if [[ "${python2_enabled}" == "0" ]]; then
-				ewarn "USE_PYTHON variable does not enable any version of Python 2. This configuration is unsupported."
-			fi
-			if [[ "${python3_enabled}" == "0" ]]; then
-				ewarn "USE_PYTHON variable does not enable any version of Python 3. This configuration is unsupported."
-			fi
-			if [[ "${python2_enabled}" == "0" && "${python3_enabled}" == "0" ]]; then
+			if [[ "${cpython_enabled}" == "0" ]]; then
 				die "USE_PYTHON variable does not enable any version of CPython"
 			fi
 		else
@@ -496,9 +489,6 @@
 			die "${FUNCNAME}(): '${function}' function is not defined"
 		fi
 	else
-		if [[ "$#" -ne 0 ]]; then
-			die "${FUNCNAME}(): '--default-function' option and function name cannot be specified simultaneously"
-		fi
 		if has "${EAPI:-0}" 0 1; then
 			die "${FUNCNAME}(): '--default-function' option cannot be used in this EAPI"
 		fi
@@ -506,28 +496,28 @@
 		if [[ "${EBUILD_PHASE}" == "configure" ]]; then
 			if has "${EAPI}" 2 3; then
 				python_default_function() {
-					econf
+					econf "$@"
 				}
 			else
 				python_default_function() {
-					nonfatal econf
+					nonfatal econf "$@"
 				}
 			fi
 		elif [[ "${EBUILD_PHASE}" == "compile" ]]; then
 			python_default_function() {
-				emake
+				emake "$@"
 			}
 		elif [[ "${EBUILD_PHASE}" == "test" ]]; then
 			python_default_function() {
 				if emake -j1 -n check &> /dev/null; then
-					emake -j1 check
+					emake -j1 check "$@"
 				elif emake -j1 -n test &> /dev/null; then
-					emake -j1 test
+					emake -j1 test "$@"
 				fi
 			}
 		elif [[ "${EBUILD_PHASE}" == "install" ]]; then
 			python_default_function() {
-				emake DESTDIR="${D}" install
+				emake DESTDIR="${D}" install "$@"
 			}
 		else
 			die "${FUNCNAME}(): '--default-function' option cannot be used in this ebuild phase"
@@ -665,7 +655,7 @@
 		if [[ "${WORKDIR}" == "${S}" ]]; then
 			die "${FUNCNAME}() cannot be used"
 		fi
-		dirs=("${S}")
+		dirs=("${S%/}")
 	else
 		dirs=("$@")
 	fi
@@ -761,12 +751,12 @@
 		fi
 
 		if [[ "${quiet}" == "0" ]]; then
-			einfo "Generating '${file#${D%/}}' wrapper script"
+			einfo "Generating '${file#${ED%/}}' wrapper script"
 		fi
 
 		cat << EOF > "${file}"
 #!/usr/bin/env python
-# Gentoo '${file##*/}' wrapper script
+# Gentoo '${file##*/}' wrapper script generated by python_generate_wrapper_scripts()
 
 import os
 import re
@@ -774,6 +764,8 @@
 import sys
 
 EPYTHON_re = re.compile(r"^python(\d+\.\d+)$")
+python_shebang_re = re.compile(r"^#! *(${EPREFIX}/usr/bin/python|(${EPREFIX})?/usr/bin/env +(${EPREFIX}/usr/bin/)?python)")
+python_verification_output_re = re.compile("^GENTOO_PYTHON_TARGET_SCRIPT_PATH supported\n$")
 
 EOF
 		if [[ "$?" != "0" ]]; then
@@ -798,16 +790,16 @@
 		sys.stderr.write("Execution of 'eselect python show${eselect_python_option:+ }${eselect_python_option}' failed\n")
 		sys.exit(1)
 
-	eselect_output = eselect_process.stdout.read()
-	if not isinstance(eselect_output, str):
+	EPYTHON = eselect_process.stdout.read().rstrip("\n")
+	if not isinstance(EPYTHON, str):
 		# Python 3
-		eselect_output = eselect_output.decode()
+		EPYTHON = EPYTHON.decode()
 
-	EPYTHON_matched = EPYTHON_re.match(eselect_output)
+	EPYTHON_matched = EPYTHON_re.match(EPYTHON)
 	if EPYTHON_matched:
 		PYTHON_ABI = EPYTHON_matched.group(1)
 	else:
-		sys.stderr.write("'eselect python show${eselect_python_option:+ }${eselect_python_option}' printed unrecognized value '%s" % eselect_output)
+		sys.stderr.write("'eselect python show${eselect_python_option:+ }${eselect_python_option}' printed unrecognized value '%s" % EPYTHON)
 		sys.exit(1)
 EOF
 			if [[ "$?" != "0" ]]; then
@@ -823,16 +815,16 @@
 	sys.stderr.write("Execution of 'eselect python show${eselect_python_option:+ }${eselect_python_option}' failed\n")
 	sys.exit(1)
 
-eselect_output = eselect_process.stdout.read()
-if not isinstance(eselect_output, str):
+EPYTHON = eselect_process.stdout.read().rstrip("\n")
+if not isinstance(EPYTHON, str):
 	# Python 3
-	eselect_output = eselect_output.decode()
+	EPYTHON = EPYTHON.decode()
 
-EPYTHON_matched = EPYTHON_re.match(eselect_output)
+EPYTHON_matched = EPYTHON_re.match(EPYTHON)
 if EPYTHON_matched:
 	PYTHON_ABI = EPYTHON_matched.group(1)
 else:
-	sys.stderr.write("'eselect python show${eselect_python_option:+ }${eselect_python_option}' printed unrecognized value '%s" % eselect_output)
+	sys.stderr.write("'eselect python show${eselect_python_option:+ }${eselect_python_option}' printed unrecognized value '%s" % EPYTHON)
 	sys.exit(1)
 EOF
 			if [[ "$?" != "0" ]]; then
@@ -841,13 +833,47 @@
 		fi
 		cat << EOF >> "${file}"
 
-os.environ["PYTHON_SCRIPT_NAME"] = sys.argv[0]
-target_executable = "%s-%s" % (os.path.realpath(sys.argv[0]), PYTHON_ABI)
-if not os.path.exists(target_executable):
-	sys.stderr.write("'%s' does not exist\n" % target_executable)
+wrapper_script_path = os.path.realpath(sys.argv[0])
+target_executable_path = "%s-%s" % (wrapper_script_path, PYTHON_ABI)
+os.environ["GENTOO_PYTHON_WRAPPER_SCRIPT_PATH"] = sys.argv[0]
+os.environ["GENTOO_PYTHON_TARGET_SCRIPT_PATH"] = target_executable_path
+if not os.path.exists(target_executable_path):
+	sys.stderr.write("'%s' does not exist\n" % target_executable_path)
 	sys.exit(1)
 
-os.execv(target_executable, sys.argv)
+target_executable = open(target_executable_path, "rb")
+target_executable_first_line = target_executable.readline()
+if not isinstance(target_executable_first_line, str):
+	# Python 3
+	target_executable_first_line = target_executable_first_line.decode("utf_8", "replace")
+
+python_shebang_matched = python_shebang_re.match(target_executable_first_line)
+target_executable.close()
+
+if python_shebang_matched:
+	try:
+		python_interpreter_path = "${EPREFIX}/usr/bin/%s" % EPYTHON
+		os.environ["GENTOO_PYTHON_TARGET_SCRIPT_PATH_VERIFICATION"] = "1"
+		python_verification_process = subprocess.Popen([python_interpreter_path, "-c", "pass"], stdout=subprocess.PIPE)
+		del os.environ["GENTOO_PYTHON_TARGET_SCRIPT_PATH_VERIFICATION"]
+		if python_verification_process.wait() != 0:
+			raise ValueError
+
+		python_verification_output = python_verification_process.stdout.read()
+		if not isinstance(python_verification_output, str):
+			# Python 3
+			python_verification_output = python_verification_output.decode()
+
+		if not python_verification_output_re.match(python_verification_output):
+			raise ValueError
+
+		os.execv(python_interpreter_path, [python_interpreter_path] + sys.argv)
+	except:
+		pass
+	if "GENTOO_PYTHON_TARGET_SCRIPT_PATH_VERIFICATION" in os.environ:
+		del os.environ["GENTOO_PYTHON_TARGET_SCRIPT_PATH_VERIFICATION"]
+
+os.execv(target_executable_path, sys.argv)
 EOF
 		if [[ "$?" != "0" ]]; then
 			die "${FUNCNAME}(): Generation of '$1' failed"
@@ -1019,7 +1045,7 @@
 		elif [[ -z "${SUPPORT_PYTHON_ABIS}" ]]; then
 			PYTHON_ABI="$("${EPREFIX}/usr/bin/python" -c "${_PYTHON_ABI_EXTRACTION_COMMAND}")"
 		elif [[ -z "${PYTHON_ABI}" ]]; then
-			die "${FUNCNAME}(): Invalid usage: Python ABI not specified"
+			die "${FUNCNAME}(): Invalid usage: ${FUNCNAME}() should be used in ABI-specific local scope"
 		fi
 	elif [[ "$#" -eq 1 ]]; then
 		if [[ "${final_ABI}" == "1" ]]; then
@@ -1487,9 +1513,12 @@
 		[[ "${only_executables}" == "1" && ! -x "${file}" ]] && continue
 
 		if [[ "$(head -n1 "${file}")" =~ ^'#!'.*python ]]; then
+			[[ "$(sed -ne "2p" "${file}")" =~ ^"# Gentoo '".*"' wrapper script generated by python_generate_wrapper_scripts()"$ ]] && continue
+
 			if [[ "${quiet}" == "0" ]]; then
 				einfo "Converting shebang in '${file}'"
 			fi
+
 			sed -e "1s/python\([[:digit:]]\+\(\.[[:digit:]]\+\)\?\)\?/python${python_version}/" -i "${file}" || die "Conversion of shebang in '${file}' failed"
 
 			# Delete potential whitespace after "#!".
@@ -1498,6 +1527,15 @@
 	done
 }
 
+# @FUNCTION: python_clean_sitedirs
+# @DESCRIPTION:
+# Delete needless files in site-packages directories in ${ED}.
+python_clean_sitedirs() {
+	_python_initialize_prefix_variables
+
+	find "${ED}"usr/$(get_libdir)/python*/site-packages "(" -name "*.c" -o -name "*.h" -o -name "*.la" ")" -type f -print0 | xargs -0 rm -f
+}
+
 # ================================================================================================
 # ================================ FUNCTIONS FOR RUNNING OF TESTS ================================
 # ================================================================================================
@@ -1984,27 +2022,27 @@
 				if [[ "${REPLY}" == *[co] ]]; then
 					py_file="${REPLY%[co]}"
 					[[ -f "${py_file}" || (! -f "${py_file}c" && ! -f "${py_file}o") ]] && continue
-					einfo "${_BLUE}<<< ${py_file}[co]${_NORMAL}"
+					echo "${_BLUE}<<< ${py_file}[co]${_NORMAL}"
 					rm -f "${py_file}"[co]
 				elif [[ "${REPLY}" == *\$py.class ]]; then
 					py_file="${REPLY%\$py.class}.py"
 					[[ -f "${py_file}" || ! -f "${py_file%.py}\$py.class" ]] && continue
-					einfo "${_BLUE}<<< ${py_file%.py}\$py.class${_NORMAL}"
+					echo "${_BLUE}<<< ${py_file%.py}\$py.class${_NORMAL}"
 					rm -f "${py_file%.py}\$py.class"
 				fi
 			done
 
 			# Attempt to delete directories, which may be empty.
 			find "${path}" -type d | sort -r | while read -r dir; do
-				rmdir "${dir}" 2>/dev/null && einfo "${_CYAN}<<< ${dir}${_NORMAL}"
+				rmdir "${dir}" 2>/dev/null && echo "${_CYAN}<<< ${dir}${_NORMAL}"
 			done
 		elif [[ "${path}" == *.py && ! -f "${path}" ]]; then
 			if [[ (-f "${path}c" || -f "${path}o") ]]; then
-				einfo "${_BLUE}<<< ${path}[co]${_NORMAL}"
+				echo "${_BLUE}<<< ${path}[co]${_NORMAL}"
 				rm -f "${path}"[co]
 			fi
 			if [[ -f "${path%.py}\$py.class" ]]; then
-				einfo "${_BLUE}<<< ${path%.py}\$py.class${_NORMAL}"
+				echo "${_BLUE}<<< ${path%.py}\$py.class${_NORMAL}"
 				rm -f "${path%.py}\$py.class"
 			fi
 		fi
@@ -2029,6 +2067,7 @@
 		einfo
 		einfo "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01."
 		einfo "Use PYTHON() instead of python variable. Use python_get_*() instead of PYVER* variables."
+		einfo "The ebuild needs to be fixed. Please report a bug, if it has not been already reported."
 		einfo
 	fi
 
@@ -2066,6 +2105,7 @@
 	einfo
 	einfo "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01."
 	einfo "Use USE dependencies and/or has_version() instead of ${FUNCNAME}()."
+	einfo "The ebuild needs to be fixed. Please report a bug, if it has not been already reported."
 	einfo
 
 	if [[ "$#" -ne 1 ]]; then
@@ -2088,6 +2128,7 @@
 		einfo
 		einfo "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01."
 		einfo "Use PYTHON_USE_WITH=\"xml\" and python_pkg_setup() instead of ${FUNCNAME}()."
+		einfo "The ebuild needs to be fixed. Please report a bug, if it has not been already reported."
 		einfo
 	fi
 






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2010-03-20 17:59 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2010-03-20 17:59 UTC (permalink / raw
  To: gentoo-commits

arfrever    10/03/20 17:59:40

  Modified:             python.eclass
  Log:
  Fix handling of PYTHON_USE_WITH_OPT in python_pkg_setup().
  Improve error messages in some functions.
  Delete python_set_build_dir_symlink().
  Fix wrapper scripts generated by python_generate_wrapper_scripts().
  Improve deprecation warnings in python_version(), python_mod_exists() and python_tkinter_exists().

Revision  Changes    Path
1.95                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.95&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.95&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.94&r2=1.95

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.94
retrieving revision 1.95
diff -u -r1.94 -r1.95
--- python.eclass	13 Mar 2010 13:46:20 -0000	1.94
+++ python.eclass	20 Mar 2010 17:59:40 -0000	1.95
@@ -1,6 +1,6 @@
 # Copyright 1999-2010 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.94 2010/03/13 13:46:20 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.95 2010/03/20 17:59:40 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -198,7 +198,13 @@
 			die "${1}"
 		}
 
-		[[ ${PYTHON_USE_WITH_OPT} ]] && use !${PYTHON_USE_WITH_OPT} && return
+		if [[ "${PYTHON_USE_WITH_OPT}" ]]; then
+			if [[ "${PYTHON_USE_WITH_OPT}" == !* ]]; then
+				use ${PYTHON_USE_WITH_OPT#!} && return
+			else
+				use !${PYTHON_USE_WITH_OPT} && return
+			fi
+		fi
 
 		python_pkg_setup_check_USE_flags() {
 			local pyatom use
@@ -221,7 +227,7 @@
 			fi
 		}
 
-		if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
+		if _python_package_supporting_installation_for_multiple_python_abis; then
 			python_execute_function -q python_pkg_setup_check_USE_flags
 		else
 			python_pkg_setup_check_USE_flags
@@ -261,13 +267,13 @@
 unset _PYTHON_ATOMS
 
 # ================================================================================================
-# ======== FUNCTIONS FOR PACKAGES SUPPORTING INSTALLATION FOR MULTIPLE VERSIONS OF PYTHON ========
+# =========== FUNCTIONS FOR PACKAGES SUPPORTING INSTALLATION FOR MULTIPLE PYTHON ABIS ============
 # ================================================================================================
 
 # @ECLASS-VARIABLE: SUPPORT_PYTHON_ABIS
 # @DESCRIPTION:
 # Set this in EAPI <= 4 to indicate that current package supports installation for
-# multiple versions of Python.
+# multiple Python ABIs.
 
 # @ECLASS-VARIABLE: PYTHON_EXPORT_PHASE_FUNCTIONS
 # @DESCRIPTION:
@@ -275,11 +281,19 @@
 # src_prepare, src_configure, src_compile, src_test, src_install.
 if ! has "${EAPI:-0}" 0 1; then
 	python_src_prepare() {
+		if ! _python_package_supporting_installation_for_multiple_python_abis; then
+			die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
+		fi
+
 		python_copy_sources
 	}
 
 	for python_default_function in src_configure src_compile src_test src_install; do
 		eval "python_${python_default_function}() {
+			if ! _python_package_supporting_installation_for_multiple_python_abis; then
+				die \"\${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs\"
+			fi
+
 			python_execute_function -d -s \"\$@\"
 		}"
 	done
@@ -297,9 +311,8 @@
 # Ensure that PYTHON_ABIS variable has valid value.
 # This function usually should not be directly called in ebuilds.
 validate_PYTHON_ABIS() {
-	# Ensure that some functions cannot be accidentally successfully used in EAPI <= 4 without setting SUPPORT_PYTHON_ABIS variable.
-	if has "${EAPI:-0}" 0 1 2 3 4 && [[ -z "${SUPPORT_PYTHON_ABIS}" ]]; then
-		die "${FUNCNAME}() cannot be used in this EAPI without setting SUPPORT_PYTHON_ABIS variable"
+	if ! _python_package_supporting_installation_for_multiple_python_abis; then
+		die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
 	fi
 
 	_python_initial_sanity_checks
@@ -336,11 +349,11 @@
 			done
 
 			if [[ -z "${PYTHON_ABIS//[${IFS}]/}" ]]; then
-				die "USE_PYTHON variable does not enable any version of Python supported by ${CATEGORY}/${PF}"
+				die "USE_PYTHON variable does not enable any Python ABI supported by ${CATEGORY}/${PF}"
 			fi
 
 			if [[ "${cpython_enabled}" == "0" ]]; then
-				die "USE_PYTHON variable does not enable any version of CPython"
+				die "USE_PYTHON variable does not enable any CPython ABI"
 			fi
 		else
 			local python_version python2_version= python3_version= support_python_major_version
@@ -427,6 +440,10 @@
 # Execute specified function for each value of PYTHON_ABIS, optionally passing additional
 # arguments. The specified function can use PYTHON_ABI and BUILDDIR variables.
 python_execute_function() {
+	if ! _python_package_supporting_installation_for_multiple_python_abis; then
+		die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
+	fi
+
 	_python_set_color_variables
 
 	local action action_message action_message_template= default_function="0" failure_message failure_message_template= final_ABI="0" function i iterated_PYTHON_ABIS nonfatal="0" previous_directory previous_directory_stack previous_directory_stack_length PYTHON_ABI quiet="0" separate_build_dirs="0" source_dir=
@@ -525,6 +542,7 @@
 		function="python_default_function"
 	fi
 
+	# Ensure that python_execute_function() cannot be directly or indirectly called by python_execute_function().
 	for ((i = 1; i < "${#FUNCNAME[@]}"; i++)); do
 		if [[ "${FUNCNAME[${i}]}" == "${FUNCNAME}" ]]; then
 			die "${FUNCNAME}(): Invalid call stack"
@@ -605,7 +623,7 @@
 					ewarn "${_RED}${failure_message}${_NORMAL}"
 				fi
 				if [[ -z "${PYTHON_ABIS}" ]]; then
-					die "${function}() function failed with all enabled versions of Python"
+					die "${function}() function failed with all enabled Python ABIs"
 				fi
 			else
 				die "${failure_message}"
@@ -649,6 +667,10 @@
 # @DESCRIPTION:
 # Copy unpacked sources of current package to separate build directory for each Python ABI.
 python_copy_sources() {
+	if ! _python_package_supporting_installation_for_multiple_python_abis; then
+		die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
+	fi
+
 	local dir dirs=() PYTHON_ABI
 
 	if [[ "$#" -eq 0 ]]; then
@@ -668,21 +690,6 @@
 	done
 }
 
-# @FUNCTION: python_set_build_dir_symlink
-# @USAGE: <directory="build">
-# @DESCRIPTION:
-# Create build directory symlink.
-python_set_build_dir_symlink() {
-	local dir="$1"
-
-	[[ -z "${PYTHON_ABI}" ]] && die "PYTHON_ABI variable not set"
-	[[ -z "${dir}" ]] && dir="build"
-
-	# Do not delete preexistent directories.
-	rm -f "${dir}" || die "Deletion of '${dir}' failed"
-	ln -s "${dir}-${PYTHON_ABI}" "${dir}" || die "Creation of '${dir}' directory symlink failed"
-}
-
 # @FUNCTION: python_generate_wrapper_scripts
 # @USAGE: [-E|--respect-EPYTHON] [-f|--force] [-q|--quiet] [--] <file> [files]
 # @DESCRIPTION:
@@ -690,6 +697,10 @@
 # If --respect-EPYTHON option is specified, then generated wrapper scripts will
 # respect EPYTHON variable at run time.
 python_generate_wrapper_scripts() {
+	if ! _python_package_supporting_installation_for_multiple_python_abis; then
+		die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
+	fi
+
 	_python_initialize_prefix_variables
 
 	local eselect_python_option file force="0" quiet="0" PYTHON_ABI python2_enabled="0" python3_enabled="0" respect_EPYTHON="0"
@@ -790,16 +801,17 @@
 		sys.stderr.write("Execution of 'eselect python show${eselect_python_option:+ }${eselect_python_option}' failed\n")
 		sys.exit(1)
 
-	EPYTHON = eselect_process.stdout.read().rstrip("\n")
+	EPYTHON = eselect_process.stdout.read()
 	if not isinstance(EPYTHON, str):
 		# Python 3
 		EPYTHON = EPYTHON.decode()
+	EPYTHON = EPYTHON.rstrip("\n")
 
 	EPYTHON_matched = EPYTHON_re.match(EPYTHON)
 	if EPYTHON_matched:
 		PYTHON_ABI = EPYTHON_matched.group(1)
 	else:
-		sys.stderr.write("'eselect python show${eselect_python_option:+ }${eselect_python_option}' printed unrecognized value '%s" % EPYTHON)
+		sys.stderr.write("'eselect python show${eselect_python_option:+ }${eselect_python_option}' printed unrecognized value '%s'\n" % EPYTHON)
 		sys.exit(1)
 EOF
 			if [[ "$?" != "0" ]]; then
@@ -815,16 +827,17 @@
 	sys.stderr.write("Execution of 'eselect python show${eselect_python_option:+ }${eselect_python_option}' failed\n")
 	sys.exit(1)
 
-EPYTHON = eselect_process.stdout.read().rstrip("\n")
+EPYTHON = eselect_process.stdout.read()
 if not isinstance(EPYTHON, str):
 	# Python 3
 	EPYTHON = EPYTHON.decode()
+EPYTHON = EPYTHON.rstrip("\n")
 
 EPYTHON_matched = EPYTHON_re.match(EPYTHON)
 if EPYTHON_matched:
 	PYTHON_ABI = EPYTHON_matched.group(1)
 else:
-	sys.stderr.write("'eselect python show${eselect_python_option:+ }${eselect_python_option}' printed unrecognized value '%s" % EPYTHON)
+	sys.stderr.write("'eselect python show${eselect_python_option:+ }${eselect_python_option}' printed unrecognized value '%s'\n" % EPYTHON)
 	sys.exit(1)
 EOF
 			if [[ "$?" != "0" ]]; then
@@ -883,7 +896,7 @@
 }
 
 # ================================================================================================
-# ====== FUNCTIONS FOR PACKAGES NOT SUPPORTING INSTALLATION FOR MULTIPLE VERSIONS OF PYTHON ======
+# ========= FUNCTIONS FOR PACKAGES NOT SUPPORTING INSTALLATION FOR MULTIPLE PYTHON ABIS ==========
 # ================================================================================================
 
 # @FUNCTION: python_set_active_version
@@ -891,8 +904,8 @@
 # @DESCRIPTION:
 # Set specified version of CPython as active version of Python.
 python_set_active_version() {
-	if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
-		die "${FUNCNAME}() cannot be used in ebuilds of packages supporting installation for multiple versions of Python"
+	if _python_package_supporting_installation_for_multiple_python_abis; then
+		die "${FUNCNAME}() cannot be used in ebuilds of packages supporting installation for multiple Python ABIs"
 	fi
 
 	if [[ "$#" -ne 1 ]]; then
@@ -935,8 +948,8 @@
 # @DESCRIPTION: Mark current package for rebuilding by python-updater after
 # switching of active version of Python.
 python_need_rebuild() {
-	if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
-		die "${FUNCNAME}() cannot be used in ebuilds of packages supporting installation for multiple versions of Python"
+	if _python_package_supporting_installation_for_multiple_python_abis; then
+		die "${FUNCNAME}() cannot be used in ebuilds of packages supporting installation for multiple Python ABIs"
 	fi
 
 	export PYTHON_NEED_REBUILD="$(PYTHON --ABI)"
@@ -1023,8 +1036,8 @@
 
 	if [[ "$#" -eq 0 ]]; then
 		if [[ "${final_ABI}" == "1" ]]; then
-			if has "${EAPI:-0}" 0 1 2 3 4 && [[ -z "${SUPPORT_PYTHON_ABIS}" ]]; then
-				die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple versions of Python"
+			if ! _python_package_supporting_installation_for_multiple_python_abis; then
+				die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
 			fi
 			validate_PYTHON_ABIS
 			PYTHON_ABI="${PYTHON_ABIS##* }"
@@ -1042,7 +1055,7 @@
 			elif [[ "${PYTHON_ABI}" != "3."* ]]; then
 				die "${FUNCNAME}(): Internal error in \`eselect python show --python3\`"
 			fi
-		elif [[ -z "${SUPPORT_PYTHON_ABIS}" ]]; then
+		elif ! _python_package_supporting_installation_for_multiple_python_abis; then
 			PYTHON_ABI="$("${EPREFIX}/usr/bin/python" -c "${_PYTHON_ABI_EXTRACTION_COMMAND}")"
 		elif [[ -z "${PYTHON_ABI}" ]]; then
 			die "${FUNCNAME}(): Invalid usage: ${FUNCNAME}() should be used in ABI-specific local scope"
@@ -1108,6 +1121,9 @@
 	done
 
 	if [[ "${final_ABI}" == "1" ]]; then
+		if ! _python_package_supporting_installation_for_multiple_python_abis; then
+			die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
+		fi
 		PYTHON_ABI="$(PYTHON -f --ABI)"
 	elif [[ -z "${PYTHON_ABI}" ]]; then
 		PYTHON_ABI="$(PYTHON --ABI)"
@@ -1140,6 +1156,9 @@
 	done
 
 	if [[ "${final_ABI}" == "1" ]]; then
+		if ! _python_package_supporting_installation_for_multiple_python_abis; then
+			die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
+		fi
 		PYTHON_ABI="$(PYTHON -f --ABI)"
 	elif [[ -z "${PYTHON_ABI}" ]]; then
 		PYTHON_ABI="$(PYTHON --ABI)"
@@ -1176,6 +1195,9 @@
 	done
 
 	if [[ "${final_ABI}" == "1" ]]; then
+		if ! _python_package_supporting_installation_for_multiple_python_abis; then
+			die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
+		fi
 		PYTHON_ABI="$(PYTHON -f --ABI)"
 	elif [[ -z "${PYTHON_ABI}" ]]; then
 		PYTHON_ABI="$(PYTHON --ABI)"
@@ -1212,6 +1234,9 @@
 	done
 
 	if [[ "${final_ABI}" == "1" ]]; then
+		if ! _python_package_supporting_installation_for_multiple_python_abis; then
+			die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
+		fi
 		PYTHON_ABI="$(PYTHON -f --ABI)"
 	elif [[ -z "${PYTHON_ABI}" ]]; then
 		PYTHON_ABI="$(PYTHON --ABI)"
@@ -1235,6 +1260,9 @@
 	while (($#)); do
 		case "$1" in
 			-f|--final-ABI)
+				if ! _python_package_supporting_installation_for_multiple_python_abis; then
+					die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
+				fi
 				options+=("$1")
 				;;
 			-*)
@@ -1278,6 +1306,9 @@
 	done
 
 	if [[ "${final_ABI}" == "1" ]]; then
+		if ! _python_package_supporting_installation_for_multiple_python_abis; then
+			die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
+		fi
 		PYTHON_ABI="$(PYTHON -f --ABI)"
 	elif [[ -z "${PYTHON_ABI}" ]]; then
 		PYTHON_ABI="$(PYTHON --ABI)"
@@ -1356,6 +1387,9 @@
 	fi
 
 	if [[ "${final_ABI}" == "1" ]]; then
+		if ! _python_package_supporting_installation_for_multiple_python_abis; then
+			die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
+		fi
 		"$(PYTHON -f)" -c "${python_command}"
 	else
 		"$(PYTHON ${PYTHON_ABI})" -c "${python_command}"
@@ -1376,6 +1410,22 @@
 	fi
 }
 
+_python_package_supporting_installation_for_multiple_python_abis() {
+	if [[ "${EBUILD_PHASE}" == "depend" ]]; then
+		die "${FUNCNAME}() cannot be used in global scope"
+	fi
+
+	if has "${EAPI:-0}" 0 1 2 3 4; then
+		if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
+			return 0
+		else
+			return 1
+		fi
+	else
+		die "${FUNCNAME}(): Support for EAPI=\"${EAPI}\" not implemented"
+	fi
+}
+
 _python_initialize_prefix_variables() {
 	if has "${EAPI:-0}" 0 1 2; then
 		if [[ -n "${ROOT}" && -z "${EROOT}" ]]; then
@@ -1495,11 +1545,9 @@
 			files+=("${argument}")
 		elif [[ -d "${argument}" ]]; then
 			if [[ "${recursive}" == "1" ]]; then
-				if [[ "${only_executables}" == "1" ]]; then
-					files+=($(find "${argument}" -perm /111 -type f))
-				else
-					files+=($(find "${argument}" -type f))
-				fi
+				while read -d $'\0' -r file; do
+					files+=("${file}")
+				done < <(find "${argument}" $([[ "${only_executables}" == "1" ]] && echo -perm /111) -type f -print0)
 			else
 				die "${FUNCNAME}(): '${argument}' is not a regular file"
 			fi
@@ -1551,7 +1599,7 @@
 		die "${FUNCNAME}() requires 1 argument"
 	fi
 
-	if [[ -n "${SUPPORT_PYTHON_ABIS}" && "$(type -t "${FUNCNAME[3]}_$1_hook")" == "function" ]]; then
+	if _python_package_supporting_installation_for_multiple_python_abis && [[ "$(type -t "${FUNCNAME[3]}_$1_hook")" == "function" ]]; then
 		"${FUNCNAME[3]}_$1_hook"
 	fi
 }
@@ -1559,9 +1607,9 @@
 # @FUNCTION: python_execute_nosetests
 # @USAGE: [-P|--PYTHONPATH PYTHONPATH] [-s|--separate-build-dirs] [--] [arguments]
 # @DESCRIPTION:
-# Execute nosetests for all enabled versions of Python.
-# In ebuilds of packages supporting installation for multiple versions of Python, this function
-# calls python_execute_nosetests_pre_hook() and python_execute_nosetests_post_hook(), if they are defined.
+# Execute nosetests for all enabled Python ABIs.
+# In ebuilds of packages supporting installation for multiple Python ABIs, this function calls
+# python_execute_nosetests_pre_hook() and python_execute_nosetests_post_hook(), if they are defined.
 python_execute_nosetests() {
 	_python_set_color_variables
 
@@ -1612,7 +1660,7 @@
 
 		_python_test_hook post
 	}
-	if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
+	if _python_package_supporting_installation_for_multiple_python_abis; then
 		python_execute_function ${separate_build_dirs:+-s} python_test_function "$@"
 	else
 		if [[ -n "${separate_build_dirs}" ]]; then
@@ -1627,9 +1675,9 @@
 # @FUNCTION: python_execute_py.test
 # @USAGE: [-P|--PYTHONPATH PYTHONPATH] [-s|--separate-build-dirs] [--] [arguments]
 # @DESCRIPTION:
-# Execute py.test for all enabled versions of Python.
-# In ebuilds of packages supporting installation for multiple versions of Python, this function
-# calls python_execute_py.test_pre_hook() and python_execute_py.test_post_hook(), if they are defined.
+# Execute py.test for all enabled Python ABIs.
+# In ebuilds of packages supporting installation for multiple Python ABIs, this function calls
+# python_execute_py.test_pre_hook() and python_execute_py.test_post_hook(), if they are defined.
 python_execute_py.test() {
 	_python_set_color_variables
 
@@ -1680,7 +1728,7 @@
 
 		_python_test_hook post
 	}
-	if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
+	if _python_package_supporting_installation_for_multiple_python_abis; then
 		python_execute_function ${separate_build_dirs:+-s} python_test_function "$@"
 	else
 		if [[ -n "${separate_build_dirs}" ]]; then
@@ -1695,8 +1743,8 @@
 # @FUNCTION: python_execute_trial
 # @USAGE: [-P|--PYTHONPATH PYTHONPATH] [-s|--separate-build-dirs] [--] [arguments]
 # @DESCRIPTION:
-# Execute trial for all enabled versions of Python.
-# In ebuilds of packages supporting installation for multiple versions of Python, this function
+# Execute trial for all enabled Python ABIs.
+# In ebuilds of packages supporting installation for multiple Python ABIs, this function
 # calls python_execute_trial_pre_hook() and python_execute_trial_post_hook(), if they are defined.
 python_execute_trial() {
 	_python_set_color_variables
@@ -1748,7 +1796,7 @@
 
 		_python_test_hook post
 	}
-	if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
+	if _python_package_supporting_installation_for_multiple_python_abis; then
 		python_execute_function ${separate_build_dirs:+-s} python_test_function "$@"
 	else
 		if [[ -n "${separate_build_dirs}" ]]; then
@@ -1797,9 +1845,9 @@
 	_python_initialize_prefix_variables
 
 	# Check if phase is pkg_postinst().
-	[[ ${EBUILD_PHASE} != "postinst" ]] && die "${FUNCNAME}() can be used only in pkg_postinst() phase"
+	[[ "${EBUILD_PHASE}" != "postinst" ]] && die "${FUNCNAME}() can be used only in pkg_postinst() phase"
 
-	if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
+	if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
 		local dir file options=() other_dirs=() other_files=() previous_PYTHON_ABI="${PYTHON_ABI}" PYTHON_ABI="${PYTHON_ABI}" return_code root site_packages_absolute_dirs=() site_packages_dirs=() site_packages_absolute_files=() site_packages_files=()
 
 		# Strip trailing slash from ROOT.
@@ -1975,13 +2023,13 @@
 	local path py_file PYTHON_ABI="${PYTHON_ABI}" SEARCH_PATH=() root
 
 	# Check if phase is pkg_postrm().
-	[[ ${EBUILD_PHASE} != "postrm" ]] && die "${FUNCNAME}() can be used only in pkg_postrm() phase"
+	[[ "${EBUILD_PHASE}" != "postrm" ]] && die "${FUNCNAME}() can be used only in pkg_postrm() phase"
 
 	# Strip trailing slash from ROOT.
 	root="${EROOT%/}"
 
 	if (($#)); then
-		if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
+		if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
 			while (($#)); do
 				if ! _python_implementation && [[ "$1" =~ ^"${EPREFIX}"/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then
 					die "${FUNCNAME}() does not support absolute paths of directories/files in site-packages directories"
@@ -2058,17 +2106,25 @@
 # Run without arguments and it will export the version of python
 # currently in use as $PYVER; sets PYVER/PYVER_MAJOR/PYVER_MINOR
 python_version() {
-	if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
+	if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
 		eerror "Use PYTHON() and/or python_get_*() instead of ${FUNCNAME}()."
 		die "${FUNCNAME}() cannot be used in this EAPI"
 	fi
 
+	_python_set_color_variables
+
 	if [[ "${FUNCNAME[1]}" != "distutils_python_version" ]]; then
-		einfo
-		einfo "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01."
-		einfo "Use PYTHON() instead of python variable. Use python_get_*() instead of PYVER* variables."
-		einfo "The ebuild needs to be fixed. Please report a bug, if it has not been already reported."
-		einfo
+		echo
+		echo " ${_RED}*${_NORMAL} ${_RED}Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01.${_NORMAL}"
+		echo " ${_RED}*${_NORMAL} ${_RED}Use PYTHON() instead of python variable. Use python_get_*() instead of PYVER* variables.${_NORMAL}"
+		echo " ${_RED}*${_NORMAL} ${_RED}The ebuild needs to be fixed. Please report a bug, if it has not been already reported.${_NORMAL}"
+		echo
+
+		einfo &> /dev/null
+		einfo "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01." &> /dev/null
+		einfo "Use PYTHON() instead of python variable. Use python_get_*() instead of PYVER* variables." &> /dev/null
+		einfo "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." &> /dev/null
+		einfo &> /dev/null
 	fi
 
 	[[ -n "${PYVER}" ]] && return 0
@@ -2097,16 +2153,22 @@
 #             echo "gtk support enabled"
 #         fi
 python_mod_exists() {
-	if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
+	if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
 		eerror "Use USE dependencies and/or has_version() instead of ${FUNCNAME}()."
 		die "${FUNCNAME}() cannot be used in this EAPI"
 	fi
 
-	einfo
-	einfo "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01."
-	einfo "Use USE dependencies and/or has_version() instead of ${FUNCNAME}()."
-	einfo "The ebuild needs to be fixed. Please report a bug, if it has not been already reported."
-	einfo
+	echo
+	echo " ${_RED}*${_NORMAL} ${_RED}Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01.${_NORMAL}"
+	echo " ${_RED}*${_NORMAL} ${_RED}Use USE dependencies and/or has_version() instead of ${FUNCNAME}().${_NORMAL}"
+	echo " ${_RED}*${_NORMAL} ${_RED}The ebuild needs to be fixed. Please report a bug, if it has not been already reported.${_NORMAL}"
+	echo
+
+	einfo &> /dev/null
+	einfo "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01." &> /dev/null
+	einfo "Use USE dependencies and/or has_version() instead of ${FUNCNAME}()." &> /dev/null
+	einfo "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." &> /dev/null
+	einfo &> /dev/null
 
 	if [[ "$#" -ne 1 ]]; then
 		die "${FUNCNAME}() requires 1 argument"
@@ -2119,17 +2181,23 @@
 # Run without arguments, checks if Python was compiled with Tkinter
 # support.  If not, prints an error message and dies.
 python_tkinter_exists() {
-	if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
+	if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
 		eerror "Use PYTHON_USE_WITH=\"xml\" and python_pkg_setup() instead of ${FUNCNAME}()."
 		die "${FUNCNAME}() cannot be used in this EAPI"
 	fi
 
 	if [[ "${FUNCNAME[1]}" != "distutils_python_tkinter" ]]; then
-		einfo
-		einfo "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01."
-		einfo "Use PYTHON_USE_WITH=\"xml\" and python_pkg_setup() instead of ${FUNCNAME}()."
-		einfo "The ebuild needs to be fixed. Please report a bug, if it has not been already reported."
-		einfo
+		echo
+		echo " ${_RED}*${_NORMAL} ${_RED}Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01.${_NORMAL}"
+		echo " ${_RED}*${_NORMAL} ${_RED}Use PYTHON_USE_WITH=\"xml\" and python_pkg_setup() instead of ${FUNCNAME}().${_NORMAL}"
+		echo " ${_RED}*${_NORMAL} ${_RED}The ebuild needs to be fixed. Please report a bug, if it has not been already reported.${_NORMAL}"
+		echo
+
+		einfo &> /dev/null
+		einfo "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01." &> /dev/null
+		einfo "Use PYTHON_USE_WITH=\"xml\" and python_pkg_setup() instead of ${FUNCNAME}()." &> /dev/null
+		einfo "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." &> /dev/null
+		einfo &> /dev/null
 	fi
 
 	if ! "$(PYTHON ${PYTHON_ABI})" -c "from sys import version_info
@@ -2154,7 +2222,7 @@
 #         python_mod_compile /usr/lib/python2.3/site-packages/pygoogle.py
 #
 python_mod_compile() {
-	if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
+	if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
 		eerror "Use python_mod_optimize() instead of ${FUNCNAME}()."
 		die "${FUNCNAME}() cannot be used in this EAPI"
 	fi
@@ -2164,7 +2232,7 @@
 	local f myroot myfiles=()
 
 	# Check if phase is pkg_postinst()
-	[[ ${EBUILD_PHASE} != postinst ]] && die "${FUNCNAME}() can be used only in pkg_postinst() phase"
+	[[ "${EBUILD_PHASE}" != "postinst" ]] && die "${FUNCNAME}() can be used only in pkg_postinst() phase"
 
 	# strip trailing slash
 	myroot="${EROOT%/}"






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2010-03-26 15:23 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2010-03-26 15:23 UTC (permalink / raw
  To: gentoo-commits

arfrever    10/03/26 15:23:17

  Modified:             python.eclass
  Log:
  Set GENTOO_PYTHON_PROCESS_NAME environmental variable in wrapper scripts generated by python_generate_wrapper_scripts(), because Python process now unsets this variable at the beginning of execution of wrapper scripts, but this variable should be set also at the beginning of execution of target scripts.

Revision  Changes    Path
1.96                 eclass/python.eclass

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.96&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.96&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.95&r2=1.96

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.95
retrieving revision 1.96
diff -u -r1.95 -r1.96
--- python.eclass	20 Mar 2010 17:59:40 -0000	1.95
+++ python.eclass	26 Mar 2010 15:23:17 -0000	1.96
@@ -1,6 +1,6 @@
 # Copyright 1999-2010 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.95 2010/03/20 17:59:40 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.96 2010/03/26 15:23:17 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -848,6 +848,7 @@
 
 wrapper_script_path = os.path.realpath(sys.argv[0])
 target_executable_path = "%s-%s" % (wrapper_script_path, PYTHON_ABI)
+os.environ["GENTOO_PYTHON_PROCESS_NAME"] = os.path.basename(sys.argv[0])
 os.environ["GENTOO_PYTHON_WRAPPER_SCRIPT_PATH"] = sys.argv[0]
 os.environ["GENTOO_PYTHON_TARGET_SCRIPT_PATH"] = target_executable_path
 if not os.path.exists(target_executable_path):






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2010-05-17 18:01 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2010-05-17 18:01 UTC (permalink / raw
  To: gentoo-commits

arfrever    10/05/17 18:01:59

  Modified:             python.eclass
  Log:
  Fix handling of PYTHON_USE_WITH with more than 2 USE flags.
  Improve python_pkg_setup().
  Rename python_clean_sitedirs() to python_clean_installation_image().
  Improve python_clean_installation_image().
  Improve handling of -- option in phase functions.
  Add check for dev-lang/python in validate_PYTHON_ABIS() (bug #319651).
  Improve error message in python_copy_sources().
  Improve python_set_active_version().
  Improve error messages in PYTHON().
  Support PEP 3147 in python_mod_optimize(), python_mod_cleanup() and python_mod_compile().

Revision  Changes    Path
1.97                 eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.97&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.97&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.96&r2=1.97

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.96
retrieving revision 1.97
diff -u -r1.96 -r1.97
--- python.eclass	26 Mar 2010 15:23:17 -0000	1.96
+++ python.eclass	17 May 2010 18:01:59 -0000	1.97
@@ -1,6 +1,6 @@
 # Copyright 1999-2010 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.96 2010/03/26 15:23:17 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.97 2010/05/17 18:01:59 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -184,20 +184,158 @@
 # Set this to a name of a USE flag if you need to make either PYTHON_USE_WITH or
 # PYTHON_USE_WITH_OR atoms conditional under a USE flag.
 
+if ! has "${EAPI:-0}" 0 1 && [[ -n ${PYTHON_USE_WITH} || -n ${PYTHON_USE_WITH_OR} ]]; then
+	_PYTHON_USE_WITH_ATOMS_ARRAY=()
+	if [[ -n "${PYTHON_USE_WITH}" ]]; then
+		for _PYTHON_ATOM in "${_PYTHON_ATOMS[@]}"; do
+			_PYTHON_USE_WITH_ATOMS_ARRAY+=("${_PYTHON_ATOM}[${PYTHON_USE_WITH// /,}]")
+		done
+	elif [[ -n "${PYTHON_USE_WITH_OR}" ]]; then
+		for _USE_flag in ${PYTHON_USE_WITH_OR}; do
+			for _PYTHON_ATOM in "${_PYTHON_ATOMS[@]}"; do
+				_PYTHON_USE_WITH_ATOMS_ARRAY+=("${_PYTHON_ATOM}[${_USE_flag}]")
+			done
+		done
+		unset _USE_flag
+	fi
+	if [[ "${#_PYTHON_USE_WITH_ATOMS_ARRAY[@]}" -gt 1 ]]; then
+		_PYTHON_USE_WITH_ATOMS="|| ( ${_PYTHON_USE_WITH_ATOMS_ARRAY[@]} )"
+	else
+		_PYTHON_USE_WITH_ATOMS="${_PYTHON_USE_WITH_ATOMS_ARRAY[@]}"
+	fi
+	if [[ -n "${PYTHON_USE_WITH_OPT}" ]]; then
+		_PYTHON_USE_WITH_ATOMS="${PYTHON_USE_WITH_OPT}? ( ${_PYTHON_USE_WITH_ATOMS} )"
+	fi
+	DEPEND+=" ${_PYTHON_USE_WITH_ATOMS}"
+	RDEPEND+=" ${_PYTHON_USE_WITH_ATOMS}"
+	unset _PYTHON_ATOM _PYTHON_USE_WITH_ATOMS _PYTHON_USE_WITH_ATOMS_ARRAY
+fi
+
+unset _PYTHON_ATOMS
+
+# ================================================================================================
+# =================================== MISCELLANEOUS FUNCTIONS ====================================
+# ================================================================================================
+
+_python_implementation() {
+	if [[ "${CATEGORY}/${PN}" == "dev-lang/python" ]]; then
+		return 0
+	elif [[ "${CATEGORY}/${PN}" == "dev-java/jython" ]]; then
+		return 0
+	else
+		return 1
+	fi
+}
+
+_python_package_supporting_installation_for_multiple_python_abis() {
+	if [[ "${EBUILD_PHASE}" == "depend" ]]; then
+		die "${FUNCNAME}() cannot be used in global scope"
+	fi
+
+	if has "${EAPI:-0}" 0 1 2 3 4; then
+		if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
+			return 0
+		else
+			return 1
+		fi
+	else
+		die "${FUNCNAME}(): Support for EAPI=\"${EAPI}\" not implemented"
+	fi
+}
+
+_python_initialize_prefix_variables() {
+	if has "${EAPI:-0}" 0 1 2; then
+		if [[ -n "${ROOT}" && -z "${EROOT}" ]]; then
+			EROOT="${ROOT%/}${EPREFIX}/"
+		fi
+		if [[ -n "${D}" && -z "${ED}" ]]; then
+			ED="${D%/}${EPREFIX}/"
+		fi
+	fi
+}
+
+unset PYTHON_SANITY_CHECKS
+
+_python_initial_sanity_checks() {
+	if [[ "$(declare -p PYTHON_SANITY_CHECKS 2> /dev/null)" != "declare -- PYTHON_SANITY_CHECKS="* ]]; then
+		# Ensure that /usr/bin/python and /usr/bin/python-config are valid.
+		if [[ "$(readlink "${EPREFIX}/usr/bin/python")" != "python-wrapper" ]]; then
+			eerror "'${EPREFIX}/usr/bin/python' is not valid symlink."
+			eerror "Use \`eselect python set \${python_interpreter}\` to fix this problem."
+			die "'${EPREFIX}/usr/bin/python' is not valid symlink"
+		fi
+		if [[ "$(<"${EPREFIX}/usr/bin/python-config")" != *"Gentoo python-config wrapper script"* ]]; then
+			eerror "'${EPREFIX}/usr/bin/python-config' is not valid script"
+			eerror "Use \`eselect python set \${python_interpreter}\` to fix this problem."
+			die "'${EPREFIX}/usr/bin/python-config' is not valid script"
+		fi
+	fi
+}
+
+_python_final_sanity_checks() {
+	if ! _python_implementation && [[ "$(declare -p PYTHON_SANITY_CHECKS 2> /dev/null)" != "declare -- PYTHON_SANITY_CHECKS="* ]]; then
+		local PYTHON_ABI="${PYTHON_ABI}"
+		for PYTHON_ABI in ${PYTHON_ABIS-${PYTHON_ABI}}; do
+			# Ensure that appropriate version of Python is installed.
+			if ! has_version "$(python_get_implementational_package)"; then
+				die "$(python_get_implementational_package) is not installed"
+			fi
+
+			# Ensure that EPYTHON variable is respected.
+			if [[ "$(EPYTHON="$(PYTHON)" python -c "${_PYTHON_ABI_EXTRACTION_COMMAND}")" != "${PYTHON_ABI}" ]]; then
+				eerror "Path to 'python':                 '$(type -p python)'"
+				eerror "ABI:                              '${ABI}'"
+				eerror "DEFAULT_ABI:                      '${DEFAULT_ABI}'"
+				eerror "EPYTHON:                          '$(PYTHON)'"
+				eerror "PYTHON_ABI:                       '${PYTHON_ABI}'"
+				eerror "Locally active version of Python: '$(EPYTHON="$(PYTHON)" python -c "${_PYTHON_ABI_EXTRACTION_COMMAND}")'"
+				die "'python' does not respect EPYTHON variable"
+			fi
+		done
+	fi
+	PYTHON_SANITY_CHECKS="1"
+}
+
+_python_set_color_variables() {
+	if [[ "${NOCOLOR:-false}" =~ ^(false|no)$ ]]; then
+		_BOLD=$'\e[1m'
+		_RED=$'\e[1;31m'
+		_GREEN=$'\e[1;32m'
+		_BLUE=$'\e[1;34m'
+		_CYAN=$'\e[1;36m'
+		_NORMAL=$'\e[0m'
+	else
+		_BOLD=
+		_RED=
+		_GREEN=
+		_BLUE=
+		_CYAN=
+		_NORMAL=
+	fi
+}
+
+unset PYTHON_PKG_SETUP_EXECUTED
+
 # @FUNCTION: python_pkg_setup
 # @DESCRIPTION:
-# Makes sure PYTHON_USE_WITH or PYTHON_USE_WITH_OR listed use flags
-# are respected. Only exported if one of those variables is set.
-if ! has "${EAPI:-0}" 0 1 && [[ -n ${PYTHON_USE_WITH} || -n ${PYTHON_USE_WITH_OR} ]]; then
-	python_pkg_setup() {
-		# Check if phase is pkg_setup().
-		[[ "${EBUILD_PHASE}" != "setup" ]] && die "${FUNCNAME}() can be used only in pkg_setup() phase"
-
-		python_pkg_setup_fail() {
-			eerror "${1}"
-			die "${1}"
-		}
+# Perform sanity checks and initialize environment.
+#
+# This function is exported in EAPI 2 and 3 when PYTHON_USE_WITH or PYTHON_USE_WITH_OR variable
+# is set and always in EAPI >=4. Calling of this function is mandatory in EAPI >=4.
+#
+# This function can be used only in pkg_setup() phase.
+python_pkg_setup() {
+	# Check if phase is pkg_setup().
+	[[ "${EBUILD_PHASE}" != "setup" ]] && die "${FUNCNAME}() can be used only in pkg_setup() phase"
 
+	if _python_package_supporting_installation_for_multiple_python_abis; then
+		validate_PYTHON_ABIS
+		export EPYTHON="$(PYTHON -f)"
+	else
+		PYTHON_ABI="$(PYTHON --ABI)"
+	fi
+
+	if ! has "${EAPI:-0}" 0 1 && [[ -n "${PYTHON_USE_WITH}" || -n "${PYTHON_USE_WITH_OR}" ]]; then
 		if [[ "${PYTHON_USE_WITH_OPT}" ]]; then
 			if [[ "${PYTHON_USE_WITH_OPT}" == !* ]]; then
 				use ${PYTHON_USE_WITH_OPT#!} && return
@@ -207,23 +345,25 @@
 		fi
 
 		python_pkg_setup_check_USE_flags() {
-			local pyatom use
-			pyatom="$(python_get_implementational_package)"
+			local python_atom USE_flag
+			python_atom="$(python_get_implementational_package)"
 
-			for use in ${PYTHON_USE_WITH}; do
-				if ! has_version "${pyatom}[${use}]"; then
-					python_pkg_setup_fail "Please rebuild ${pyatom} with the following USE flags enabled: ${PYTHON_USE_WITH}"
+			for USE_flag in ${PYTHON_USE_WITH}; do
+				if ! has_version "${python_atom}[${USE_flag}]"; then
+					eerror "Please rebuild ${python_atom} with the following USE flags enabled: ${PYTHON_USE_WITH}"
+					die "Please rebuild ${python_atom} with the following USE flags enabled: ${PYTHON_USE_WITH}"
 				fi
 			done
 
-			for use in ${PYTHON_USE_WITH_OR}; do
-				if has_version "${pyatom}[${use}]"; then
+			for USE_flag in ${PYTHON_USE_WITH_OR}; do
+				if has_version "${python_atom}[${USE_flag}]"; then
 					return
 				fi
 			done
 
 			if [[ ${PYTHON_USE_WITH_OR} ]]; then
-				python_pkg_setup_fail "Please rebuild ${pyatom} with at least one of the following USE flags enabled: ${PYTHON_USE_WITH_OR}"
+				eerror "Please rebuild ${python_atom} with at least one of the following USE flags enabled: ${PYTHON_USE_WITH_OR}"
+				die "Please rebuild ${python_atom} with at least one of the following USE flags enabled: ${PYTHON_USE_WITH_OR}"
 			fi
 		}
 
@@ -233,38 +373,148 @@
 			python_pkg_setup_check_USE_flags
 		fi
 
-		unset -f python_pkg_setup_check_USE_flags python_pkg_setup_fail
-	}
+		unset -f python_pkg_setup_check_USE_flags
+	fi
+
+	PYTHON_PKG_SETUP_EXECUTED="1"
+}
 
+if ! has "${EAPI:-0}" 0 1 2 3 || has "${EAPI:-0}" 2 3 && [[ -n "${PYTHON_USE_WITH}" || -n "${PYTHON_USE_WITH_OR}" ]]; then
 	EXPORT_FUNCTIONS pkg_setup
+fi
 
-	_PYTHON_USE_WITH_ATOMS_ARRAY=()
-	if [[ -n "${PYTHON_USE_WITH}" ]]; then
-		for _PYTHON_ATOM in "${_PYTHON_ATOMS[@]}"; do
-			_PYTHON_USE_WITH_ATOMS_ARRAY+=("${_PYTHON_ATOM}[${PYTHON_USE_WITH/ /,}]")
-		done
-	elif [[ -n "${PYTHON_USE_WITH_OR}" ]]; then
-		for _USE_flag in ${PYTHON_USE_WITH_OR}; do
-			for _PYTHON_ATOM in "${_PYTHON_ATOMS[@]}"; do
-				_PYTHON_USE_WITH_ATOMS_ARRAY+=("${_PYTHON_ATOM}[${_USE_flag}]")
-			done
+# @FUNCTION: python_convert_shebangs
+# @USAGE: [-q|--quiet] [-r|--recursive] [-x|--only-executables] [--] <Python_version> <file|directory> [files|directories]
+# @DESCRIPTION:
+# Convert shebangs in specified files. Directories can be specified only with --recursive option.
+python_convert_shebangs() {
+	local argument file files=() only_executables="0" python_version quiet="0" recursive="0"
+
+	while (($#)); do
+		case "$1" in
+			-r|--recursive)
+				recursive="1"
+				;;
+			-q|--quiet)
+				quiet="1"
+				;;
+			-x|--only-executables)
+				only_executables="1"
+				;;
+			--)
+				shift
+				break
+				;;
+			-*)
+				die "${FUNCNAME}(): Unrecognized option '$1'"
+				;;
+			*)
+				break
+				;;
+		esac
+		shift
+	done
+
+	if [[ "$#" -eq 0 ]]; then
+		die "${FUNCNAME}(): Missing Python version and files or directories"
+	elif [[ "$#" -eq 1 ]]; then
+		die "${FUNCNAME}(): Missing files or directories"
+	fi
+
+	python_version="$1"
+	shift
+
+	for argument in "$@"; do
+		if [[ ! -e "${argument}" ]]; then
+			die "${FUNCNAME}(): '${argument}' does not exist"
+		elif [[ -f "${argument}" ]]; then
+			files+=("${argument}")
+		elif [[ -d "${argument}" ]]; then
+			if [[ "${recursive}" == "1" ]]; then
+				while read -d $'\0' -r file; do
+					files+=("${file}")
+				done < <(find "${argument}" $([[ "${only_executables}" == "1" ]] && echo -perm /111) -type f -print0)
+			else
+				die "${FUNCNAME}(): '${argument}' is not a regular file"
+			fi
+		else
+			die "${FUNCNAME}(): '${argument}' is not a regular file or a directory"
+		fi
+	done
+
+	for file in "${files[@]}"; do
+		file="${file#./}"
+		[[ "${only_executables}" == "1" && ! -x "${file}" ]] && continue
+
+		if [[ "$(head -n1 "${file}")" =~ ^'#!'.*python ]]; then
+			[[ "$(sed -ne "2p" "${file}")" =~ ^"# Gentoo '".*"' wrapper script generated by python_generate_wrapper_scripts()"$ ]] && continue
+
+			if [[ "${quiet}" == "0" ]]; then
+				einfo "Converting shebang in '${file}'"
+			fi
+
+			sed -e "1s/python\([[:digit:]]\+\(\.[[:digit:]]\+\)\?\)\?/python${python_version}/" -i "${file}" || die "Conversion of shebang in '${file}' failed"
+
+			# Delete potential whitespace after "#!".
+			sed -e '1s/\(^#!\)[[:space:]]*/\1/' -i "${file}" || die "sed '${file}' failed"
+		fi
+	done
+}
+
+# @FUNCTION: python_clean_installation_image
+# @USAGE: [-q|--quiet]
+# @DESCRIPTION:
+# Delete needless files in installation image.
+python_clean_installation_image() {
+	_python_initialize_prefix_variables
+
+	local file files=() quiet="0"
+
+	# Check if phase is src_install().
+	[[ "${EBUILD_PHASE}" != "install" ]] && die "${FUNCNAME}() can be used only in src_install() phase"
+
+	while (($#)); do
+		case "$1" in
+			-q|--quiet)
+				quiet="1"
+				;;
+			-*)
+				die "${FUNCNAME}(): Unrecognized option '$1'"
+				;;
+			*)
+				die "${FUNCNAME}(): Invalid usage"
+				;;
+		esac
+		shift
+	done
+
+	while read -d $'\0' -r file; do
+		files+=("${file}")
+	done < <(find "${ED}" "(" -name "*.py[co]" -o -name "*\$py.class" ")" -type f -print0)
+
+	if [[ "${#files[@]}" -gt 0 ]]; then
+		if [[ "${quiet}" == "0" ]]; then
+			ewarn "Deleting byte-compiled Python modules needlessly generated by build system:"
+		fi
+		for file in "${files[@]}"; do
+			if [[ "${quiet}" == "0" ]]; then
+				ewarn " ${file}"
+			fi
+			rm -f "${file}"
 		done
-		unset _USE_flag
 	fi
-	if [[ "${#_PYTHON_USE_WITH_ATOMS_ARRAY[@]}" -gt 1 ]]; then
-		_PYTHON_USE_WITH_ATOMS="|| ( ${_PYTHON_USE_WITH_ATOMS_ARRAY[@]} )"
+
+	python_clean_sitedirs() {
+		find "${ED}$(python_get_sitedir)" "(" -name "*.c" -o -name "*.h" -o -name "*.la" ")" -type f -print0 | xargs -0 rm -f
+	}
+	if _python_package_supporting_installation_for_multiple_python_abis; then
+		python_execute_function -q python_clean_sitedirs
 	else
-		_PYTHON_USE_WITH_ATOMS="${_PYTHON_USE_WITH_ATOMS_ARRAY[@]}"
-	fi
-	if [[ -n "${PYTHON_USE_WITH_OPT}" ]]; then
-		_PYTHON_USE_WITH_ATOMS="${PYTHON_USE_WITH_OPT}? ( ${_PYTHON_USE_WITH_ATOMS} )"
+		python_clean_sitedirs
 	fi
-	DEPEND+=" ${_PYTHON_USE_WITH_ATOMS}"
-	RDEPEND+=" ${_PYTHON_USE_WITH_ATOMS}"
-	unset _PYTHON_ATOM _PYTHON_USE_WITH_ATOMS _PYTHON_USE_WITH_ATOMS_ARRAY
-fi
 
-unset _PYTHON_ATOMS
+	unset -f python_clean_sitedirs
+}
 
 # ================================================================================================
 # =========== FUNCTIONS FOR PACKAGES SUPPORTING INSTALLATION FOR MULTIPLE PYTHON ABIS ============
@@ -294,7 +544,7 @@
 				die \"\${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs\"
 			fi
 
-			python_execute_function -d -s \"\$@\"
+			python_execute_function -d -s -- \"\$@\"
 		}"
 	done
 	unset python_default_function
@@ -358,6 +608,10 @@
 		else
 			local python_version python2_version= python3_version= support_python_major_version
 
+			if ! has_version "dev-lang/python"; then
+				die "${FUNCNAME}(): 'dev-lang/python' is not installed"
+			fi
+
 			python_version="$("${EPREFIX}/usr/bin/python" -c 'from sys import version_info; print(".".join(str(x) for x in version_info[:2]))')"
 
 			if has_version "=dev-lang/python-2*"; then
@@ -675,7 +929,7 @@
 
 	if [[ "$#" -eq 0 ]]; then
 		if [[ "${WORKDIR}" == "${S}" ]]; then
-			die "${FUNCNAME}() cannot be used"
+			die "${FUNCNAME}() cannot be used with current value of S variable"
 		fi
 		dirs=("${S%/}")
 	else
@@ -909,6 +1163,10 @@
 		die "${FUNCNAME}() cannot be used in ebuilds of packages supporting installation for multiple Python ABIs"
 	fi
 
+	if [[ -n "${PYTHON_PKG_SETUP_EXECUTED}" ]]; then
+		die "${FUNCNAME}() should be called before python_pkg_setup()"
+	fi
+
 	if [[ "$#" -ne 1 ]]; then
 		die "${FUNCNAME}() requires 1 argument"
 	fi
@@ -1045,19 +1303,22 @@
 		elif [[ "${python2}" == "1" ]]; then
 			PYTHON_ABI="$(eselect python show --python2 --ABI)"
 			if [[ -z "${PYTHON_ABI}" ]]; then
-				die "${FUNCNAME}(): Active Python 2 interpreter not set"
+				die "${FUNCNAME}(): Active version of Python 2 not set"
 			elif [[ "${PYTHON_ABI}" != "2."* ]]; then
 				die "${FUNCNAME}(): Internal error in \`eselect python show --python2\`"
 			fi
 		elif [[ "${python3}" == "1" ]]; then
 			PYTHON_ABI="$(eselect python show --python3 --ABI)"
 			if [[ -z "${PYTHON_ABI}" ]]; then
-				die "${FUNCNAME}(): Active Python 3 interpreter not set"
+				die "${FUNCNAME}(): Active version of Python 3 not set"
 			elif [[ "${PYTHON_ABI}" != "3."* ]]; then
 				die "${FUNCNAME}(): Internal error in \`eselect python show --python3\`"
 			fi
 		elif ! _python_package_supporting_installation_for_multiple_python_abis; then
 			PYTHON_ABI="$("${EPREFIX}/usr/bin/python" -c "${_PYTHON_ABI_EXTRACTION_COMMAND}")"
+			if [[ -z "${PYTHON_ABI}" ]]; then
+				die "${FUNCNAME}(): Main active version of Python not set"
+			fi
 		elif [[ -z "${PYTHON_ABI}" ]]; then
 			die "${FUNCNAME}(): Invalid usage: ${FUNCNAME}() should be used in ABI-specific local scope"
 		fi
@@ -1398,194 +1659,6 @@
 }
 
 # ================================================================================================
-# =================================== MISCELLANEOUS FUNCTIONS ====================================
-# ================================================================================================
-
-_python_implementation() {
-	if [[ "${CATEGORY}/${PN}" == "dev-lang/python" ]]; then
-		return 0
-	elif [[ "${CATEGORY}/${PN}" == "dev-java/jython" ]]; then
-		return 0
-	else
-		return 1
-	fi
-}
-
-_python_package_supporting_installation_for_multiple_python_abis() {
-	if [[ "${EBUILD_PHASE}" == "depend" ]]; then
-		die "${FUNCNAME}() cannot be used in global scope"
-	fi
-
-	if has "${EAPI:-0}" 0 1 2 3 4; then
-		if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
-			return 0
-		else
-			return 1
-		fi
-	else
-		die "${FUNCNAME}(): Support for EAPI=\"${EAPI}\" not implemented"
-	fi
-}
-
-_python_initialize_prefix_variables() {
-	if has "${EAPI:-0}" 0 1 2; then
-		if [[ -n "${ROOT}" && -z "${EROOT}" ]]; then
-			EROOT="${ROOT%/}${EPREFIX}/"
-		fi
-		if [[ -n "${D}" && -z "${ED}" ]]; then
-			ED="${D%/}${EPREFIX}/"
-		fi
-	fi
-}
-
-unset PYTHON_SANITY_CHECKS
-
-_python_initial_sanity_checks() {
-	if [[ "$(declare -p PYTHON_SANITY_CHECKS 2> /dev/null)" != "declare -- PYTHON_SANITY_CHECKS="* ]]; then
-		# Ensure that /usr/bin/python and /usr/bin/python-config are valid.
-		if [[ "$(readlink "${EPREFIX}/usr/bin/python")" != "python-wrapper" ]]; then
-			eerror "'${EPREFIX}/usr/bin/python' is not valid symlink."
-			eerror "Use \`eselect python set \${python_interpreter}\` to fix this problem."
-			die "'${EPREFIX}/usr/bin/python' is not valid symlink"
-		fi
-		if [[ "$(<"${EPREFIX}/usr/bin/python-config")" != *"Gentoo python-config wrapper script"* ]]; then
-			eerror "'${EPREFIX}/usr/bin/python-config' is not valid script"
-			eerror "Use \`eselect python set \${python_interpreter}\` to fix this problem."
-			die "'${EPREFIX}/usr/bin/python-config' is not valid script"
-		fi
-	fi
-}
-
-_python_final_sanity_checks() {
-	if ! _python_implementation && [[ "$(declare -p PYTHON_SANITY_CHECKS 2> /dev/null)" != "declare -- PYTHON_SANITY_CHECKS="* ]]; then
-		local PYTHON_ABI="${PYTHON_ABI}"
-		for PYTHON_ABI in ${PYTHON_ABIS-${PYTHON_ABI}}; do
-			# Ensure that appropriate version of Python is installed.
-			if ! has_version "$(python_get_implementational_package)"; then
-				die "$(python_get_implementational_package) is not installed"
-			fi
-
-			# Ensure that EPYTHON variable is respected.
-			if [[ "$(EPYTHON="$(PYTHON)" python -c "${_PYTHON_ABI_EXTRACTION_COMMAND}")" != "${PYTHON_ABI}" ]]; then
-				eerror "python:                    '$(type -p python)'"
-				eerror "ABI:                       '${ABI}'"
-				eerror "DEFAULT_ABI:               '${DEFAULT_ABI}'"
-				eerror "EPYTHON:                   '$(PYTHON)'"
-				eerror "PYTHON_ABI:                '${PYTHON_ABI}'"
-				eerror "Version of enabled Python: '$(EPYTHON="$(PYTHON)" python -c "${_PYTHON_ABI_EXTRACTION_COMMAND}")'"
-				die "'python' does not respect EPYTHON variable"
-			fi
-		done
-	fi
-	PYTHON_SANITY_CHECKS="1"
-}
-
-_python_set_color_variables() {
-	if [[ "${NOCOLOR:-false}" =~ ^(false|no)$ ]]; then
-		_BOLD=$'\e[1m'
-		_RED=$'\e[1;31m'
-		_GREEN=$'\e[1;32m'
-		_BLUE=$'\e[1;34m'
-		_CYAN=$'\e[1;36m'
-		_NORMAL=$'\e[0m'
-	else
-		_BOLD=
-		_RED=
-		_GREEN=
-		_BLUE=
-		_CYAN=
-		_NORMAL=
-	fi
-}
-
-# @FUNCTION: python_convert_shebangs
-# @USAGE: [-q|--quiet] [-r|--recursive] [-x|--only-executables] [--] <Python_version> <file|directory> [files|directories]
-# @DESCRIPTION:
-# Convert shebangs in specified files. Directories can be specified only with --recursive option.
-python_convert_shebangs() {
-	local argument file files=() only_executables="0" python_version quiet="0" recursive="0"
-
-	while (($#)); do
-		case "$1" in
-			-r|--recursive)
-				recursive="1"
-				;;
-			-q|--quiet)
-				quiet="1"
-				;;
-			-x|--only-executables)
-				only_executables="1"
-				;;
-			--)
-				shift
-				break
-				;;
-			-*)
-				die "${FUNCNAME}(): Unrecognized option '$1'"
-				;;
-			*)
-				break
-				;;
-		esac
-		shift
-	done
-
-	if [[ "$#" -eq 0 ]]; then
-		die "${FUNCNAME}(): Missing Python version and files or directories"
-	elif [[ "$#" -eq 1 ]]; then
-		die "${FUNCNAME}(): Missing files or directories"
-	fi
-
-	python_version="$1"
-	shift
-
-	for argument in "$@"; do
-		if [[ ! -e "${argument}" ]]; then
-			die "${FUNCNAME}(): '${argument}' does not exist"
-		elif [[ -f "${argument}" ]]; then
-			files+=("${argument}")
-		elif [[ -d "${argument}" ]]; then
-			if [[ "${recursive}" == "1" ]]; then
-				while read -d $'\0' -r file; do
-					files+=("${file}")
-				done < <(find "${argument}" $([[ "${only_executables}" == "1" ]] && echo -perm /111) -type f -print0)
-			else
-				die "${FUNCNAME}(): '${argument}' is not a regular file"
-			fi
-		else
-			die "${FUNCNAME}(): '${argument}' is not a regular file or a directory"
-		fi
-	done
-
-	for file in "${files[@]}"; do
-		file="${file#./}"
-		[[ "${only_executables}" == "1" && ! -x "${file}" ]] && continue
-
-		if [[ "$(head -n1 "${file}")" =~ ^'#!'.*python ]]; then
-			[[ "$(sed -ne "2p" "${file}")" =~ ^"# Gentoo '".*"' wrapper script generated by python_generate_wrapper_scripts()"$ ]] && continue
-
-			if [[ "${quiet}" == "0" ]]; then
-				einfo "Converting shebang in '${file}'"
-			fi
-
-			sed -e "1s/python\([[:digit:]]\+\(\.[[:digit:]]\+\)\?\)\?/python${python_version}/" -i "${file}" || die "Conversion of shebang in '${file}' failed"
-
-			# Delete potential whitespace after "#!".
-			sed -e '1s/\(^#!\)[[:space:]]*/\1/' -i "${file}" || die "sed '${file}' failed"
-		fi
-	done
-}
-
-# @FUNCTION: python_clean_sitedirs
-# @DESCRIPTION:
-# Delete needless files in site-packages directories in ${ED}.
-python_clean_sitedirs() {
-	_python_initialize_prefix_variables
-
-	find "${ED}"usr/$(get_libdir)/python*/site-packages "(" -name "*.c" -o -name "*.h" -o -name "*.la" ")" -type f -print0 | xargs -0 rm -f
-}
-
-# ================================================================================================
 # ================================ FUNCTIONS FOR RUNNING OF TESTS ================================
 # ================================================================================================
 
@@ -1830,6 +1903,93 @@
 	export PYTHONDONTWRITEBYTECODE="1"
 }
 
+_python_clean_compiled_modules() {
+	_python_initialize_prefix_variables
+	_python_set_color_variables
+
+	[[ "${FUNCNAME[1]}" =~ ^(python_mod_optimize|python_mod_compile|python_mod_cleanup)$ ]] || die "${FUNCNAME}(): Invalid usage"
+
+	local base_module_name compiled_file compiled_files=() dir path py_file root
+
+	# Strip trailing slash from EROOT.
+	root="${EROOT%/}"
+
+	for path in "$@"; do
+		compiled_files=()
+		if [[ -d "${path}" ]]; then
+			while read -d $'\0' -r compiled_file; do
+				compiled_files+=("${compiled_file}")
+			done < <(find "${path}" "(" -name "*.py[co]" -o -name "*\$py.class" ")" -print0)
+
+			if [[ "${EBUILD_PHASE}" == "postrm" ]]; then
+				# Delete empty child directories.
+				find "${path}" -type d | sort -r | while read -r dir; do
+					rmdir "${dir}" 2> /dev/null && echo "${_CYAN}<<< ${dir}${_NORMAL}"
+				done
+			fi
+		elif [[ "${path}" == *.py ]]; then
+			base_module_name="${path##*/}"
+			base_module_name="${base_module_name%.py}"
+			if [[ -d "${path%/*}/__pycache__" ]]; then
+				while read -d $'\0' -r compiled_file; do
+					compiled_files+=("${compiled_file}")
+				done < <(find "${path%/*}/__pycache__" "(" -name "${base_module_name}.*.py[co]" -o -name "${base_module_name}\$py.class" ")" -print0)
+			fi
+			compiled_files+=("${path}c" "${path}o" "${path%.py}\$py.class")
+		fi
+
+		for compiled_file in "${compiled_files[@]}"; do
+			[[ ! -f "${compiled_file}" ]] && continue
+			dir="${compiled_file%/*}"
+			dir="${dir##*/}"
+			if [[ "${compiled_file}" == *.py[co] ]]; then
+				if [[ "${dir}" == "__pycache__" ]]; then
+					base_module_name="${compiled_file##*/}"
+					base_module_name="${base_module_name%%.*py[co]}"
+					py_file="${compiled_file%__pycache__/*}${base_module_name}.py"
+				else
+					py_file="${compiled_file%[co]}"
+				fi
+				if [[ "${EBUILD_PHASE}" == "postinst" ]]; then
+					[[ -f "${py_file}" && "${compiled_file}" -nt "${py_file}" ]] && continue
+				else
+					[[ -f "${py_file}" ]] && continue
+				fi
+				echo "${_BLUE}<<< ${compiled_file%[co]}[co]${_NORMAL}"
+				rm -f "${compiled_file%[co]}"[co]
+			elif [[ "${compiled_file}" == *\$py.class ]]; then
+				if [[ "${dir}" == "__pycache__" ]]; then
+					base_module_name="${compiled_file##*/}"
+					base_module_name="${base_module_name%\$py.class}"
+					py_file="${compiled_file%__pycache__/*}${base_module_name}.py"
+				else
+					py_file="${compiled_file%\$py.class}"
+				fi
+				if [[ "${EBUILD_PHASE}" == "postinst" ]]; then
+					[[ -f "${py_file}" && "${compiled_file}" -nt "${py_file}" ]] && continue
+				else
+					[[ -f "${py_file}" ]] && continue
+				fi
+				echo "${_BLUE}<<< ${compiled_file}${_NORMAL}"
+				rm -f "${compiled_file}"
+			else
+				die "${FUNCNAME}(): Unrecognized file type: '${compiled_file}'"
+			fi
+
+			# Delete empty parent directories.
+			dir="${compiled_file%/*}"
+			while [[ "${dir}" != "${root}" ]]; do
+				if rmdir "${compiled_file%/*}" 2> /dev/null; then
+					echo "${_CYAN}<<< ${compiled_file%/*}${_NORMAL}"
+				else
+					break
+				fi
+				dir="${dir%/*}"
+			done
+		done
+	done
+}
+
 # @FUNCTION: python_mod_optimize
 # @USAGE: [options] [directory|file]
 # @DESCRIPTION:
@@ -1849,12 +2009,22 @@
 	[[ "${EBUILD_PHASE}" != "postinst" ]] && die "${FUNCNAME}() can be used only in pkg_postinst() phase"
 
 	if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
-		local dir file options=() other_dirs=() other_files=() previous_PYTHON_ABI="${PYTHON_ABI}" PYTHON_ABI="${PYTHON_ABI}" return_code root site_packages_absolute_dirs=() site_packages_dirs=() site_packages_absolute_files=() site_packages_files=()
+		# PYTHON_ABI variable cannot be local in packages not supporting installation for multiple Python ABIs.
+		local dir file iterated_PYTHON_ABIS options=() other_dirs=() other_files=() previous_PYTHON_ABI="${PYTHON_ABI}" return_code root site_packages_absolute_dirs=() site_packages_dirs=() site_packages_absolute_files=() site_packages_files=()
 
-		# Strip trailing slash from ROOT.
+		if _python_package_supporting_installation_for_multiple_python_abis; then
+			if [[ -z "${PYTHON_ABIS}" ]]; then
+				die "${FUNCNAME}(): Environment not initialized"
+			fi
+			iterated_PYTHON_ABIS="${PYTHON_ABIS}"
+		else
+			iterated_PYTHON_ABIS="${PYTHON_ABI:=$(PYTHON --ABI)}"
+		fi
+
+		# Strip trailing slash from EROOT.
 		root="${EROOT%/}"
 
-		# Respect ROOT and options passed to compileall.py.
+		# Respect EROOT and options passed to compileall.py.
 		while (($#)); do
 			case "$1" in
 				-l|-f|-q)
@@ -1868,20 +2038,23 @@
 					ewarn "${FUNCNAME}(): Ignoring option '$1'"
 					;;
 				*)
-					if ! _python_implementation && [[ "$1" =~ ^"${EPREFIX}"/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then
-						die "${FUNCNAME}() does not support absolute paths of directories/files in site-packages directories"
+					if ! _python_implementation && [[ "$1" =~ ^/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then
+						die "${FUNCNAME}(): Paths of directories / files in site-packages directories must be relative to site-packages directories"
 					elif [[ "$1" =~ ^/ ]]; then
-						if [[ -d "${root}/$1" ]]; then
-							other_dirs+=("${root}/$1")
-						elif [[ -f "${root}/$1" ]]; then
-							other_files+=("${root}/$1")
-						elif [[ -e "${root}/$1" ]]; then
-							ewarn "'${root}/$1' is not a file or a directory!"
+						if _python_package_supporting_installation_for_multiple_python_abis; then
+							die "${FUNCNAME}(): Absolute paths cannot be used in ebuilds of packages supporting installation for multiple Python ABIs"
+						fi
+						if [[ -d "${root}$1" ]]; then
+							other_dirs+=("${root}$1")
+						elif [[ -f "${root}$1" ]]; then
+							other_files+=("${root}$1")
+						elif [[ -e "${root}$1" ]]; then
+							ewarn "'${root}$1' is not a file or a directory!"
 						else
-							ewarn "'${root}/$1' does not exist!"
+							ewarn "'${root}$1' does not exist!"
 						fi
 					else
-						for PYTHON_ABI in ${PYTHON_ABIS-${PYTHON_ABI:-$(PYTHON --ABI)}}; do
+						for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
 							if [[ -d "${root}$(python_get_sitedir)/$1" ]]; then
 								site_packages_dirs+=("$1")
 								break
@@ -1903,7 +2076,7 @@
 		# Set additional options.
 		options+=("-q")
 
-		for PYTHON_ABI in ${PYTHON_ABIS-${PYTHON_ABI:-$(PYTHON --ABI)}}; do
+		for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
 			if ((${#site_packages_dirs[@]})) || ((${#site_packages_files[@]})); then
 				return_code="0"
 				ebegin "Compilation and optimization of Python modules for $(python_get_implementation) $(python_get_version)"
@@ -1915,6 +2088,7 @@
 					if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
 						"$(PYTHON)" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${site_packages_absolute_dirs[@]}" &> /dev/null || return_code="1"
 					fi
+					_python_clean_compiled_modules "${site_packages_absolute_dirs[@]}"
 				fi
 				if ((${#site_packages_files[@]})); then
 					for file in "${site_packages_files[@]}"; do
@@ -1924,17 +2098,20 @@
 					if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
 						"$(PYTHON)" -O "${root}$(python_get_libdir)/py_compile.py" "${site_packages_absolute_files[@]}" &> /dev/null || return_code="1"
 					fi
+					_python_clean_compiled_modules "${site_packages_absolute_files[@]}"
 				fi
 				eend "${return_code}"
 			fi
 			unset site_packages_absolute_dirs site_packages_absolute_files
 		done
 
-		# Restore previous value of PYTHON_ABI.
-		if [[ -n "${previous_PYTHON_ABI}" ]]; then
-			PYTHON_ABI="${previous_PYTHON_ABI}"
-		else
-			unset PYTHON_ABI
+		if _python_package_supporting_installation_for_multiple_python_abis; then
+			# Restore previous value of PYTHON_ABI.
+			if [[ -n "${previous_PYTHON_ABI}" ]]; then
+				PYTHON_ABI="${previous_PYTHON_ABI}"
+			else
+				unset PYTHON_ABI
+			fi
 		fi
 
 		if ((${#other_dirs[@]})) || ((${#other_files[@]})); then
@@ -1945,12 +2122,14 @@
 				if [[ "$(_python_get_implementation "${PYTHON_ABI-$(PYTHON --ABI)}")" != "Jython" ]]; then
 					"$(PYTHON ${PYTHON_ABI})" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" &> /dev/null || return_code="1"
 				fi
+				_python_clean_compiled_modules "${other_dirs[@]}"
 			fi
 			if ((${#other_files[@]})); then
 				"$(PYTHON ${PYTHON_ABI})" "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" || return_code="1"
 				if [[ "$(_python_get_implementation "${PYTHON_ABI-$(PYTHON --ABI)}")" != "Jython" ]]; then
 					"$(PYTHON ${PYTHON_ABI})" -O "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" &> /dev/null || return_code="1"
 				fi
+				_python_clean_compiled_modules "${other_dirs[@]}"
 			fi
 			eend "${return_code}"
 		fi
@@ -1960,7 +2139,7 @@
 		# strip trailing slash
 		myroot="${EROOT%/}"
 
-		# respect ROOT and options passed to compileall.py
+		# respect EROOT and options passed to compileall.py
 		while (($#)); do
 			case "$1" in
 				-l|-f|-q)
@@ -1974,15 +2153,15 @@
 					ewarn "${FUNCNAME}(): Ignoring option '$1'"
 					;;
 				*)
-					if [[ -d "${myroot}"/$1 ]]; then
-						mydirs+=("${myroot}/$1")
-					elif [[ -f "${myroot}"/$1 ]]; then
-						# Files are passed to python_mod_compile which is ROOT-aware
+					if [[ -d "${myroot}/${1#/}" ]]; then
+						mydirs+=("${myroot}/${1#/}")
+					elif [[ -f "${myroot}/${1#/}" ]]; then
+						# Files are passed to python_mod_compile which is EROOT-aware
 						myfiles+=("$1")
-					elif [[ -e "${myroot}/$1" ]]; then
-						ewarn "${myroot}/$1 is not a file or directory!"
+					elif [[ -e "${myroot}/${1#/}" ]]; then
+						ewarn "${myroot}/${1#/} is not a file or directory!"
 					else
-						ewarn "${myroot}/$1 does not exist!"
+						ewarn "${myroot}/${1#/} does not exist!"
 					fi
 					;;
 			esac
@@ -1992,10 +2171,13 @@
 		# set additional opts
 		myopts+=(-q)
 
+		PYTHON_ABI="$(PYTHON --ABI)"
+
 		ebegin "Compilation and optimization of Python modules for $(python_get_implementation) $(python_get_version)"
 		if ((${#mydirs[@]})); then
 			"$(PYTHON ${PYTHON_ABI})" "${myroot}$(python_get_libdir)/compileall.py" "${myopts[@]}" "${mydirs[@]}" || return_code="1"
 			"$(PYTHON ${PYTHON_ABI})" -O "${myroot}$(python_get_libdir)/compileall.py" "${myopts[@]}" "${mydirs[@]}" &> /dev/null || return_code="1"
+			_python_clean_compiled_modules "${mydirs[@]}"
 		fi
 
 		if ((${#myfiles[@]})); then
@@ -2019,83 +2201,63 @@
 # This function can be used only in pkg_postrm() phase.
 python_mod_cleanup() {
 	_python_initialize_prefix_variables
-	_python_set_color_variables
 
-	local path py_file PYTHON_ABI="${PYTHON_ABI}" SEARCH_PATH=() root
+	local dir iterated_PYTHON_ABIS PYTHON_ABI="${PYTHON_ABI}" root search_paths=() sitedir
 
 	# Check if phase is pkg_postrm().
 	[[ "${EBUILD_PHASE}" != "postrm" ]] && die "${FUNCNAME}() can be used only in pkg_postrm() phase"
 
-	# Strip trailing slash from ROOT.
+	if _python_package_supporting_installation_for_multiple_python_abis; then
+		if [[ -z "${PYTHON_ABIS}" ]]; then
+			die "${FUNCNAME}(): Environment not initialized"
+		fi
+		iterated_PYTHON_ABIS="${PYTHON_ABIS}"
+	else
+		iterated_PYTHON_ABIS="${PYTHON_ABI:-$(PYTHON --ABI)}"
+	fi
+
+	# Strip trailing slash from EROOT.
 	root="${EROOT%/}"
 
 	if (($#)); then
 		if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
 			while (($#)); do
-				if ! _python_implementation && [[ "$1" =~ ^"${EPREFIX}"/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then
-					die "${FUNCNAME}() does not support absolute paths of directories/files in site-packages directories"
+				if ! _python_implementation && [[ "$1" =~ ^/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then
+					die "${FUNCNAME}(): Paths of directories / files in site-packages directories must be relative to site-packages directories"
 				elif [[ "$1" =~ ^/ ]]; then
-					SEARCH_PATH+=("${root}/${1#/}")
+					if _python_package_supporting_installation_for_multiple_python_abis; then
+						die "${FUNCNAME}(): Absolute paths cannot be used in ebuilds of packages supporting installation for multiple Python ABIs"
+					fi
+					search_paths+=("${root}$1")
 				else
-					for PYTHON_ABI in ${PYTHON_ABIS-${PYTHON_ABI:-$(PYTHON --ABI)}}; do
-						SEARCH_PATH+=("${root}$(python_get_sitedir)/$1")
+					for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
+						search_paths+=("${root}$(python_get_sitedir)/$1")
 					done
 				fi
 				shift
 			done
 		else
-			SEARCH_PATH=("${@#/}")
-			SEARCH_PATH=("${SEARCH_PATH[@]/#/${root}/}")
+			search_paths=("${@#/}")
+			search_paths=("${search_paths[@]/#/${root}/}")
 		fi
 	else
-		local dir sitedir
 		for dir in "${root}"/usr/lib*; do
 			if [[ -d "${dir}" && ! -L "${dir}" ]]; then
 				for sitedir in "${dir}"/python*/site-packages; do
 					if [[ -d "${sitedir}" ]]; then
-						SEARCH_PATH+=("${sitedir}")
+						search_paths+=("${sitedir}")
 					fi
 				done
 			fi
 		done
 		for sitedir in "${root}"/usr/share/jython-*/Lib/site-packages; do
 			if [[ -d "${sitedir}" ]]; then
-				SEARCH_PATH+=("${sitedir}")
+				search_paths+=("${sitedir}")
 			fi
 		done
 	fi
 
-	for path in "${SEARCH_PATH[@]}"; do
-		if [[ -d "${path}" ]]; then
-			find "${path}" "(" -name "*.py[co]" -o -name "*\$py.class" ")" -print0 | while read -rd ''; do
-				if [[ "${REPLY}" == *[co] ]]; then
-					py_file="${REPLY%[co]}"
-					[[ -f "${py_file}" || (! -f "${py_file}c" && ! -f "${py_file}o") ]] && continue
-					echo "${_BLUE}<<< ${py_file}[co]${_NORMAL}"
-					rm -f "${py_file}"[co]
-				elif [[ "${REPLY}" == *\$py.class ]]; then
-					py_file="${REPLY%\$py.class}.py"
-					[[ -f "${py_file}" || ! -f "${py_file%.py}\$py.class" ]] && continue
-					echo "${_BLUE}<<< ${py_file%.py}\$py.class${_NORMAL}"
-					rm -f "${py_file%.py}\$py.class"
-				fi
-			done
-
-			# Attempt to delete directories, which may be empty.
-			find "${path}" -type d | sort -r | while read -r dir; do
-				rmdir "${dir}" 2>/dev/null && echo "${_CYAN}<<< ${dir}${_NORMAL}"
-			done
-		elif [[ "${path}" == *.py && ! -f "${path}" ]]; then
-			if [[ (-f "${path}c" || -f "${path}o") ]]; then
-				echo "${_BLUE}<<< ${path}[co]${_NORMAL}"
-				rm -f "${path}"[co]
-			fi
-			if [[ -f "${path%.py}\$py.class" ]]; then
-				echo "${_BLUE}<<< ${path%.py}\$py.class${_NORMAL}"
-				rm -f "${path%.py}\$py.class"
-			fi
-		fi
-	done
+	_python_clean_compiled_modules "${search_paths[@]}"
 }
 
 # ================================================================================================
@@ -2159,6 +2321,8 @@
 		die "${FUNCNAME}() cannot be used in this EAPI"
 	fi
 
+	_python_set_color_variables
+
 	echo
 	echo " ${_RED}*${_NORMAL} ${_RED}Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01.${_NORMAL}"
 	echo " ${_RED}*${_NORMAL} ${_RED}Use USE dependencies and/or has_version() instead of ${FUNCNAME}().${_NORMAL}"
@@ -2187,6 +2351,8 @@
 		die "${FUNCNAME}() cannot be used in this EAPI"
 	fi
 
+	_python_set_color_variables
+
 	if [[ "${FUNCNAME[1]}" != "distutils_python_tkinter" ]]; then
 		echo
 		echo " ${_RED}*${_NORMAL} ${_RED}Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01.${_NORMAL}"
@@ -2238,14 +2404,17 @@
 	# strip trailing slash
 	myroot="${EROOT%/}"
 
-	# respect ROOT
+	# respect EROOT
 	for f in "$@"; do
 		[[ -f "${myroot}/${f}" ]] && myfiles+=("${myroot}/${f}")
 	done
 
+	PYTHON_ABI="$(PYTHON --ABI)"
+
 	if ((${#myfiles[@]})); then
 		"$(PYTHON ${PYTHON_ABI})" "${myroot}$(python_get_libdir)/py_compile.py" "${myfiles[@]}"
 		"$(PYTHON ${PYTHON_ABI})" -O "${myroot}$(python_get_libdir)/py_compile.py" "${myfiles[@]}" &> /dev/null
+		_python_clean_compiled_modules "${myfiles[@]}"
 	else
 		ewarn "No files to compile!"
 	fi






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2010-05-25 15:04 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2010-05-25 15:04 UTC (permalink / raw
  To: gentoo-commits

arfrever    10/05/25 15:04:40

  Modified:             python.eclass
  Log:
  Improve python_pkg_setup().
  Improve python_clean_installation_image().
  Rename validate_PYTHON_ABIS() to _python_calculate_PYTHON_ABIS().
  Delete sanity check in python_set_active_version() (bug #321057).
  Improve error message in PYTHON().
  Improve _python_clean_compiled_modules().
  Print deprecation warnings when python_mod_optimize() / python_mod_cleanup are called without paths to Python modules.
  Print deprecation warning in python_mod_compile().

Revision  Changes    Path
1.98                 eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.98&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.98&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.97&r2=1.98

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.97
retrieving revision 1.98
diff -u -r1.97 -r1.98
--- python.eclass	17 May 2010 18:01:59 -0000	1.97
+++ python.eclass	25 May 2010 15:04:40 -0000	1.98
@@ -1,6 +1,6 @@
 # Copyright 1999-2010 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.97 2010/05/17 18:01:59 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.98 2010/05/25 15:04:40 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -329,10 +329,10 @@
 	[[ "${EBUILD_PHASE}" != "setup" ]] && die "${FUNCNAME}() can be used only in pkg_setup() phase"
 
 	if _python_package_supporting_installation_for_multiple_python_abis; then
-		validate_PYTHON_ABIS
+		_python_calculate_PYTHON_ABIS
 		export EPYTHON="$(PYTHON -f)"
 	else
-		PYTHON_ABI="$(PYTHON --ABI)"
+		PYTHON_ABI="${PYTHON_ABI:-$(PYTHON --ABI)}"
 	fi
 
 	if ! has "${EAPI:-0}" 0 1 && [[ -n "${PYTHON_USE_WITH}" || -n "${PYTHON_USE_WITH_OR}" ]]; then
@@ -501,11 +501,18 @@
 				ewarn " ${file}"
 			fi
 			rm -f "${file}"
+
+			# Delete empty __pycache__ directories.
+			if [[ "${file%/*}" == *"/__pycache__" ]]; then
+				rmdir "${file%/*}" 2> /dev/null
+			fi
 		done
 	fi
 
 	python_clean_sitedirs() {
-		find "${ED}$(python_get_sitedir)" "(" -name "*.c" -o -name "*.h" -o -name "*.la" ")" -type f -print0 | xargs -0 rm -f
+		if [[ -d "${ED}$(python_get_sitedir)" ]]; then
+			find "${ED}$(python_get_sitedir)" "(" -name "*.c" -o -name "*.h" -o -name "*.la" ")" -type f -print0 | xargs -0 rm -f
+		fi
 	}
 	if _python_package_supporting_installation_for_multiple_python_abis; then
 		python_execute_function -q python_clean_sitedirs
@@ -556,11 +563,7 @@
 
 unset PYTHON_ABIS
 
-# @FUNCTION: validate_PYTHON_ABIS
-# @DESCRIPTION:
-# Ensure that PYTHON_ABIS variable has valid value.
-# This function usually should not be directly called in ebuilds.
-validate_PYTHON_ABIS() {
+_python_calculate_PYTHON_ABIS() {
 	if ! _python_package_supporting_installation_for_multiple_python_abis; then
 		die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
 	fi
@@ -817,7 +820,7 @@
 		[[ "${EBUILD_PHASE}" == "postrm" ]] && action="Postuninstallation"
 	fi
 
-	validate_PYTHON_ABIS
+	_python_calculate_PYTHON_ABIS
 	if [[ "${final_ABI}" == "1" ]]; then
 		iterated_PYTHON_ABIS="$(PYTHON -f --ABI)"
 	else
@@ -936,7 +939,7 @@
 		dirs=("$@")
 	fi
 
-	validate_PYTHON_ABIS
+	_python_calculate_PYTHON_ABIS
 	for PYTHON_ABI in ${PYTHON_ABIS}; do
 		for dir in "${dirs[@]}"; do
 			cp -pr "${dir}" "${dir}-${PYTHON_ABI}" > /dev/null || die "Copying of sources failed"
@@ -988,7 +991,7 @@
 		die "${FUNCNAME}(): Missing arguments"
 	fi
 
-	validate_PYTHON_ABIS
+	_python_calculate_PYTHON_ABIS
 	for PYTHON_ABI in "${_CPYTHON2_SUPPORTED_ABIS[@]}"; do
 		if has "${PYTHON_ABI}" ${PYTHON_ABIS}; then
 			python2_enabled="1"
@@ -1163,10 +1166,6 @@
 		die "${FUNCNAME}() cannot be used in ebuilds of packages supporting installation for multiple Python ABIs"
 	fi
 
-	if [[ -n "${PYTHON_PKG_SETUP_EXECUTED}" ]]; then
-		die "${FUNCNAME}() should be called before python_pkg_setup()"
-	fi
-
 	if [[ "$#" -ne 1 ]]; then
 		die "${FUNCNAME}() requires 1 argument"
 	fi
@@ -1298,7 +1297,7 @@
 			if ! _python_package_supporting_installation_for_multiple_python_abis; then
 				die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
 			fi
-			validate_PYTHON_ABIS
+			_python_calculate_PYTHON_ABIS
 			PYTHON_ABI="${PYTHON_ABIS##* }"
 		elif [[ "${python2}" == "1" ]]; then
 			PYTHON_ABI="$(eselect python show --python2 --ABI)"
@@ -1317,7 +1316,7 @@
 		elif ! _python_package_supporting_installation_for_multiple_python_abis; then
 			PYTHON_ABI="$("${EPREFIX}/usr/bin/python" -c "${_PYTHON_ABI_EXTRACTION_COMMAND}")"
 			if [[ -z "${PYTHON_ABI}" ]]; then
-				die "${FUNCNAME}(): Main active version of Python not set"
+				die "${FUNCNAME}(): Failure of extraction of locally active version of Python"
 			fi
 		elif [[ -z "${PYTHON_ABI}" ]]; then
 			die "${FUNCNAME}(): Invalid usage: ${FUNCNAME}() should be used in ABI-specific local scope"
@@ -1945,7 +1944,8 @@
 			if [[ "${compiled_file}" == *.py[co] ]]; then
 				if [[ "${dir}" == "__pycache__" ]]; then
 					base_module_name="${compiled_file##*/}"
-					base_module_name="${base_module_name%%.*py[co]}"
+					base_module_name="${base_module_name%.*py[co]}"
+					base_module_name="${base_module_name%.*}"
 					py_file="${compiled_file%__pycache__/*}${base_module_name}.py"
 				else
 					py_file="${compiled_file%[co]}"
@@ -2024,7 +2024,6 @@
 		# Strip trailing slash from EROOT.
 		root="${EROOT%/}"
 
-		# Respect EROOT and options passed to compileall.py.
 		while (($#)); do
 			case "$1" in
 				-l|-f|-q)
@@ -2038,41 +2037,62 @@
 					ewarn "${FUNCNAME}(): Ignoring option '$1'"
 					;;
 				*)
-					if ! _python_implementation && [[ "$1" =~ ^/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then
-						die "${FUNCNAME}(): Paths of directories / files in site-packages directories must be relative to site-packages directories"
-					elif [[ "$1" =~ ^/ ]]; then
-						if _python_package_supporting_installation_for_multiple_python_abis; then
-							die "${FUNCNAME}(): Absolute paths cannot be used in ebuilds of packages supporting installation for multiple Python ABIs"
-						fi
-						if [[ -d "${root}$1" ]]; then
-							other_dirs+=("${root}$1")
-						elif [[ -f "${root}$1" ]]; then
-							other_files+=("${root}$1")
-						elif [[ -e "${root}$1" ]]; then
-							ewarn "'${root}$1' is not a file or a directory!"
-						else
-							ewarn "'${root}$1' does not exist!"
-						fi
-					else
-						for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
-							if [[ -d "${root}$(python_get_sitedir)/$1" ]]; then
-								site_packages_dirs+=("$1")
-								break
-							elif [[ -f "${root}$(python_get_sitedir)/$1" ]]; then
-								site_packages_files+=("$1")
-								break
-							elif [[ -e "${root}$(python_get_sitedir)/$1" ]]; then
-								ewarn "'$1' is not a file or a directory!"
-							else
-								ewarn "'$1' does not exist!"
-							fi
-						done
-					fi
+					break
 					;;
 			esac
 			shift
 		done
 
+		if [[ "$#" -eq 0 ]]; then
+			_python_set_color_variables
+
+			echo
+			echo " ${_RED}*${_NORMAL} ${_RED}Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be${_NORMAL}"
+			echo " ${_RED}*${_NORMAL} ${_RED}disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules.${_NORMAL}"
+			echo " ${_RED}*${_NORMAL} ${_RED}The ebuild needs to be fixed. Please report a bug, if it has not been already reported.${_NORMAL}"
+			echo
+
+			einfo &> /dev/null
+			einfo "Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be" &> /dev/null
+			einfo "disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules." &> /dev/null
+			einfo "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." &> /dev/null
+			einfo &> /dev/null
+		fi
+
+		while (($#)); do
+			if ! _python_implementation && [[ "$1" =~ ^/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then
+				die "${FUNCNAME}(): Paths of directories / files in site-packages directories must be relative to site-packages directories"
+			elif [[ "$1" =~ ^/ ]]; then
+				if _python_package_supporting_installation_for_multiple_python_abis; then
+					die "${FUNCNAME}(): Absolute paths cannot be used in ebuilds of packages supporting installation for multiple Python ABIs"
+				fi
+				if [[ -d "${root}$1" ]]; then
+					other_dirs+=("${root}$1")
+				elif [[ -f "${root}$1" ]]; then
+					other_files+=("${root}$1")
+				elif [[ -e "${root}$1" ]]; then
+					eerror "'${root}$1' is not a file or a directory!"
+				else
+					eerror "'${root}$1' does not exist!"
+				fi
+			else
+				for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
+					if [[ -d "${root}$(python_get_sitedir)/$1" ]]; then
+						site_packages_dirs+=("$1")
+						break
+					elif [[ -f "${root}$(python_get_sitedir)/$1" ]]; then
+						site_packages_files+=("$1")
+						break
+					elif [[ -e "${root}$(python_get_sitedir)/$1" ]]; then
+						eerror "'$1' is not a file or a directory!"
+					else
+						eerror "'$1' does not exist!"
+					fi
+				done
+			fi
+			shift
+		done
+
 		# Set additional options.
 		options+=("-q")
 
@@ -2119,14 +2139,14 @@
 			ebegin "Compilation and optimization of Python modules placed outside of site-packages directories for $(python_get_implementation) $(python_get_version)"
 			if ((${#other_dirs[@]})); then
 				"$(PYTHON ${PYTHON_ABI})" "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" || return_code="1"
-				if [[ "$(_python_get_implementation "${PYTHON_ABI-$(PYTHON --ABI)}")" != "Jython" ]]; then
+				if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
 					"$(PYTHON ${PYTHON_ABI})" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" &> /dev/null || return_code="1"
 				fi
 				_python_clean_compiled_modules "${other_dirs[@]}"
 			fi
 			if ((${#other_files[@]})); then
 				"$(PYTHON ${PYTHON_ABI})" "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" || return_code="1"
-				if [[ "$(_python_get_implementation "${PYTHON_ABI-$(PYTHON --ABI)}")" != "Jython" ]]; then
+				if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
 					"$(PYTHON ${PYTHON_ABI})" -O "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" &> /dev/null || return_code="1"
 				fi
 				_python_clean_compiled_modules "${other_dirs[@]}"
@@ -2134,6 +2154,8 @@
 			eend "${return_code}"
 		fi
 	else
+		# Deprecated part of python_mod_optimize()
+
 		local myroot mydirs=() myfiles=() myopts=() return_code="0"
 
 		# strip trailing slash
@@ -2153,25 +2175,46 @@
 					ewarn "${FUNCNAME}(): Ignoring option '$1'"
 					;;
 				*)
-					if [[ -d "${myroot}/${1#/}" ]]; then
-						mydirs+=("${myroot}/${1#/}")
-					elif [[ -f "${myroot}/${1#/}" ]]; then
-						# Files are passed to python_mod_compile which is EROOT-aware
-						myfiles+=("$1")
-					elif [[ -e "${myroot}/${1#/}" ]]; then
-						ewarn "${myroot}/${1#/} is not a file or directory!"
-					else
-						ewarn "${myroot}/${1#/} does not exist!"
-					fi
+					break
 					;;
 			esac
 			shift
 		done
 
+		if [[ "$#" -eq 0 ]]; then
+			_python_set_color_variables
+
+			echo
+			echo " ${_RED}*${_NORMAL} ${_RED}Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be${_NORMAL}"
+			echo " ${_RED}*${_NORMAL} ${_RED}disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules.${_NORMAL}"
+			echo " ${_RED}*${_NORMAL} ${_RED}The ebuild needs to be fixed. Please report a bug, if it has not been already reported.${_NORMAL}"
+			echo
+
+			einfo &> /dev/null
+			einfo "Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be" &> /dev/null
+			einfo "disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules." &> /dev/null
+			einfo "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." &> /dev/null
+			einfo &> /dev/null
+		fi
+
+		while (($#)); do
+			if [[ -d "${myroot}/${1#/}" ]]; then
+				mydirs+=("${myroot}/${1#/}")
+			elif [[ -f "${myroot}/${1#/}" ]]; then
+				# Files are passed to python_mod_compile which is EROOT-aware
+				myfiles+=("$1")
+			elif [[ -e "${myroot}/${1#/}" ]]; then
+				eerror "${myroot}/${1#/} is not a file or directory!"
+			else
+				eerror "${myroot}/${1#/} does not exist!"
+			fi
+			shift
+		done
+
 		# set additional opts
 		myopts+=(-q)
 
-		PYTHON_ABI="$(PYTHON --ABI)"
+		PYTHON_ABI="${PYTHON_ABI:-$(PYTHON --ABI)}"
 
 		ebegin "Compilation and optimization of Python modules for $(python_get_implementation) $(python_get_version)"
 		if ((${#mydirs[@]})); then
@@ -2219,7 +2262,7 @@
 	# Strip trailing slash from EROOT.
 	root="${EROOT%/}"
 
-	if (($#)); then
+	if [[ "$#" -gt 0 ]]; then
 		if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
 			while (($#)); do
 				if ! _python_implementation && [[ "$1" =~ ^/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then
@@ -2237,10 +2280,26 @@
 				shift
 			done
 		else
+			# Deprecated part of python_mod_cleanup()
+
 			search_paths=("${@#/}")
 			search_paths=("${search_paths[@]/#/${root}/}")
 		fi
 	else
+		_python_set_color_variables
+
+		echo
+		echo " ${_RED}*${_NORMAL} ${_RED}Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be${_NORMAL}"
+		echo " ${_RED}*${_NORMAL} ${_RED}disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules.${_NORMAL}"
+		echo " ${_RED}*${_NORMAL} ${_RED}The ebuild needs to be fixed. Please report a bug, if it has not been already reported.${_NORMAL}"
+		echo
+
+		einfo &> /dev/null
+		einfo "Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be" &> /dev/null
+		einfo "disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules." &> /dev/null
+		einfo "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." &> /dev/null
+		einfo &> /dev/null
+
 		for dir in "${root}"/usr/lib*; do
 			if [[ -d "${dir}" && ! -L "${dir}" ]]; then
 				for sitedir in "${dir}"/python*/site-packages; do
@@ -2329,11 +2388,11 @@
 	echo " ${_RED}*${_NORMAL} ${_RED}The ebuild needs to be fixed. Please report a bug, if it has not been already reported.${_NORMAL}"
 	echo
 
-	einfo &> /dev/null
-	einfo "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01." &> /dev/null
-	einfo "Use USE dependencies and/or has_version() instead of ${FUNCNAME}()." &> /dev/null
-	einfo "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." &> /dev/null
-	einfo &> /dev/null
+	eerror &> /dev/null
+	eerror "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01." &> /dev/null
+	eerror "Use USE dependencies and/or has_version() instead of ${FUNCNAME}()." &> /dev/null
+	eerror "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." &> /dev/null
+	eerror &> /dev/null
 
 	if [[ "$#" -ne 1 ]]; then
 		die "${FUNCNAME}() requires 1 argument"
@@ -2360,11 +2419,11 @@
 		echo " ${_RED}*${_NORMAL} ${_RED}The ebuild needs to be fixed. Please report a bug, if it has not been already reported.${_NORMAL}"
 		echo
 
-		einfo &> /dev/null
-		einfo "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01." &> /dev/null
-		einfo "Use PYTHON_USE_WITH=\"xml\" and python_pkg_setup() instead of ${FUNCNAME}()." &> /dev/null
-		einfo "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." &> /dev/null
-		einfo &> /dev/null
+		eerror &> /dev/null
+		eerror "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01." &> /dev/null
+		eerror "Use PYTHON_USE_WITH=\"xml\" and python_pkg_setup() instead of ${FUNCNAME}()." &> /dev/null
+		eerror "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." &> /dev/null
+		eerror &> /dev/null
 	fi
 
 	if ! "$(PYTHON ${PYTHON_ABI})" -c "from sys import version_info
@@ -2395,6 +2454,19 @@
 	fi
 
 	_python_initialize_prefix_variables
+	_python_set_color_variables
+
+	echo
+	echo " ${_RED}*${_NORMAL} ${_RED}Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-09-01.${_NORMAL}"
+	echo " ${_RED}*${_NORMAL} ${_RED}Use python_mod_optimize() instead of ${FUNCNAME}().${_NORMAL}"
+	echo " ${_RED}*${_NORMAL} ${_RED}The ebuild needs to be fixed. Please report a bug, if it has not been already reported.${_NORMAL}"
+	echo
+
+	einfo &> /dev/null
+	einfo "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-09-01." &> /dev/null
+	einfo "Use python_mod_optimize() instead of ${FUNCNAME}()." &> /dev/null
+	einfo "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." &> /dev/null
+	einfo &> /dev/null
 
 	local f myroot myfiles=()
 






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2010-05-25 19:49 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2010-05-25 19:49 UTC (permalink / raw
  To: gentoo-commits

arfrever    10/05/25 19:49:54

  Modified:             python.eclass
  Log:
  Fix deprecation warning in python_mod_compile().

Revision  Changes    Path
1.99                 eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.99&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.99&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.98&r2=1.99

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.98
retrieving revision 1.99
diff -u -r1.98 -r1.99
--- python.eclass	25 May 2010 15:04:40 -0000	1.98
+++ python.eclass	25 May 2010 19:49:54 -0000	1.99
@@ -1,6 +1,6 @@
 # Copyright 1999-2010 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.98 2010/05/25 15:04:40 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.99 2010/05/25 19:49:54 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -2456,17 +2456,19 @@
 	_python_initialize_prefix_variables
 	_python_set_color_variables
 
-	echo
-	echo " ${_RED}*${_NORMAL} ${_RED}Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-09-01.${_NORMAL}"
-	echo " ${_RED}*${_NORMAL} ${_RED}Use python_mod_optimize() instead of ${FUNCNAME}().${_NORMAL}"
-	echo " ${_RED}*${_NORMAL} ${_RED}The ebuild needs to be fixed. Please report a bug, if it has not been already reported.${_NORMAL}"
-	echo
+	if [[ "${FUNCNAME[1]}" != "python_mod_optimize" ]]; then
+		echo
+		echo " ${_RED}*${_NORMAL} ${_RED}Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-09-01.${_NORMAL}"
+		echo " ${_RED}*${_NORMAL} ${_RED}Use python_mod_optimize() instead of ${FUNCNAME}().${_NORMAL}"
+		echo " ${_RED}*${_NORMAL} ${_RED}The ebuild needs to be fixed. Please report a bug, if it has not been already reported.${_NORMAL}"
+		echo
 
-	einfo &> /dev/null
-	einfo "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-09-01." &> /dev/null
-	einfo "Use python_mod_optimize() instead of ${FUNCNAME}()." &> /dev/null
-	einfo "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." &> /dev/null
-	einfo &> /dev/null
+		einfo &> /dev/null
+		einfo "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-09-01." &> /dev/null
+		einfo "Use python_mod_optimize() instead of ${FUNCNAME}()." &> /dev/null
+		einfo "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." &> /dev/null
+		einfo &> /dev/null
+	fi
 
 	local f myroot myfiles=()
 






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2010-05-29 16:39 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2010-05-29 16:39 UTC (permalink / raw
  To: gentoo-commits

arfrever    10/05/29 16:39:13

  Modified:             python.eclass
  Log:
  Fix deletion of empty parent directories in _python_clean_compiled_modules().

Revision  Changes    Path
1.100                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.100&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.100&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.99&r2=1.100

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -r1.99 -r1.100
--- python.eclass	25 May 2010 19:49:54 -0000	1.99
+++ python.eclass	29 May 2010 16:39:13 -0000	1.100
@@ -1,6 +1,6 @@
 # Copyright 1999-2010 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.99 2010/05/25 19:49:54 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.100 2010/05/29 16:39:13 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -1923,7 +1923,9 @@
 			if [[ "${EBUILD_PHASE}" == "postrm" ]]; then
 				# Delete empty child directories.
 				find "${path}" -type d | sort -r | while read -r dir; do
-					rmdir "${dir}" 2> /dev/null && echo "${_CYAN}<<< ${dir}${_NORMAL}"
+					if rmdir "${dir}" 2> /dev/null; then
+						echo "${_CYAN}<<< ${dir}${_NORMAL}"
+					fi
 				done
 			fi
 		elif [[ "${path}" == *.py ]]; then
@@ -1979,8 +1981,8 @@
 			# Delete empty parent directories.
 			dir="${compiled_file%/*}"
 			while [[ "${dir}" != "${root}" ]]; do
-				if rmdir "${compiled_file%/*}" 2> /dev/null; then
-					echo "${_CYAN}<<< ${compiled_file%/*}${_NORMAL}"
+				if rmdir "${dir}" 2> /dev/null; then
+					echo "${_CYAN}<<< ${dir}${_NORMAL}"
 				else
 					break
 				fi






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2010-07-17 23:02 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2010-07-17 23:02 UTC (permalink / raw
  To: gentoo-commits

arfrever    10/07/17 23:02:14

  Modified:             python.eclass
  Log:
  Deprecate NEED_PYTHON variable.
  Require python_pkg_setup() in EAPI >=4.
  Ensure that sanity checks in python_pkg_setup() and python_set_active_version() are performed for binary packages.
  Improve handling of arguments in some functions.
  Support flags specific to given Python ABIs.
  Improve sanity checks in some functions.
  Improve error messages in some functions.
  Support --base-path option in python_get_includedir(), python_get_libdir(), python_get_sitedir() and python_get_library().
  Allow multiple paths in argument of --PYTHONPATH option of python_execute_nosetests(), python_execute_py.test() and python_execute_trial().
  Simplify python_mod_optimize() and python_mod_cleanup() in EAPI >=4.
  Clean unneeded code in python_version(), python_mod_exists() and python_tkinter_exists().

Revision  Changes    Path
1.101                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.101&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.101&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.100&r2=1.101

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -r1.100 -r1.101
--- python.eclass	29 May 2010 16:39:13 -0000	1.100
+++ python.eclass	17 Jul 2010 23:02:14 -0000	1.101
@@ -1,6 +1,6 @@
 # Copyright 1999-2010 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.100 2010/05/29 16:39:13 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.101 2010/07/17 23:02:14 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -161,9 +161,26 @@
 	_parse_PYTHON_DEPEND
 elif [[ -n "${NEED_PYTHON}" ]]; then
 	if ! has "${EAPI:-0}" 0 1 2; then
-		eerror "Use PYTHON_DEPEND instead of NEED_PYTHON."
-		die "NEED_PYTHON cannot be used in this EAPI"
+		eerror "Use PYTHON_DEPEND variable instead of NEED_PYTHON variable."
+		die "NEED_PYTHON variable cannot be used in this EAPI"
 	fi
+
+	if [[ "${NOCOLOR:-false}" =~ ^(false|no)$ ]]; then
+		_RED=$'\e[1;31m'
+		_NORMAL=$'\e[0m'
+	else
+		_RED=
+		_NORMAL=
+	fi
+
+	echo
+	echo " ${_RED}*${_NORMAL} ${_RED}Deprecation Warning: NEED_PYTHON variable is deprecated and will be banned on 2010-10-01.${_NORMAL}"
+	echo " ${_RED}*${_NORMAL} ${_RED}Use PYTHON_DEPEND variable instead of NEED_PYTHON variable.${_NORMAL}"
+	echo " ${_RED}*${_NORMAL} ${_RED}The ebuild needs to be fixed. Please report a bug, if it has not been already reported.${_NORMAL}"
+	echo
+
+	unset _BOLD _NORMAL
+
 	_PYTHON_ATOMS=(">=dev-lang/python-${NEED_PYTHON}")
 	DEPEND+="${DEPEND:+ }${_PYTHON_ATOMS[@]}"
 	RDEPEND+="${RDEPEND:+ }${_PYTHON_ATOMS[@]}"
@@ -243,6 +260,10 @@
 	fi
 }
 
+_python_abi-specific_local_scope() {
+	[[ " ${FUNCNAME[@]:2} " =~ " "(_python_final_sanity_checks|python_execute_function|python_mod_optimize|python_mod_cleanup)" " ]]
+}
+
 _python_initialize_prefix_variables() {
 	if has "${EAPI:-0}" 0 1 2; then
 		if [[ -n "${ROOT}" && -z "${EROOT}" ]]; then
@@ -254,10 +275,10 @@
 	fi
 }
 
-unset PYTHON_SANITY_CHECKS
+unset PYTHON_SANITY_CHECKS_EXECUTED PYTHON_SKIP_SANITY_CHECKS
 
 _python_initial_sanity_checks() {
-	if [[ "$(declare -p PYTHON_SANITY_CHECKS 2> /dev/null)" != "declare -- PYTHON_SANITY_CHECKS="* ]]; then
+	if [[ "$(declare -p PYTHON_SANITY_CHECKS_EXECUTED 2> /dev/null)" != "declare -- PYTHON_SANITY_CHECKS_EXECUTED="* || " ${FUNCNAME[@]:1} " =~ " "(python_set_active_version|python_pkg_setup)" " && -z "${PYTHON_SKIP_SANITY_CHECKS}" ]]; then
 		# Ensure that /usr/bin/python and /usr/bin/python-config are valid.
 		if [[ "$(readlink "${EPREFIX}/usr/bin/python")" != "python-wrapper" ]]; then
 			eerror "'${EPREFIX}/usr/bin/python' is not valid symlink."
@@ -273,7 +294,7 @@
 }
 
 _python_final_sanity_checks() {
-	if ! _python_implementation && [[ "$(declare -p PYTHON_SANITY_CHECKS 2> /dev/null)" != "declare -- PYTHON_SANITY_CHECKS="* ]]; then
+	if ! _python_implementation && [[ "$(declare -p PYTHON_SANITY_CHECKS_EXECUTED 2> /dev/null)" != "declare -- PYTHON_SANITY_CHECKS_EXECUTED="* || " ${FUNCNAME[@]:1} " =~ " "(python_set_active_version|python_pkg_setup)" " && -z "${PYTHON_SKIP_SANITY_CHECKS}" ]]; then
 		local PYTHON_ABI="${PYTHON_ABI}"
 		for PYTHON_ABI in ${PYTHON_ABIS-${PYTHON_ABI}}; do
 			# Ensure that appropriate version of Python is installed.
@@ -293,7 +314,7 @@
 			fi
 		done
 	fi
-	PYTHON_SANITY_CHECKS="1"
+	PYTHON_SANITY_CHECKS_EXECUTED="1"
 }
 
 _python_set_color_variables() {
@@ -316,6 +337,14 @@
 
 unset PYTHON_PKG_SETUP_EXECUTED
 
+_python_check_python_pkg_setup_execution() {
+	[[ " ${FUNCNAME[@]:1} " =~ " "(python_set_active_version|python_pkg_setup)" " ]] && return
+
+	if ! has "${EAPI:-0}" 0 1 2 3 && [[ -z "${PYTHON_PKG_SETUP_EXECUTED}" ]]; then
+		die "python_pkg_setup() not called"
+	fi
+}
+
 # @FUNCTION: python_pkg_setup
 # @DESCRIPTION:
 # Perform sanity checks and initialize environment.
@@ -328,6 +357,10 @@
 	# Check if phase is pkg_setup().
 	[[ "${EBUILD_PHASE}" != "setup" ]] && die "${FUNCNAME}() can be used only in pkg_setup() phase"
 
+	if [[ "$#" -ne 0 ]]; then
+		die "${FUNCNAME}() does not accept arguments"
+	fi
+
 	if _python_package_supporting_installation_for_multiple_python_abis; then
 		_python_calculate_PYTHON_ABIS
 		export EPYTHON="$(PYTHON -f)"
@@ -368,7 +401,7 @@
 		}
 
 		if _python_package_supporting_installation_for_multiple_python_abis; then
-			python_execute_function -q python_pkg_setup_check_USE_flags
+			PYTHON_SKIP_SANITY_CHECKS="1" python_execute_function -q python_pkg_setup_check_USE_flags
 		else
 			python_pkg_setup_check_USE_flags
 		fi
@@ -388,6 +421,8 @@
 # @DESCRIPTION:
 # Convert shebangs in specified files. Directories can be specified only with --recursive option.
 python_convert_shebangs() {
+	_python_check_python_pkg_setup_execution
+
 	local argument file files=() only_executables="0" python_version quiet="0" recursive="0"
 
 	while (($#)); do
@@ -466,6 +501,7 @@
 # @DESCRIPTION:
 # Delete needless files in installation image.
 python_clean_installation_image() {
+	_python_check_python_pkg_setup_execution
 	_python_initialize_prefix_variables
 
 	local file files=() quiet="0"
@@ -538,15 +574,23 @@
 # src_prepare, src_configure, src_compile, src_test, src_install.
 if ! has "${EAPI:-0}" 0 1; then
 	python_src_prepare() {
+		_python_check_python_pkg_setup_execution
+
 		if ! _python_package_supporting_installation_for_multiple_python_abis; then
 			die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
 		fi
 
+		if [[ "$#" -ne 0 ]]; then
+			die "${FUNCNAME}() does not accept arguments"
+		fi
+
 		python_copy_sources
 	}
 
 	for python_default_function in src_configure src_compile src_test src_install; do
 		eval "python_${python_default_function}() {
+			_python_check_python_pkg_setup_execution
+
 			if ! _python_package_supporting_installation_for_multiple_python_abis; then
 				die \"\${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs\"
 			fi
@@ -691,19 +735,73 @@
 	_python_final_sanity_checks
 }
 
+_python_prepare_flags() {
+	local array=() deleted_flag element flags new_value old_flag old_value operator pattern prefix variable
+
+	for variable in CPPFLAGS CFLAGS CXXFLAGS LDFLAGS; do
+		eval "_PYTHON_SAVED_${variable}=\"\${!variable}\""
+		for prefix in PYTHON_USER_ PYTHON_; do
+			if [[ "$(declare -p ${prefix}${variable} 2> /dev/null)" == "declare -a ${prefix}${variable}="* ]]; then
+				eval "array=(\"\${${prefix}${variable}[@]}\")"
+				for element in "${array[@]}"; do
+					if [[ "${element}" =~ ^([[:alnum:]]|\.|-|\*|\[|\])+\ (\+|-)\ .+ ]]; then
+						pattern="${element%% *}"
+						element="${element#* }"
+						operator="${element%% *}"
+						flags="${element#* }"
+						if [[ "${PYTHON_ABI}" == ${pattern} ]]; then
+							if [[ "${operator}" == "+" ]]; then
+								eval "export ${variable}+=\"\${variable:+ }${flags}\""
+							elif [[ "${operator}" == "-" ]]; then
+								flags="${flags// /$'\n'}"
+								old_value="${!variable// /$'\n'}"
+								new_value=""
+								while read old_flag; do
+									while read deleted_flag; do
+										if [[ "${old_flag}" == ${deleted_flag} ]]; then
+											continue 2
+										fi
+									done <<< "${flags}"
+									new_value+="${new_value:+ }${old_flag}"
+								done <<< "${old_value}"
+								eval "export ${variable}=\"\${new_value}\""
+							fi
+						fi
+					else
+						die "Element '${element}' of ${prefix}${variable} array has invalid syntax"
+					fi
+				done
+			elif [[ -n "$(declare -p ${prefix}${variable} 2> /dev/null)" ]]; then
+				die "${prefix}${variable} should be indexed array"
+			fi
+		done
+	done
+}
+
+_python_restore_flags() {
+	local variable
+
+	for variable in CPPFLAGS CFLAGS CXXFLAGS LDFLAGS; do
+		eval "${variable}=\"\${_PYTHON_SAVED_${variable}}\""
+		unset _PYTHON_SAVED_${variable}
+	done
+}
+
 # @FUNCTION: python_execute_function
 # @USAGE: [--action-message message] [-d|--default-function] [--failure-message message] [-f|--final-ABI] [--nonfatal] [-q|--quiet] [-s|--separate-build-dirs] [--source-dir source_directory] [--] <function> [arguments]
 # @DESCRIPTION:
 # Execute specified function for each value of PYTHON_ABIS, optionally passing additional
 # arguments. The specified function can use PYTHON_ABI and BUILDDIR variables.
 python_execute_function() {
+	_python_check_python_pkg_setup_execution
+
 	if ! _python_package_supporting_installation_for_multiple_python_abis; then
 		die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
 	fi
 
 	_python_set_color_variables
 
-	local action action_message action_message_template= default_function="0" failure_message failure_message_template= final_ABI="0" function i iterated_PYTHON_ABIS nonfatal="0" previous_directory previous_directory_stack previous_directory_stack_length PYTHON_ABI quiet="0" separate_build_dirs="0" source_dir=
+	local action action_message action_message_template= default_function="0" failure_message failure_message_template= final_ABI="0" function iterated_PYTHON_ABIS nonfatal="0" previous_directory previous_directory_stack previous_directory_stack_length PYTHON_ABI quiet="0" return_code separate_build_dirs="0" source_dir=
 
 	while (($#)); do
 		case "$1" in
@@ -800,11 +898,9 @@
 	fi
 
 	# Ensure that python_execute_function() cannot be directly or indirectly called by python_execute_function().
-	for ((i = 1; i < "${#FUNCNAME[@]}"; i++)); do
-		if [[ "${FUNCNAME[${i}]}" == "${FUNCNAME}" ]]; then
-			die "${FUNCNAME}(): Invalid call stack"
-		fi
-	done
+	if _python_abi-specific_local_scope; then
+		die "${FUNCNAME}(): Invalid call stack"
+	fi
 
 	if [[ "${quiet}" == "0" ]]; then
 		[[ "${EBUILD_PHASE}" == "setup" ]] && action="Setting up"
@@ -827,6 +923,8 @@
 		iterated_PYTHON_ABIS="${PYTHON_ABIS}"
 	fi
 	for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
+		_python_prepare_flags
+
 		if [[ "${quiet}" == "0" ]]; then
 			if [[ -n "${action_message_template}" ]]; then
 				action_message="$(eval echo -n "${action_message_template}")"
@@ -857,7 +955,11 @@
 			EPYTHON="$(PYTHON)" "${function}" "$@"
 		fi
 
-		if [[ "$?" != "0" ]]; then
+		return_code="$?"
+
+		_python_restore_flags
+
+		if [[ "${return_code}" -ne 0 ]]; then
 			if [[ -n "${failure_message_template}" ]]; then
 				failure_message="$(eval echo -n "${failure_message_template}")"
 			else
@@ -924,6 +1026,8 @@
 # @DESCRIPTION:
 # Copy unpacked sources of current package to separate build directory for each Python ABI.
 python_copy_sources() {
+	_python_check_python_pkg_setup_execution
+
 	if ! _python_package_supporting_installation_for_multiple_python_abis; then
 		die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
 	fi
@@ -954,6 +1058,8 @@
 # If --respect-EPYTHON option is specified, then generated wrapper scripts will
 # respect EPYTHON variable at run time.
 python_generate_wrapper_scripts() {
+	_python_check_python_pkg_setup_execution
+
 	if ! _python_package_supporting_installation_for_multiple_python_abis; then
 		die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
 	fi
@@ -1157,11 +1263,18 @@
 # ========= FUNCTIONS FOR PACKAGES NOT SUPPORTING INSTALLATION FOR MULTIPLE PYTHON ABIS ==========
 # ================================================================================================
 
+unset EPYTHON PYTHON_ABI
+
 # @FUNCTION: python_set_active_version
 # @USAGE: <CPython_ABI|2|3>
 # @DESCRIPTION:
 # Set specified version of CPython as active version of Python.
+#
+# This function can be used only in pkg_setup() phase.
 python_set_active_version() {
+	# Check if phase is pkg_setup().
+	[[ "${EBUILD_PHASE}" != "setup" ]] && die "${FUNCNAME}() can be used only in pkg_setup() phase"
+
 	if _python_package_supporting_installation_for_multiple_python_abis; then
 		die "${FUNCNAME}() cannot be used in ebuilds of packages supporting installation for multiple Python ABIs"
 	fi
@@ -1172,29 +1285,31 @@
 
 	_python_initial_sanity_checks
 
-	if [[ "$1" =~ ^[[:digit:]]+\.[[:digit:]]+$ ]]; then
-		if ! _python_implementation && ! has_version "dev-lang/python:$1"; then
-			die "${FUNCNAME}(): 'dev-lang/python:$1' is not installed"
-		fi
-		export EPYTHON="$(PYTHON "$1")"
-	elif [[ "$1" == "2" ]]; then
-		if ! _python_implementation && ! has_version "=dev-lang/python-2*"; then
-			die "${FUNCNAME}(): '=dev-lang/python-2*' is not installed"
-		fi
-		export EPYTHON="$(PYTHON -2)"
-	elif [[ "$1" == "3" ]]; then
-		if ! _python_implementation && ! has_version "=dev-lang/python-3*"; then
-			die "${FUNCNAME}(): '=dev-lang/python-3*' is not installed"
+	if [[ -z "${PYTHON_ABI}" ]]; then
+		if [[ "$1" =~ ^[[:digit:]]+\.[[:digit:]]+$ ]]; then
+			if ! _python_implementation && ! has_version "dev-lang/python:$1"; then
+				die "${FUNCNAME}(): 'dev-lang/python:$1' is not installed"
+			fi
+			export EPYTHON="$(PYTHON "$1")"
+		elif [[ "$1" == "2" ]]; then
+			if ! _python_implementation && ! has_version "=dev-lang/python-2*"; then
+				die "${FUNCNAME}(): '=dev-lang/python-2*' is not installed"
+			fi
+			export EPYTHON="$(PYTHON -2)"
+		elif [[ "$1" == "3" ]]; then
+			if ! _python_implementation && ! has_version "=dev-lang/python-3*"; then
+				die "${FUNCNAME}(): '=dev-lang/python-3*' is not installed"
+			fi
+			export EPYTHON="$(PYTHON -3)"
+		else
+			die "${FUNCNAME}(): Unrecognized argument '$1'"
 		fi
-		export EPYTHON="$(PYTHON -3)"
-	else
-		die "${FUNCNAME}(): Unrecognized argument '$1'"
-	fi
 
-	# PYTHON_ABI variable is intended to be used only in ebuilds/eclasses,
-	# so it does not need to be exported to subprocesses.
-	PYTHON_ABI="${EPYTHON#python}"
-	PYTHON_ABI="${PYTHON_ABI%%-*}"
+		# PYTHON_ABI variable is intended to be used only in ebuilds/eclasses,
+		# so it does not need to be exported to subprocesses.
+		PYTHON_ABI="${EPYTHON#python}"
+		PYTHON_ABI="${PYTHON_ABI%%-*}"
+	fi
 
 	_python_final_sanity_checks
 
@@ -1206,10 +1321,16 @@
 # @DESCRIPTION: Mark current package for rebuilding by python-updater after
 # switching of active version of Python.
 python_need_rebuild() {
+	_python_check_python_pkg_setup_execution
+
 	if _python_package_supporting_installation_for_multiple_python_abis; then
 		die "${FUNCNAME}() cannot be used in ebuilds of packages supporting installation for multiple Python ABIs"
 	fi
 
+	if [[ "$#" -ne 0 ]]; then
+		die "${FUNCNAME}() does not accept arguments"
+	fi
+
 	export PYTHON_NEED_REBUILD="$(PYTHON --ABI)"
 }
 
@@ -1251,6 +1372,8 @@
 # If --absolute-path option is specified, then absolute path to Python interpreter is printed.
 # --ABI and --absolute-path options cannot be specified simultaneously.
 PYTHON() {
+	_python_check_python_pkg_setup_execution
+
 	local ABI_output="0" absolute_path_output="0" final_ABI="0" PYTHON_ABI="${PYTHON_ABI}" python_interpreter python2="0" python3="0"
 
 	while (($#)); do
@@ -1285,7 +1408,7 @@
 	done
 
 	if [[ "${ABI_output}" == "1" && "${absolute_path_output}" == "1" ]]; then
-		die "${FUNCNAME}(): '--ABI and '--absolute-path' options cannot be specified simultaneously"
+		die "${FUNCNAME}(): '--ABI' and '--absolute-path' options cannot be specified simultaneously"
 	fi
 
 	if [[ "$((${python2} + ${python3} + ${final_ABI}))" -gt 1 ]]; then
@@ -1313,13 +1436,15 @@
 			elif [[ "${PYTHON_ABI}" != "3."* ]]; then
 				die "${FUNCNAME}(): Internal error in \`eselect python show --python3\`"
 			fi
-		elif ! _python_package_supporting_installation_for_multiple_python_abis; then
+		elif _python_package_supporting_installation_for_multiple_python_abis; then
+			if ! _python_abi-specific_local_scope; then
+				die "${FUNCNAME}() should be used in ABI-specific local scope"
+			fi
+		else
 			PYTHON_ABI="$("${EPREFIX}/usr/bin/python" -c "${_PYTHON_ABI_EXTRACTION_COMMAND}")"
 			if [[ -z "${PYTHON_ABI}" ]]; then
 				die "${FUNCNAME}(): Failure of extraction of locally active version of Python"
 			fi
-		elif [[ -z "${PYTHON_ABI}" ]]; then
-			die "${FUNCNAME}(): Invalid usage: ${FUNCNAME}() should be used in ABI-specific local scope"
 		fi
 	elif [[ "$#" -eq 1 ]]; then
 		if [[ "${final_ABI}" == "1" ]]; then
@@ -1364,6 +1489,8 @@
 # Print name of Python implementation.
 # If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
 python_get_implementation() {
+	_python_check_python_pkg_setup_execution
+
 	local final_ABI="0" PYTHON_ABI="${PYTHON_ABI}"
 
 	while (($#)); do
@@ -1386,8 +1513,14 @@
 			die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
 		fi
 		PYTHON_ABI="$(PYTHON -f --ABI)"
-	elif [[ -z "${PYTHON_ABI}" ]]; then
-		PYTHON_ABI="$(PYTHON --ABI)"
+	else
+		if _python_package_supporting_installation_for_multiple_python_abis; then
+			if ! _python_abi-specific_local_scope; then
+				die "${FUNCNAME}() should be used in ABI-specific local scope"
+			fi
+		else
+			PYTHON_ABI="${PYTHON_ABI:-$(PYTHON --ABI)}"
+		fi
 	fi
 
 	echo "$(_python_get_implementation "${PYTHON_ABI}")"
@@ -1399,6 +1532,8 @@
 # Print category, name and slot of package providing Python implementation.
 # If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
 python_get_implementational_package() {
+	_python_check_python_pkg_setup_execution
+
 	local final_ABI="0" PYTHON_ABI="${PYTHON_ABI}"
 
 	while (($#)); do
@@ -1421,8 +1556,14 @@
 			die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
 		fi
 		PYTHON_ABI="$(PYTHON -f --ABI)"
-	elif [[ -z "${PYTHON_ABI}" ]]; then
-		PYTHON_ABI="$(PYTHON --ABI)"
+	else
+		if _python_package_supporting_installation_for_multiple_python_abis; then
+			if ! _python_abi-specific_local_scope; then
+				die "${FUNCNAME}() should be used in ABI-specific local scope"
+			fi
+		else
+			PYTHON_ABI="${PYTHON_ABI:-$(PYTHON --ABI)}"
+		fi
 	fi
 
 	if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
@@ -1433,15 +1574,21 @@
 }
 
 # @FUNCTION: python_get_includedir
-# @USAGE: [-f|--final-ABI]
+# @USAGE: [-b|--base-path] [-f|--final-ABI]
 # @DESCRIPTION:
 # Print path to Python include directory.
+# If --base-path option is specified, then path not prefixed with "/" is printed.
 # If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
 python_get_includedir() {
-	local final_ABI="0" PYTHON_ABI="${PYTHON_ABI}"
+	_python_check_python_pkg_setup_execution
+
+	local base_path="0" final_ABI="0" prefix PYTHON_ABI="${PYTHON_ABI}"
 
 	while (($#)); do
 		case "$1" in
+			-b|--base-path)
+				base_path="1"
+				;;
 			-f|--final-ABI)
 				final_ABI="1"
 				;;
@@ -1455,32 +1602,48 @@
 		shift
 	done
 
+	if [[ "${base_path}" == "0" ]]; then
+		prefix="/"
+	fi
+
 	if [[ "${final_ABI}" == "1" ]]; then
 		if ! _python_package_supporting_installation_for_multiple_python_abis; then
 			die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
 		fi
 		PYTHON_ABI="$(PYTHON -f --ABI)"
-	elif [[ -z "${PYTHON_ABI}" ]]; then
-		PYTHON_ABI="$(PYTHON --ABI)"
+	else
+		if _python_package_supporting_installation_for_multiple_python_abis; then
+			if ! _python_abi-specific_local_scope; then
+				die "${FUNCNAME}() should be used in ABI-specific local scope"
+			fi
+		else
+			PYTHON_ABI="${PYTHON_ABI:-$(PYTHON --ABI)}"
+		fi
 	fi
 
 	if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
-		echo "/usr/include/python${PYTHON_ABI}"
+		echo "${prefix}usr/include/python${PYTHON_ABI}"
 	elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
-		echo "/usr/share/jython-${PYTHON_ABI%-jython}/Include"
+		echo "${prefix}usr/share/jython-${PYTHON_ABI%-jython}/Include"
 	fi
 }
 
 # @FUNCTION: python_get_libdir
-# @USAGE: [-f|--final-ABI]
+# @USAGE: [-b|--base-path] [-f|--final-ABI]
 # @DESCRIPTION:
 # Print path to Python library directory.
+# If --base-path option is specified, then path not prefixed with "/" is printed.
 # If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
 python_get_libdir() {
-	local final_ABI="0" PYTHON_ABI="${PYTHON_ABI}"
+	_python_check_python_pkg_setup_execution
+
+	local base_path="0" final_ABI="0" prefix PYTHON_ABI="${PYTHON_ABI}"
 
 	while (($#)); do
 		case "$1" in
+			-b|--base-path)
+				base_path="1"
+				;;
 			-f|--final-ABI)
 				final_ABI="1"
 				;;
@@ -1494,36 +1657,50 @@
 		shift
 	done
 
+	if [[ "${base_path}" == "0" ]]; then
+		prefix="/"
+	fi
+
 	if [[ "${final_ABI}" == "1" ]]; then
 		if ! _python_package_supporting_installation_for_multiple_python_abis; then
 			die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
 		fi
 		PYTHON_ABI="$(PYTHON -f --ABI)"
-	elif [[ -z "${PYTHON_ABI}" ]]; then
-		PYTHON_ABI="$(PYTHON --ABI)"
+	else
+		if _python_package_supporting_installation_for_multiple_python_abis; then
+			if ! _python_abi-specific_local_scope; then
+				die "${FUNCNAME}() should be used in ABI-specific local scope"
+			fi
+		else
+			PYTHON_ABI="${PYTHON_ABI:-$(PYTHON --ABI)}"
+		fi
 	fi
 
 	if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
-		echo "/usr/$(get_libdir)/python${PYTHON_ABI}"
+		echo "${prefix}usr/$(get_libdir)/python${PYTHON_ABI}"
 	elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
-		echo "/usr/share/jython-${PYTHON_ABI%-jython}/Lib"
+		echo "${prefix}usr/share/jython-${PYTHON_ABI%-jython}/Lib"
 	fi
 }
 
 # @FUNCTION: python_get_sitedir
-# @USAGE: [-f|--final-ABI]
+# @USAGE: [-b|--base-path] [-f|--final-ABI]
 # @DESCRIPTION:
 # Print path to Python site-packages directory.
+# If --base-path option is specified, then path not prefixed with "/" is printed.
 # If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
 python_get_sitedir() {
-	local options=()
+	_python_check_python_pkg_setup_execution
+
+	local final_ABI="0" options=()
 
 	while (($#)); do
 		case "$1" in
+			-b|--base-path)
+				options+=("$1")
+				;;
 			-f|--final-ABI)
-				if ! _python_package_supporting_installation_for_multiple_python_abis; then
-					die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
-				fi
+				final_ABI="1"
 				options+=("$1")
 				;;
 			-*)
@@ -1536,20 +1713,36 @@
 		shift
 	done
 
+	if [[ "${final_ABI}" == "1" ]]; then
+		if ! _python_package_supporting_installation_for_multiple_python_abis; then
+			die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
+		fi
+	else
+		if _python_package_supporting_installation_for_multiple_python_abis && ! _python_abi-specific_local_scope; then
+			die "${FUNCNAME}() should be used in ABI-specific local scope"
+		fi
+	fi
+
 	echo "$(python_get_libdir "${options[@]}")/site-packages"
 }
 
 # @FUNCTION: python_get_library
-# @USAGE: [-f|--final-ABI] [-l|--linker-option]
+# @USAGE: [-b|--base-path] [-f|--final-ABI] [-l|--linker-option]
 # @DESCRIPTION:
 # Print path to Python library.
+# If --base-path option is specified, then path not prefixed with "/" is printed.
 # If --linker-option is specified, then "-l${library}" linker option is printed.
 # If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
 python_get_library() {
-	local final_ABI="0" linker_option="0" PYTHON_ABI="${PYTHON_ABI}"
+	_python_check_python_pkg_setup_execution
+
+	local base_path="0" final_ABI="0" linker_option="0" prefix PYTHON_ABI="${PYTHON_ABI}"
 
 	while (($#)); do
 		case "$1" in
+			-b|--base-path)
+				base_path="1"
+				;;
 			-f|--final-ABI)
 				final_ABI="1"
 				;;
@@ -1566,20 +1759,34 @@
 		shift
 	done
 
+	if [[ "${base_path}" == "0" ]]; then
+		prefix="/"
+	fi
+
+	if [[ "${base_path}" == "1" && "${linker_option}" == "1" ]]; then
+		die "${FUNCNAME}(): '--base-path' and '--linker-option' options cannot be specified simultaneously"
+	fi
+
 	if [[ "${final_ABI}" == "1" ]]; then
 		if ! _python_package_supporting_installation_for_multiple_python_abis; then
 			die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
 		fi
 		PYTHON_ABI="$(PYTHON -f --ABI)"
-	elif [[ -z "${PYTHON_ABI}" ]]; then
-		PYTHON_ABI="$(PYTHON --ABI)"
+	else
+		if _python_package_supporting_installation_for_multiple_python_abis; then
+			if ! _python_abi-specific_local_scope; then
+				die "${FUNCNAME}() should be used in ABI-specific local scope"
+			fi
+		else
+			PYTHON_ABI="${PYTHON_ABI:-$(PYTHON --ABI)}"
+		fi
 	fi
 
 	if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
 		if [[ "${linker_option}" == "1" ]]; then
 			echo "-lpython${PYTHON_ABI}"
 		else
-			echo "/usr/$(get_libdir)/libpython${PYTHON_ABI}$(get_libname)"
+			echo "${prefix}usr/$(get_libdir)/libpython${PYTHON_ABI}$(get_libname)"
 		fi
 	elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
 		die "${FUNCNAME}(): Jython does not have shared library"
@@ -1594,6 +1801,8 @@
 # If --full, --major, --minor and --micro options are not specified, then "${major_version}.${minor_version}" is printed.
 # If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
 python_get_version() {
+	_python_check_python_pkg_setup_execution
+
 	local final_ABI="0" full="0" major="0" minor="0" micro="0" python_command
 
 	while (($#)); do
@@ -1653,6 +1862,9 @@
 		fi
 		"$(PYTHON -f)" -c "${python_command}"
 	else
+		if _python_package_supporting_installation_for_multiple_python_abis && ! _python_abi-specific_local_scope; then
+			die "${FUNCNAME}() should be used in ABI-specific local scope"
+		fi
 		"$(PYTHON ${PYTHON_ABI})" -c "${python_command}"
 	fi
 }
@@ -1684,6 +1896,7 @@
 # In ebuilds of packages supporting installation for multiple Python ABIs, this function calls
 # python_execute_nosetests_pre_hook() and python_execute_nosetests_post_hook(), if they are defined.
 python_execute_nosetests() {
+	_python_check_python_pkg_setup_execution
 	_python_set_color_variables
 
 	local PYTHONPATH_template= separate_build_dirs=
@@ -1712,14 +1925,9 @@
 	done
 
 	python_test_function() {
-		local evaluated_PYTHONPATH=
+		local evaluated_PYTHONPATH
 
-		if [[ -n "${PYTHONPATH_template}" ]]; then
-			evaluated_PYTHONPATH="$(eval echo -n "${PYTHONPATH_template}")"
-			if [[ ! -e "${evaluated_PYTHONPATH}" ]]; then
-				unset evaluated_PYTHONPATH
-			fi
-		fi
+		evaluated_PYTHONPATH="$(eval echo -n "${PYTHONPATH_template}")"
 
 		_python_test_hook pre
 
@@ -1752,6 +1960,7 @@
 # In ebuilds of packages supporting installation for multiple Python ABIs, this function calls
 # python_execute_py.test_pre_hook() and python_execute_py.test_post_hook(), if they are defined.
 python_execute_py.test() {
+	_python_check_python_pkg_setup_execution
 	_python_set_color_variables
 
 	local PYTHONPATH_template= separate_build_dirs=
@@ -1780,14 +1989,9 @@
 	done
 
 	python_test_function() {
-		local evaluated_PYTHONPATH=
+		local evaluated_PYTHONPATH
 
-		if [[ -n "${PYTHONPATH_template}" ]]; then
-			evaluated_PYTHONPATH="$(eval echo -n "${PYTHONPATH_template}")"
-			if [[ ! -e "${evaluated_PYTHONPATH}" ]]; then
-				unset evaluated_PYTHONPATH
-			fi
-		fi
+		evaluated_PYTHONPATH="$(eval echo -n "${PYTHONPATH_template}")"
 
 		_python_test_hook pre
 
@@ -1820,6 +2024,7 @@
 # In ebuilds of packages supporting installation for multiple Python ABIs, this function
 # calls python_execute_trial_pre_hook() and python_execute_trial_post_hook(), if they are defined.
 python_execute_trial() {
+	_python_check_python_pkg_setup_execution
 	_python_set_color_variables
 
 	local PYTHONPATH_template= separate_build_dirs=
@@ -1848,14 +2053,9 @@
 	done
 
 	python_test_function() {
-		local evaluated_PYTHONPATH=
+		local evaluated_PYTHONPATH
 
-		if [[ -n "${PYTHONPATH_template}" ]]; then
-			evaluated_PYTHONPATH="$(eval echo -n "${PYTHONPATH_template}")"
-			if [[ ! -e "${evaluated_PYTHONPATH}" ]]; then
-				unset evaluated_PYTHONPATH
-			fi
-		fi
+		evaluated_PYTHONPATH="$(eval echo -n "${PYTHONPATH_template}")"
 
 		_python_test_hook pre
 
@@ -1890,6 +2090,12 @@
 # Tell Python to automatically recompile modules to .pyc/.pyo if the
 # timestamps/version stamps have changed.
 python_enable_pyc() {
+	_python_check_python_pkg_setup_execution
+
+	if [[ "$#" -ne 0 ]]; then
+		die "${FUNCNAME}() does not accept arguments"
+	fi
+
 	unset PYTHONDONTWRITEBYTECODE
 }
 
@@ -1899,6 +2105,12 @@
 # even if the timestamps/version stamps do not match. This is done
 # to protect sandbox.
 python_disable_pyc() {
+	_python_check_python_pkg_setup_execution
+
+	if [[ "$#" -ne 0 ]]; then
+		die "${FUNCNAME}() does not accept arguments"
+	fi
+
 	export PYTHONDONTWRITEBYTECODE="1"
 }
 
@@ -2005,6 +2217,7 @@
 #
 # This function can be used only in pkg_postinst() phase.
 python_mod_optimize() {
+	_python_check_python_pkg_setup_execution
 	_python_initialize_prefix_variables
 
 	# Check if phase is pkg_postinst().
@@ -2015,12 +2228,16 @@
 		local dir file iterated_PYTHON_ABIS options=() other_dirs=() other_files=() previous_PYTHON_ABI="${PYTHON_ABI}" return_code root site_packages_absolute_dirs=() site_packages_dirs=() site_packages_absolute_files=() site_packages_files=()
 
 		if _python_package_supporting_installation_for_multiple_python_abis; then
-			if [[ -z "${PYTHON_ABIS}" ]]; then
-				die "${FUNCNAME}(): Environment not initialized"
+			if has "${EAPI:-0}" 0 1 2 3 && [[ -z "${PYTHON_ABIS}" ]]; then
+				die "${FUNCNAME}(): python_pkg_setup() or python_execute_function() not called"
 			fi
 			iterated_PYTHON_ABIS="${PYTHON_ABIS}"
 		else
-			iterated_PYTHON_ABIS="${PYTHON_ABI:=$(PYTHON --ABI)}"
+			if has "${EAPI:-0}" 0 1 2 3; then
+				iterated_PYTHON_ABIS="${PYTHON_ABI:=$(PYTHON --ABI)}"
+			else
+				iterated_PYTHON_ABIS="${PYTHON_ABI}"
+			fi
 		fi
 
 		# Strip trailing slash from EROOT.
@@ -2035,8 +2252,12 @@
 					options+=("$1" "$2")
 					shift
 					;;
+				--)
+					shift
+					break
+					;;
 				-*)
-					ewarn "${FUNCNAME}(): Ignoring option '$1'"
+					die "${FUNCNAME}(): Unrecognized option '$1'"
 					;;
 				*)
 					break
@@ -2062,7 +2283,9 @@
 		fi
 
 		while (($#)); do
-			if ! _python_implementation && [[ "$1" =~ ^/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then
+			if [[ "$1" =~ ^($|(\.|\.\.|/)($|/)) ]]; then
+				die "${FUNCNAME}(): Invalid argument '$1'"
+			elif ! _python_implementation && [[ "$1" =~ ^/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then
 				die "${FUNCNAME}(): Paths of directories / files in site-packages directories must be relative to site-packages directories"
 			elif [[ "$1" =~ ^/ ]]; then
 				if _python_package_supporting_installation_for_multiple_python_abis; then
@@ -2073,9 +2296,9 @@
 				elif [[ -f "${root}$1" ]]; then
 					other_files+=("${root}$1")
 				elif [[ -e "${root}$1" ]]; then
-					eerror "'${root}$1' is not a file or a directory!"
+					eerror "${FUNCNAME}(): '${root}$1' is not a regular file or a directory"
 				else
-					eerror "'${root}$1' does not exist!"
+					eerror "${FUNCNAME}(): '${root}$1' does not exist"
 				fi
 			else
 				for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
@@ -2086,9 +2309,9 @@
 						site_packages_files+=("$1")
 						break
 					elif [[ -e "${root}$(python_get_sitedir)/$1" ]]; then
-						eerror "'$1' is not a file or a directory!"
+						eerror "${FUNCNAME}(): '$1' is not a regular file or a directory"
 					else
-						eerror "'$1' does not exist!"
+						eerror "${FUNCNAME}(): '$1' does not exist"
 					fi
 				done
 			fi
@@ -2173,8 +2396,12 @@
 					myopts+=("$1" "$2")
 					shift
 					;;
+				--)
+					shift
+					break
+					;;
 				-*)
-					ewarn "${FUNCNAME}(): Ignoring option '$1'"
+					die "${FUNCNAME}(): Unrecognized option '$1'"
 					;;
 				*)
 					break
@@ -2200,15 +2427,17 @@
 		fi
 
 		while (($#)); do
-			if [[ -d "${myroot}/${1#/}" ]]; then
+			if [[ "$1" =~ ^($|(\.|\.\.|/)($|/)) ]]; then
+				die "${FUNCNAME}(): Invalid argument '$1'"
+			elif [[ -d "${myroot}/${1#/}" ]]; then
 				mydirs+=("${myroot}/${1#/}")
 			elif [[ -f "${myroot}/${1#/}" ]]; then
 				# Files are passed to python_mod_compile which is EROOT-aware
 				myfiles+=("$1")
 			elif [[ -e "${myroot}/${1#/}" ]]; then
-				eerror "${myroot}/${1#/} is not a file or directory!"
+				eerror "${FUNCNAME}(): ${myroot}/${1#/} is not a regular file or directory"
 			else
-				eerror "${myroot}/${1#/} does not exist!"
+				eerror "${FUNCNAME}(): ${myroot}/${1#/} does not exist"
 			fi
 			shift
 		done
@@ -2245,6 +2474,7 @@
 #
 # This function can be used only in pkg_postrm() phase.
 python_mod_cleanup() {
+	_python_check_python_pkg_setup_execution
 	_python_initialize_prefix_variables
 
 	local dir iterated_PYTHON_ABIS PYTHON_ABI="${PYTHON_ABI}" root search_paths=() sitedir
@@ -2253,12 +2483,16 @@
 	[[ "${EBUILD_PHASE}" != "postrm" ]] && die "${FUNCNAME}() can be used only in pkg_postrm() phase"
 
 	if _python_package_supporting_installation_for_multiple_python_abis; then
-		if [[ -z "${PYTHON_ABIS}" ]]; then
-			die "${FUNCNAME}(): Environment not initialized"
+		if has "${EAPI:-0}" 0 1 2 3 && [[ -z "${PYTHON_ABIS}" ]]; then
+			die "${FUNCNAME}(): python_pkg_setup() or python_execute_function() not called"
 		fi
 		iterated_PYTHON_ABIS="${PYTHON_ABIS}"
 	else
-		iterated_PYTHON_ABIS="${PYTHON_ABI:-$(PYTHON --ABI)}"
+		if has "${EAPI:-0}" 0 1 2 3; then
+			iterated_PYTHON_ABIS="${PYTHON_ABI:-$(PYTHON --ABI)}"
+		else
+			iterated_PYTHON_ABIS="${PYTHON_ABI}"
+		fi
 	fi
 
 	# Strip trailing slash from EROOT.
@@ -2267,7 +2501,9 @@
 	if [[ "$#" -gt 0 ]]; then
 		if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
 			while (($#)); do
-				if ! _python_implementation && [[ "$1" =~ ^/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then
+				if [[ "$1" =~ ^($|(\.|\.\.|/)($|/)) ]]; then
+					die "${FUNCNAME}(): Invalid argument '$1'"
+				elif ! _python_implementation && [[ "$1" =~ ^/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then
 					die "${FUNCNAME}(): Paths of directories / files in site-packages directories must be relative to site-packages directories"
 				elif [[ "$1" =~ ^/ ]]; then
 					if _python_package_supporting_installation_for_multiple_python_abis; then
@@ -2325,119 +2561,22 @@
 # ===================================== DEPRECATED FUNCTIONS =====================================
 # ================================================================================================
 
-# @FUNCTION: python_version
-# @DESCRIPTION:
-# Run without arguments and it will export the version of python
-# currently in use as $PYVER; sets PYVER/PYVER_MAJOR/PYVER_MINOR
+# Scheduled for deletion on 2011-01-01.
 python_version() {
-	if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
-		eerror "Use PYTHON() and/or python_get_*() instead of ${FUNCNAME}()."
-		die "${FUNCNAME}() cannot be used in this EAPI"
-	fi
-
-	_python_set_color_variables
-
-	if [[ "${FUNCNAME[1]}" != "distutils_python_version" ]]; then
-		echo
-		echo " ${_RED}*${_NORMAL} ${_RED}Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01.${_NORMAL}"
-		echo " ${_RED}*${_NORMAL} ${_RED}Use PYTHON() instead of python variable. Use python_get_*() instead of PYVER* variables.${_NORMAL}"
-		echo " ${_RED}*${_NORMAL} ${_RED}The ebuild needs to be fixed. Please report a bug, if it has not been already reported.${_NORMAL}"
-		echo
-
-		einfo &> /dev/null
-		einfo "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01." &> /dev/null
-		einfo "Use PYTHON() instead of python variable. Use python_get_*() instead of PYVER* variables." &> /dev/null
-		einfo "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." &> /dev/null
-		einfo &> /dev/null
-	fi
+	eerror "Use PYTHON() instead of python variable. Use python_get_*() instead of PYVER* variables."
+	die "${FUNCNAME}() is banned"
+}
 
-	[[ -n "${PYVER}" ]] && return 0
-	local tmpstr
-	python="${python:-${EPREFIX}/usr/bin/python}"
-	tmpstr="$(EPYTHON= ${python} -V 2>&1 )"
-	export PYVER_ALL="${tmpstr#Python }"
-	export PYVER_MAJOR="${PYVER_ALL:0:1}"
-	export PYVER_MINOR="${PYVER_ALL:2:1}"
-	if [[ "${PYVER_ALL:3:1}" == "." ]]; then
-		export PYVER_MICRO="${PYVER_ALL:4}"
-	fi
-	export PYVER="${PYVER_MAJOR}.${PYVER_MINOR}"
-}
-
-# @FUNCTION: python_mod_exists
-# @USAGE: <module>
-# @DESCRIPTION:
-# Run with the module name as an argument. It will check if a
-# Python module is installed and loadable. It will return
-# TRUE(0) if the module exists, and FALSE(1) if the module does
-# not exist.
-#
-# Example:
-#         if python_mod_exists gtk; then
-#             echo "gtk support enabled"
-#         fi
+# Scheduled for deletion on 2011-01-01.
 python_mod_exists() {
-	if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
-		eerror "Use USE dependencies and/or has_version() instead of ${FUNCNAME}()."
-		die "${FUNCNAME}() cannot be used in this EAPI"
-	fi
-
-	_python_set_color_variables
-
-	echo
-	echo " ${_RED}*${_NORMAL} ${_RED}Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01.${_NORMAL}"
-	echo " ${_RED}*${_NORMAL} ${_RED}Use USE dependencies and/or has_version() instead of ${FUNCNAME}().${_NORMAL}"
-	echo " ${_RED}*${_NORMAL} ${_RED}The ebuild needs to be fixed. Please report a bug, if it has not been already reported.${_NORMAL}"
-	echo
-
-	eerror &> /dev/null
-	eerror "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01." &> /dev/null
-	eerror "Use USE dependencies and/or has_version() instead of ${FUNCNAME}()." &> /dev/null
-	eerror "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." &> /dev/null
-	eerror &> /dev/null
-
-	if [[ "$#" -ne 1 ]]; then
-		die "${FUNCNAME}() requires 1 argument"
-	fi
-	"$(PYTHON ${PYTHON_ABI})" -c "import $1" &> /dev/null
+	eerror "Use USE dependencies and/or has_version() instead of ${FUNCNAME}()."
+	die "${FUNCNAME}() is banned"
 }
 
-# @FUNCTION: python_tkinter_exists
-# @DESCRIPTION:
-# Run without arguments, checks if Python was compiled with Tkinter
-# support.  If not, prints an error message and dies.
+# Scheduled for deletion on 2011-01-01.
 python_tkinter_exists() {
-	if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
-		eerror "Use PYTHON_USE_WITH=\"xml\" and python_pkg_setup() instead of ${FUNCNAME}()."
-		die "${FUNCNAME}() cannot be used in this EAPI"
-	fi
-
-	_python_set_color_variables
-
-	if [[ "${FUNCNAME[1]}" != "distutils_python_tkinter" ]]; then
-		echo
-		echo " ${_RED}*${_NORMAL} ${_RED}Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01.${_NORMAL}"
-		echo " ${_RED}*${_NORMAL} ${_RED}Use PYTHON_USE_WITH=\"xml\" and python_pkg_setup() instead of ${FUNCNAME}().${_NORMAL}"
-		echo " ${_RED}*${_NORMAL} ${_RED}The ebuild needs to be fixed. Please report a bug, if it has not been already reported.${_NORMAL}"
-		echo
-
-		eerror &> /dev/null
-		eerror "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01." &> /dev/null
-		eerror "Use PYTHON_USE_WITH=\"xml\" and python_pkg_setup() instead of ${FUNCNAME}()." &> /dev/null
-		eerror "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." &> /dev/null
-		eerror &> /dev/null
-	fi
-
-	if ! "$(PYTHON ${PYTHON_ABI})" -c "from sys import version_info
-if version_info[0] == 3:
-	import tkinter
-else:
-	import Tkinter" &> /dev/null; then
-		eerror "Python needs to be rebuilt with tkinter support enabled."
-		eerror "Add the following line to '${EPREFIX}/etc/portage/package.use' and rebuild Python"
-		eerror "dev-lang/python tk"
-		die "Python installed without support for tkinter"
-	fi
+	eerror "Use PYTHON_USE_WITH=\"xml\" and python_pkg_setup() instead of ${FUNCNAME}()."
+	die "${FUNCNAME}() is banned"
 }
 
 # @FUNCTION: python_mod_compile






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2010-07-18 20:45 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2010-07-18 20:45 UTC (permalink / raw
  To: gentoo-commits

arfrever    10/07/18 20:45:51

  Modified:             python.eclass
  Log:
  Print path to ebuild in deprecation warning for NEED_PYTHON variable.
  Disable colors by default (bug #309057).

Revision  Changes    Path
1.102                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.102&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.102&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.101&r2=1.102

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.101
retrieving revision 1.102
diff -u -r1.101 -r1.102
--- python.eclass	17 Jul 2010 23:02:14 -0000	1.101
+++ python.eclass	18 Jul 2010 20:45:50 -0000	1.102
@@ -1,6 +1,6 @@
 # Copyright 1999-2010 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.101 2010/07/17 23:02:14 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.102 2010/07/18 20:45:50 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -165,19 +165,12 @@
 		die "NEED_PYTHON variable cannot be used in this EAPI"
 	fi
 
-	if [[ "${NOCOLOR:-false}" =~ ^(false|no)$ ]]; then
-		_RED=$'\e[1;31m'
-		_NORMAL=$'\e[0m'
-	else
-		_RED=
-		_NORMAL=
-	fi
-
-	echo
-	echo " ${_RED}*${_NORMAL} ${_RED}Deprecation Warning: NEED_PYTHON variable is deprecated and will be banned on 2010-10-01.${_NORMAL}"
-	echo " ${_RED}*${_NORMAL} ${_RED}Use PYTHON_DEPEND variable instead of NEED_PYTHON variable.${_NORMAL}"
-	echo " ${_RED}*${_NORMAL} ${_RED}The ebuild needs to be fixed. Please report a bug, if it has not been already reported.${_NORMAL}"
-	echo
+	ewarn
+	ewarn "\"${EBUILD}\":"
+	ewarn "Deprecation Warning: NEED_PYTHON variable is deprecated and will be banned on 2010-10-01."
+	ewarn "Use PYTHON_DEPEND variable instead of NEED_PYTHON variable."
+	ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported."
+	ewarn
 
 	unset _BOLD _NORMAL
 
@@ -317,8 +310,13 @@
 	PYTHON_SANITY_CHECKS_EXECUTED="1"
 }
 
+# @ECLASS-VARIABLE: PYTHON_COLORS
+# @DESCRIPTION:
+# User-configurable colored output.
+PYTHON_COLORS="${PYTHON_COLORS:-0}"
+
 _python_set_color_variables() {
-	if [[ "${NOCOLOR:-false}" =~ ^(false|no)$ ]]; then
+	if [[ "${PYTHON_COLORS}" != "0" && "${NOCOLOR:-false}" =~ ^(false|no)$ ]]; then
 		_BOLD=$'\e[1m'
 		_RED=$'\e[1;31m'
 		_GREEN=$'\e[1;32m'
@@ -968,7 +966,7 @@
 
 			if [[ "${nonfatal}" == "1" ]]; then
 				if [[ "${quiet}" == "0" ]]; then
-					ewarn "${_RED}${failure_message}${_NORMAL}"
+					ewarn "${failure_message}"
 				fi
 			elif [[ "${final_ABI}" == "0" ]] && has "${PYTHON_ABI}" ${FAILURE_TOLERANT_PYTHON_ABIS}; then
 				if [[ "${EBUILD_PHASE}" != "test" ]] || ! has test-fail-continue ${FEATURES}; then
@@ -979,7 +977,7 @@
 					export PYTHON_ABIS="${enabled_PYTHON_ABIS}"
 				fi
 				if [[ "${quiet}" == "0" ]]; then
-					ewarn "${_RED}${failure_message}${_NORMAL}"
+					ewarn "${failure_message}"
 				fi
 				if [[ -z "${PYTHON_ABIS}" ]]; then
 					die "${function}() function failed with all enabled Python ABIs"
@@ -2267,19 +2265,11 @@
 		done
 
 		if [[ "$#" -eq 0 ]]; then
-			_python_set_color_variables
-
-			echo
-			echo " ${_RED}*${_NORMAL} ${_RED}Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be${_NORMAL}"
-			echo " ${_RED}*${_NORMAL} ${_RED}disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules.${_NORMAL}"
-			echo " ${_RED}*${_NORMAL} ${_RED}The ebuild needs to be fixed. Please report a bug, if it has not been already reported.${_NORMAL}"
-			echo
-
-			einfo &> /dev/null
-			einfo "Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be" &> /dev/null
-			einfo "disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules." &> /dev/null
-			einfo "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." &> /dev/null
-			einfo &> /dev/null
+			ewarn
+			ewarn "Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be"
+			ewarn "disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules."
+			ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported."
+			ewarn
 		fi
 
 		while (($#)); do
@@ -2411,19 +2401,11 @@
 		done
 
 		if [[ "$#" -eq 0 ]]; then
-			_python_set_color_variables
-
-			echo
-			echo " ${_RED}*${_NORMAL} ${_RED}Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be${_NORMAL}"
-			echo " ${_RED}*${_NORMAL} ${_RED}disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules.${_NORMAL}"
-			echo " ${_RED}*${_NORMAL} ${_RED}The ebuild needs to be fixed. Please report a bug, if it has not been already reported.${_NORMAL}"
-			echo
-
-			einfo &> /dev/null
-			einfo "Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be" &> /dev/null
-			einfo "disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules." &> /dev/null
-			einfo "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." &> /dev/null
-			einfo &> /dev/null
+			ewarn
+			ewarn "Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be"
+			ewarn "disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules."
+			ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported."
+			ewarn
 		fi
 
 		while (($#)); do
@@ -2524,19 +2506,11 @@
 			search_paths=("${search_paths[@]/#/${root}/}")
 		fi
 	else
-		_python_set_color_variables
-
-		echo
-		echo " ${_RED}*${_NORMAL} ${_RED}Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be${_NORMAL}"
-		echo " ${_RED}*${_NORMAL} ${_RED}disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules.${_NORMAL}"
-		echo " ${_RED}*${_NORMAL} ${_RED}The ebuild needs to be fixed. Please report a bug, if it has not been already reported.${_NORMAL}"
-		echo
-
-		einfo &> /dev/null
-		einfo "Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be" &> /dev/null
-		einfo "disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules." &> /dev/null
-		einfo "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." &> /dev/null
-		einfo &> /dev/null
+		ewarn
+		ewarn "Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be"
+		ewarn "disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules."
+		ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported."
+		ewarn
 
 		for dir in "${root}"/usr/lib*; do
 			if [[ -d "${dir}" && ! -L "${dir}" ]]; then
@@ -2598,17 +2572,11 @@
 	_python_set_color_variables
 
 	if [[ "${FUNCNAME[1]}" != "python_mod_optimize" ]]; then
-		echo
-		echo " ${_RED}*${_NORMAL} ${_RED}Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-09-01.${_NORMAL}"
-		echo " ${_RED}*${_NORMAL} ${_RED}Use python_mod_optimize() instead of ${FUNCNAME}().${_NORMAL}"
-		echo " ${_RED}*${_NORMAL} ${_RED}The ebuild needs to be fixed. Please report a bug, if it has not been already reported.${_NORMAL}"
-		echo
-
-		einfo &> /dev/null
-		einfo "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-09-01." &> /dev/null
-		einfo "Use python_mod_optimize() instead of ${FUNCNAME}()." &> /dev/null
-		einfo "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." &> /dev/null
-		einfo &> /dev/null
+		ewarn
+		ewarn "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-09-01."
+		ewarn "Use python_mod_optimize() instead of ${FUNCNAME}()."
+		ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported."
+		ewarn
 	fi
 
 	local f myroot myfiles=()






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2010-10-03  0:38 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2010-10-03  0:38 UTC (permalink / raw
  To: gentoo-commits

arfrever    10/10/03 00:38:13

  Modified:             python.eclass
  Log:
  Fix preservation of whitespace in python_execute_function(), python_execute_nosetests(), python_execute_py.test() and python_execute_trial().
  Support --allow-evaluated-non-sitedir-paths option in python_mod_optimize() and python_mod_cleanup().

Revision  Changes    Path
1.103                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.103&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.103&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.102&r2=1.103

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.102
retrieving revision 1.103
diff -u -r1.102 -r1.103
--- python.eclass	18 Jul 2010 20:45:50 -0000	1.102
+++ python.eclass	3 Oct 2010 00:38:13 -0000	1.103
@@ -1,6 +1,6 @@
 # Copyright 1999-2010 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.102 2010/07/18 20:45:50 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.103 2010/10/03 00:38:13 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -925,7 +925,7 @@
 
 		if [[ "${quiet}" == "0" ]]; then
 			if [[ -n "${action_message_template}" ]]; then
-				action_message="$(eval echo -n "${action_message_template}")"
+				eval "action_message=\"${action_message_template}\""
 			else
 				action_message="${action} of ${CATEGORY}/${PF} with $(python_get_implementation) $(python_get_version)..."
 			fi
@@ -959,7 +959,7 @@
 
 		if [[ "${return_code}" -ne 0 ]]; then
 			if [[ -n "${failure_message_template}" ]]; then
-				failure_message="$(eval echo -n "${failure_message_template}")"
+				eval "failure_message=\"${failure_message_template}\""
 			else
 				failure_message="${action} failed with $(python_get_implementation) $(python_get_version) in ${function}() function"
 			fi
@@ -1925,7 +1925,7 @@
 	python_test_function() {
 		local evaluated_PYTHONPATH
 
-		evaluated_PYTHONPATH="$(eval echo -n "${PYTHONPATH_template}")"
+		eval "evaluated_PYTHONPATH=\"${PYTHONPATH_template}\""
 
 		_python_test_hook pre
 
@@ -1989,7 +1989,7 @@
 	python_test_function() {
 		local evaluated_PYTHONPATH
 
-		evaluated_PYTHONPATH="$(eval echo -n "${PYTHONPATH_template}")"
+		eval "evaluated_PYTHONPATH=\"${PYTHONPATH_template}\""
 
 		_python_test_hook pre
 
@@ -2053,7 +2053,7 @@
 	python_test_function() {
 		local evaluated_PYTHONPATH
 
-		evaluated_PYTHONPATH="$(eval echo -n "${PYTHONPATH_template}")"
+		eval "evaluated_PYTHONPATH=\"${PYTHONPATH_template}\""
 
 		_python_test_hook pre
 
@@ -2223,7 +2223,7 @@
 
 	if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
 		# PYTHON_ABI variable cannot be local in packages not supporting installation for multiple Python ABIs.
-		local dir file iterated_PYTHON_ABIS options=() other_dirs=() other_files=() previous_PYTHON_ABI="${PYTHON_ABI}" return_code root site_packages_absolute_dirs=() site_packages_dirs=() site_packages_absolute_files=() site_packages_files=()
+		local allow_evaluated_non_sitedir_paths="0" dir dirs=() evaluated_dirs=() evaluated_files=() file files=() iterated_PYTHON_ABIS options=() other_dirs=() other_files=() previous_PYTHON_ABI="${PYTHON_ABI}" return_code root site_packages_dirs=() site_packages_files=()
 
 		if _python_package_supporting_installation_for_multiple_python_abis; then
 			if has "${EAPI:-0}" 0 1 2 3 && [[ -z "${PYTHON_ABIS}" ]]; then
@@ -2243,6 +2243,9 @@
 
 		while (($#)); do
 			case "$1" in
+				--allow-evaluated-non-sitedir-paths)
+					allow_evaluated_non_sitedir_paths="1"
+					;;
 				-l|-f|-q)
 					options+=("$1")
 					;;
@@ -2264,6 +2267,10 @@
 			shift
 		done
 
+		if [[ "${allow_evaluated_non_sitedir_paths}" == "1" ]] && ! _python_package_supporting_installation_for_multiple_python_abis; then
+			die "${FUNCNAME}(): '--allow-evaluated-non-sitedir-paths' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
+		fi
+
 		if [[ "$#" -eq 0 ]]; then
 			ewarn
 			ewarn "Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be"
@@ -2279,16 +2286,27 @@
 				die "${FUNCNAME}(): Paths of directories / files in site-packages directories must be relative to site-packages directories"
 			elif [[ "$1" =~ ^/ ]]; then
 				if _python_package_supporting_installation_for_multiple_python_abis; then
-					die "${FUNCNAME}(): Absolute paths cannot be used in ebuilds of packages supporting installation for multiple Python ABIs"
-				fi
-				if [[ -d "${root}$1" ]]; then
-					other_dirs+=("${root}$1")
-				elif [[ -f "${root}$1" ]]; then
-					other_files+=("${root}$1")
-				elif [[ -e "${root}$1" ]]; then
-					eerror "${FUNCNAME}(): '${root}$1' is not a regular file or a directory"
+					if [[ "${allow_evaluated_non_sitedir_paths}" != "1" ]]; then
+						die "${FUNCNAME}(): Absolute paths cannot be used in ebuilds of packages supporting installation for multiple Python ABIs"
+					fi
+					if [[ "$1" != *\$* ]]; then
+						die "${FUNCNAME}(): '$1' has invalid syntax"
+					fi
+					if [[ "$1" == *.py ]]; then
+						evaluated_files+=("$1")
+					else
+						evaluated_dirs+=("$1")
+					fi
 				else
-					eerror "${FUNCNAME}(): '${root}$1' does not exist"
+					if [[ -d "${root}$1" ]]; then
+						other_dirs+=("${root}$1")
+					elif [[ -f "${root}$1" ]]; then
+						other_files+=("${root}$1")
+					elif [[ -e "${root}$1" ]]; then
+						eerror "${FUNCNAME}(): '${root}$1' is not a regular file or a directory"
+					else
+						eerror "${FUNCNAME}(): '${root}$1' does not exist"
+					fi
 				fi
 			else
 				for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
@@ -2312,32 +2330,38 @@
 		options+=("-q")
 
 		for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
-			if ((${#site_packages_dirs[@]})) || ((${#site_packages_files[@]})); then
+			if ((${#site_packages_dirs[@]})) || ((${#site_packages_files[@]})) || ((${#evaluated_dirs[@]})) || ((${#evaluated_files[@]})); then
 				return_code="0"
 				ebegin "Compilation and optimization of Python modules for $(python_get_implementation) $(python_get_version)"
-				if ((${#site_packages_dirs[@]})); then
+				if ((${#site_packages_dirs[@]})) || ((${#evaluated_dirs[@]})); then
 					for dir in "${site_packages_dirs[@]}"; do
-						site_packages_absolute_dirs+=("${root}$(python_get_sitedir)/${dir}")
+						dirs+=("${root}$(python_get_sitedir)/${dir}")
+					done
+					for dir in "${evaluated_dirs[@]}"; do
+						eval "dirs+=(\"\${root}${dir}\")"
 					done
-					"$(PYTHON)" "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${site_packages_absolute_dirs[@]}" || return_code="1"
+					"$(PYTHON)" "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${dirs[@]}" || return_code="1"
 					if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
-						"$(PYTHON)" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${site_packages_absolute_dirs[@]}" &> /dev/null || return_code="1"
+						"$(PYTHON)" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${dirs[@]}" &> /dev/null || return_code="1"
 					fi
-					_python_clean_compiled_modules "${site_packages_absolute_dirs[@]}"
+					_python_clean_compiled_modules "${dirs[@]}"
 				fi
-				if ((${#site_packages_files[@]})); then
+				if ((${#site_packages_files[@]})) || ((${#evaluated_files[@]})); then
 					for file in "${site_packages_files[@]}"; do
-						site_packages_absolute_files+=("${root}$(python_get_sitedir)/${file}")
+						files+=("${root}$(python_get_sitedir)/${file}")
 					done
-					"$(PYTHON)" "${root}$(python_get_libdir)/py_compile.py" "${site_packages_absolute_files[@]}" || return_code="1"
+					for file in "${evaluated_files[@]}"; do
+						eval "files+=(\"\${root}${file}\")"
+					done
+					"$(PYTHON)" "${root}$(python_get_libdir)/py_compile.py" "${files[@]}" || return_code="1"
 					if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
-						"$(PYTHON)" -O "${root}$(python_get_libdir)/py_compile.py" "${site_packages_absolute_files[@]}" &> /dev/null || return_code="1"
+						"$(PYTHON)" -O "${root}$(python_get_libdir)/py_compile.py" "${files[@]}" &> /dev/null || return_code="1"
 					fi
-					_python_clean_compiled_modules "${site_packages_absolute_files[@]}"
+					_python_clean_compiled_modules "${files[@]}"
 				fi
 				eend "${return_code}"
 			fi
-			unset site_packages_absolute_dirs site_packages_absolute_files
+			unset dirs files
 		done
 
 		if _python_package_supporting_installation_for_multiple_python_abis; then
@@ -2459,7 +2483,7 @@
 	_python_check_python_pkg_setup_execution
 	_python_initialize_prefix_variables
 
-	local dir iterated_PYTHON_ABIS PYTHON_ABI="${PYTHON_ABI}" root search_paths=() sitedir
+	local allow_evaluated_non_sitedir_paths="0" dir iterated_PYTHON_ABIS PYTHON_ABI="${PYTHON_ABI}" root search_paths=() sitedir
 
 	# Check if phase is pkg_postrm().
 	[[ "${EBUILD_PHASE}" != "postrm" ]] && die "${FUNCNAME}() can be used only in pkg_postrm() phase"
@@ -2480,6 +2504,29 @@
 	# Strip trailing slash from EROOT.
 	root="${EROOT%/}"
 
+	while (($#)); do
+		case "$1" in
+			--allow-evaluated-non-sitedir-paths)
+				allow_evaluated_non_sitedir_paths="1"
+				;;
+			--)
+				shift
+				break
+				;;
+			-*)
+				die "${FUNCNAME}(): Unrecognized option '$1'"
+				;;
+			*)
+				break
+				;;
+		esac
+		shift
+	done
+
+	if [[ "${allow_evaluated_non_sitedir_paths}" == "1" ]] && ! _python_package_supporting_installation_for_multiple_python_abis; then
+		die "${FUNCNAME}(): '--allow-evaluated-non-sitedir-paths' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
+	fi
+
 	if [[ "$#" -gt 0 ]]; then
 		if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
 			while (($#)); do
@@ -2489,9 +2536,18 @@
 					die "${FUNCNAME}(): Paths of directories / files in site-packages directories must be relative to site-packages directories"
 				elif [[ "$1" =~ ^/ ]]; then
 					if _python_package_supporting_installation_for_multiple_python_abis; then
-						die "${FUNCNAME}(): Absolute paths cannot be used in ebuilds of packages supporting installation for multiple Python ABIs"
+						if [[ "${allow_evaluated_non_sitedir_paths}" != "1" ]]; then
+							die "${FUNCNAME}(): Absolute paths cannot be used in ebuilds of packages supporting installation for multiple Python ABIs"
+						fi
+						if [[ "$1" != *\$* ]]; then
+							die "${FUNCNAME}(): '$1' has invalid syntax"
+						fi
+						for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
+							eval "search_paths+=(\"\${root}$1\")"
+						done
+					else
+						search_paths+=("${root}$1")
 					fi
-					search_paths+=("${root}$1")
 				else
 					for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
 						search_paths+=("${root}$(python_get_sitedir)/$1")






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2010-10-25 11:54 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2010-10-25 11:54 UTC (permalink / raw
  To: gentoo-commits

arfrever    10/10/25 11:54:19

  Modified:             python.eclass
  Log:
  Set IUSE in EAPI >=4.
  Rename _parse_PYTHON_DEPEND() to _python_parse_PYTHON_DEPEND() and unset it after its using.
  Ban NEED_PYTHON variable.
  Add python_abi_depend().
  Fix exporting of python_pkg_setup() in EAPI >=4.
  Update and improve _python_calculate_PYTHON_ABIS().
  Support EAPI="0" in python_get_implementational_package().
  Use non-deprecated parts of python_mod_optimize() and python_mod_cleanup() for dev-lang/python and sys-apps/portage.
  Disallow not passing of paths to Python modules to python_mod_optimize() and python_mod_cleanup().
  Fix a typo in python_mod_optimize().
  Ban python_mod_compile().

Revision  Changes    Path
1.104                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.104&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.104&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.103&r2=1.104

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.103
retrieving revision 1.104
diff -u -r1.103 -r1.104
--- python.eclass	3 Oct 2010 00:38:13 -0000	1.103
+++ python.eclass	25 Oct 2010 11:54:19 -0000	1.104
@@ -1,6 +1,6 @@
 # Copyright 1999-2010 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.103 2010/10/03 00:38:13 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.104 2010/10/25 11:54:19 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -18,6 +18,36 @@
 _CPYTHON2_SUPPORTED_ABIS=(2.4 2.5 2.6 2.7)
 _CPYTHON3_SUPPORTED_ABIS=(3.0 3.1 3.2)
 _JYTHON_SUPPORTED_ABIS=(2.5-jython)
+_PYTHON_SUPPORTED_ABIS=(${_CPYTHON2_SUPPORTED_ABIS[@]} ${_CPYTHON3_SUPPORTED_ABIS[@]} ${_JYTHON_SUPPORTED_ABIS[@]})
+
+# ================================================================================================
+# ===================================== HANDLING OF METADATA =====================================
+# ================================================================================================
+
+_python_set_IUSE() {
+	local PYTHON_ABI restricted_ABI restricted_ABIs support_ABI
+
+	_PYTHON_ABIS_USE_FLAGS=""
+	restricted_ABIs="${RESTRICT_PYTHON_ABIS// /$'\n'}"
+
+	for PYTHON_ABI in "${_PYTHON_SUPPORTED_ABIS[@]}"; do
+		support_ABI="1"
+		while read restricted_ABI; do
+			if [[ "${PYTHON_ABI}" == ${restricted_ABI} ]]; then
+				support_ABI="0"
+				break
+			fi
+		done <<< "${restricted_ABIs}"
+		[[ "${support_ABI}" == "1" ]] && _PYTHON_ABIS_USE_FLAGS+="${_PYTHON_ABIS_USE_FLAGS:+ }python_abis_${PYTHON_ABI}"
+	done
+
+	IUSE="${_PYTHON_ABIS_USE_FLAGS}"
+}
+
+if ! has "${EAPI:-0}" 0 1 2 3 && [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
+	_python_set_IUSE
+fi
+unset -f _python_set_IUSE
 
 # @ECLASS-VARIABLE: PYTHON_DEPEND
 # @DESCRIPTION:
@@ -29,7 +59,7 @@
 #   minimal_version:           <minimal_major_version.minimal_minor_version>
 #   maximal_version:           <maximal_major_version.maximal_minor_version>
 
-_parse_PYTHON_DEPEND() {
+_python_parse_PYTHON_DEPEND() {
 	local major_version maximal_version minimal_version python_all="0" python_maximal_version python_minimal_version python_versions=() python2="0" python2_maximal_version python2_minimal_version python3="0" python3_maximal_version python3_minimal_version USE_flag= version_components_group version_components_group_regex version_components_groups
 
 	version_components_group_regex="(2|3|\*)(:([[:digit:]]+\.[[:digit:]]+)?(:([[:digit:]]+\.[[:digit:]]+)?)?)?"
@@ -155,31 +185,17 @@
 DEPEND=">=app-admin/eselect-python-20091230"
 RDEPEND="${DEPEND}"
 
-if [[ -n "${PYTHON_DEPEND}" && -n "${NEED_PYTHON}" ]]; then
-	die "PYTHON_DEPEND and NEED_PYTHON cannot be set simultaneously"
-elif [[ -n "${PYTHON_DEPEND}" ]]; then
-	_parse_PYTHON_DEPEND
-elif [[ -n "${NEED_PYTHON}" ]]; then
-	if ! has "${EAPI:-0}" 0 1 2; then
-		eerror "Use PYTHON_DEPEND variable instead of NEED_PYTHON variable."
-		die "NEED_PYTHON variable cannot be used in this EAPI"
-	fi
-
-	ewarn
-	ewarn "\"${EBUILD}\":"
-	ewarn "Deprecation Warning: NEED_PYTHON variable is deprecated and will be banned on 2010-10-01."
-	ewarn "Use PYTHON_DEPEND variable instead of NEED_PYTHON variable."
-	ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported."
-	ewarn
-
-	unset _BOLD _NORMAL
-
-	_PYTHON_ATOMS=(">=dev-lang/python-${NEED_PYTHON}")
-	DEPEND+="${DEPEND:+ }${_PYTHON_ATOMS[@]}"
-	RDEPEND+="${RDEPEND:+ }${_PYTHON_ATOMS[@]}"
+if [[ -n "${PYTHON_DEPEND}" ]]; then
+	_python_parse_PYTHON_DEPEND
 else
 	_PYTHON_ATOMS=("dev-lang/python")
 fi
+unset -f _python_parse_PYTHON_DEPEND
+
+if [[ -n "${NEED_PYTHON}" ]]; then
+	eerror "Use PYTHON_DEPEND variable instead of NEED_PYTHON variable."
+	die "NEED_PYTHON variable is banned"
+fi
 
 # @ECLASS-VARIABLE: PYTHON_USE_WITH
 # @DESCRIPTION:
@@ -223,6 +239,135 @@
 
 unset _PYTHON_ATOMS
 
+# @FUNCTION: python_abi_depend
+# @USAGE: [-e|--exclude-ABIs Python_ABIs] [-i|--include-ABIs Python_ABIs] [--] <dependency_atom> [dependency_atoms]
+# @DESCRIPTION:
+# Print dependency atoms with USE dependencies for Python ABIs added.
+# If --exclude-ABIs option is specified, then Python ABIs matching its argument are not used.
+# If --include-ABIs option is specified, then only Python ABIs matching its argument are used.
+# --exclude-ABIs and --include-ABIs options cannot be specified simultaneously.
+python_abi_depend() {
+	local atom atom_index atoms=() exclude_ABIs="0" excluded_ABI excluded_ABIs include_ABIs="0" included_ABI included_ABIs support_ABI USE_dependencies USE_flag USE_flag_index USE_flags=()
+
+	if has "${EAPI:-0}" 0 1 2 3; then
+		die "${FUNCNAME}() cannot be used in this EAPI"
+	fi
+
+	if [[ -z "${SUPPORT_PYTHON_ABIS}" ]]; then
+		die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
+	fi
+
+	while (($#)); do
+		case "$1" in
+			-e|--exclude-ABIs)
+				exclude_ABIs="1"
+				excluded_ABIs="${2// /$'\n'}"
+				shift
+				;;
+			-i|--include-ABIs)
+				include_ABIs="1"
+				included_ABIs="${2// /$'\n'}"
+				shift
+				;;
+			--)
+				shift
+				break
+				;;
+			-*)
+				die "${FUNCNAME}(): Unrecognized option '$1'"
+				;;
+			*)
+				break
+				;;
+		esac
+		shift
+	done
+
+	if [[ "${exclude_ABIs}" == "1" && "${include_ABIs}" == "1" ]]; then
+		die "${FUNCNAME}(): '--exclude-ABIs' and '--include-ABIs' options cannot be specified simultaneously"
+	fi
+
+	if [[ "$#" -eq 0 ]]; then
+		die "${FUNCNAME}(): Missing dependency atoms"
+	fi
+
+	atoms=("$@")
+
+	if [[ "${exclude_ABIs}" == "0" && "${include_ABIs}" == "0" ]]; then
+		USE_dependencies="$(printf ",%s?" ${_PYTHON_ABIS_USE_FLAGS})"
+		USE_dependencies="${USE_dependencies#,}"
+
+		for atom_index in "${!atoms[@]}"; do
+			atom="${atoms[${atom_index}]}"
+
+			if [[ "${atom}" == *"["*"]" ]]; then
+				echo -n "${atom%]},"
+			else
+				echo -n "${atom}["
+			fi
+			echo -n "${USE_dependencies}]"
+
+			if [[ "${atom_index}" -ne $((${#atoms[@]} - 1)) ]]; then
+				echo -n " "
+			fi
+		done
+	else
+		if [[ "${exclude_ABIs}" == "1" ]]; then
+			for USE_flag in ${_PYTHON_ABIS_USE_FLAGS}; do
+				while read excluded_ABI; do
+				support_ABI="1"
+					if [[ "${USE_flag}" == python_abis_${excluded_ABI} ]]; then
+						support_ABI="0"
+						break
+					fi
+				done <<< "${excluded_ABIs}"
+			[[ "${support_ABI}" == "1" ]] && USE_flags+=("${USE_flag}")
+			done
+		elif [[ "${include_ABIs}" == "1" ]]; then
+			for USE_flag in ${_PYTHON_ABIS_USE_FLAGS}; do
+				while read included_ABI; do
+				support_ABI="0"
+					if [[ "${USE_flag}" == python_abis_${included_ABI} ]]; then
+						support_ABI="1"
+						break
+					fi
+				done <<< "${included_ABIs}"
+			[[ "${support_ABI}" == "1" ]] && USE_flags+=("${USE_flag}")
+			done
+		else
+			die "${FUNCNAME}(): Internal error"
+		fi
+
+		for USE_flag_index in "${!USE_flags[@]}"; do
+			USE_flag="${USE_flags[${USE_flag_index}]}"
+			USE_dependencies="${USE_flag}"
+
+			echo -n "${USE_flag}? ( "
+
+			for atom_index in "${!atoms[@]}"; do
+				atom="${atoms[${atom_index}]}"
+
+				if [[ "${atom}" == *"["*"]" ]]; then
+					echo -n "${atom%]},"
+				else
+					echo -n "${atom}["
+				fi
+				echo -n "${USE_dependencies}]"
+
+				if [[ "${atom_index}" -ne $((${#atoms[@]} - 1)) ]]; then
+					echo -n " "
+				fi
+			done
+
+			echo -n " )"
+
+			if [[ "${USE_flag_index}" -ne $((${#USE_flags[@]} - 1)) ]]; then
+				echo -n " "
+			fi
+		done
+	fi
+}
+
 # ================================================================================================
 # =================================== MISCELLANEOUS FUNCTIONS ====================================
 # ================================================================================================
@@ -410,7 +555,7 @@
 	PYTHON_PKG_SETUP_EXECUTED="1"
 }
 
-if ! has "${EAPI:-0}" 0 1 2 3 || has "${EAPI:-0}" 2 3 && [[ -n "${PYTHON_USE_WITH}" || -n "${PYTHON_USE_WITH_OR}" ]]; then
+if ! has "${EAPI:-0}" 0 1 2 3 || { has "${EAPI:-0}" 2 3 && [[ -n "${PYTHON_USE_WITH}" || -n "${PYTHON_USE_WITH_OR}" ]]; }; then
 	EXPORT_FUNCTIONS pkg_setup
 fi
 
@@ -603,7 +748,9 @@
 	fi
 fi
 
-unset PYTHON_ABIS
+if has "${EAPI:-0}" 0 1 2 3; then
+	unset PYTHON_ABIS
+fi
 
 _python_calculate_PYTHON_ABIS() {
 	if ! _python_package_supporting_installation_for_multiple_python_abis; then
@@ -612,10 +759,10 @@
 
 	_python_initial_sanity_checks
 
-	# USE_${ABI_TYPE^^} and RESTRICT_${ABI_TYPE^^}_ABIS variables hopefully will be included in EAPI >= 5.
-	if [[ "$(declare -p PYTHON_ABIS 2> /dev/null)" != "declare -x PYTHON_ABIS="* ]] && has "${EAPI:-0}" 0 1 2 3 4; then
-		local PYTHON_ABI restricted_ABI support_ABI supported_PYTHON_ABIS=
-		PYTHON_ABI_SUPPORTED_VALUES="${_CPYTHON2_SUPPORTED_ABIS[@]} ${_CPYTHON3_SUPPORTED_ABIS[@]} ${_JYTHON_SUPPORTED_ABIS[@]}"
+	if [[ "$(declare -p PYTHON_ABIS 2> /dev/null)" != "declare -x PYTHON_ABIS="* ]] && has "${EAPI:-0}" 0 1 2 3; then
+		local PYTHON_ABI restricted_ABI restricted_ABIs support_ABI supported_PYTHON_ABIS
+
+		restricted_ABIs="${RESTRICT_PYTHON_ABIS// /$'\n'}"
 
 		if [[ "$(declare -p USE_PYTHON 2> /dev/null)" == "declare -x USE_PYTHON="* ]]; then
 			local cpython_enabled="0"
@@ -625,7 +772,7 @@
 			fi
 
 			for PYTHON_ABI in ${USE_PYTHON}; do
-				if ! has "${PYTHON_ABI}" ${PYTHON_ABI_SUPPORTED_VALUES}; then
+				if ! has "${PYTHON_ABI}" ${_PYTHON_SUPPORTED_ABIS[@]}; then
 					die "USE_PYTHON variable contains invalid value '${PYTHON_ABI}'"
 				fi
 
@@ -634,12 +781,12 @@
 				fi
 
 				support_ABI="1"
-				for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
+				while read restricted_ABI; do
 					if [[ "${PYTHON_ABI}" == ${restricted_ABI} ]]; then
 						support_ABI="0"
 						break
 					fi
-				done
+				done <<< "${restricted_ABIs}"
 				[[ "${support_ABI}" == "1" ]] && export PYTHON_ABIS+="${PYTHON_ABIS:+ }${PYTHON_ABI}"
 			done
 
@@ -668,19 +815,19 @@
 
 				for PYTHON_ABI in "${_CPYTHON2_SUPPORTED_ABIS[@]}"; do
 					support_python_major_version="1"
-					for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
+					while read restricted_ABI; do
 						if [[ "${PYTHON_ABI}" == ${restricted_ABI} ]]; then
 							support_python_major_version="0"
 						fi
-					done
+					done <<< "${restricted_ABIs}"
 					[[ "${support_python_major_version}" == "1" ]] && break
 				done
 				if [[ "${support_python_major_version}" == "1" ]]; then
-					for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
+					while read restricted_ABI; do
 						if [[ "${python2_version}" == ${restricted_ABI} ]]; then
 							die "Active version of Python 2 is not supported by ${CATEGORY}/${PF}"
 						fi
-					done
+					done <<< "${restricted_ABIs}"
 				else
 					python2_version=""
 				fi
@@ -695,19 +842,19 @@
 
 				for PYTHON_ABI in "${_CPYTHON3_SUPPORTED_ABIS[@]}"; do
 					support_python_major_version="1"
-					for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
+					while read restricted_ABI; do
 						if [[ "${PYTHON_ABI}" == ${restricted_ABI} ]]; then
 							support_python_major_version="0"
 						fi
-					done
+					done <<< "${restricted_ABIs}"
 					[[ "${support_python_major_version}" == "1" ]] && break
 				done
 				if [[ "${support_python_major_version}" == "1" ]]; then
-					for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
+					while read restricted_ABI; do
 						if [[ "${python3_version}" == ${restricted_ABI} ]]; then
 							die "Active version of Python 3 is not supported by ${CATEGORY}/${PF}"
 						fi
-					done
+					done <<< "${restricted_ABIs}"
 				else
 					python3_version=""
 				fi
@@ -1564,10 +1711,18 @@
 		fi
 	fi
 
-	if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
-		echo "dev-lang/python:${PYTHON_ABI}"
-	elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
-		echo "dev-java/jython:${PYTHON_ABI%-jython}"
+	if [[ "${EAPI:-0}" == "0" ]]; then
+		if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
+			echo "=dev-lang/python-${PYTHON_ABI}*"
+		elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
+			echo "=dev-java/jython-${PYTHON_ABI%-jython}*"
+		fi
+	else
+		if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
+			echo "dev-lang/python:${PYTHON_ABI}"
+		elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
+			echo "dev-java/jython:${PYTHON_ABI%-jython}"
+		fi
 	fi
 }
 
@@ -2116,7 +2271,7 @@
 	_python_initialize_prefix_variables
 	_python_set_color_variables
 
-	[[ "${FUNCNAME[1]}" =~ ^(python_mod_optimize|python_mod_compile|python_mod_cleanup)$ ]] || die "${FUNCNAME}(): Invalid usage"
+	[[ "${FUNCNAME[1]}" =~ ^(python_mod_optimize|python_mod_cleanup)$ ]] || die "${FUNCNAME}(): Invalid usage"
 
 	local base_module_name compiled_file compiled_files=() dir path py_file root
 
@@ -2203,15 +2358,10 @@
 }
 
 # @FUNCTION: python_mod_optimize
-# @USAGE: [options] [directory|file]
+# @USAGE: [--allow-evaluated-non-sitedir-paths] [-d directory] [-f] [-l] [-q] [-x regular_expression] [--] <file|directory> [files|directories]
 # @DESCRIPTION:
-# If no arguments supplied, it will recompile not recursively all modules
-# under sys.path (eg. /usr/lib/python2.6, /usr/lib/python2.6/site-packages).
-#
-# If supplied with arguments, it will recompile all modules recursively
-# in the supplied directory.
-#
-# Options passed to this function are passed to compileall.py.
+# Byte-compile specified Python modules.
+# -d, -f, -l, -q and -x options passed to this function are passed to compileall.py.
 #
 # This function can be used only in pkg_postinst() phase.
 python_mod_optimize() {
@@ -2221,7 +2371,7 @@
 	# Check if phase is pkg_postinst().
 	[[ "${EBUILD_PHASE}" != "postinst" ]] && die "${FUNCNAME}() can be used only in pkg_postinst() phase"
 
-	if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
+	if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis || _python_implementation || [[ "${CATEGORY}/${PN}" == "sys-apps/portage" ]]; then
 		# PYTHON_ABI variable cannot be local in packages not supporting installation for multiple Python ABIs.
 		local allow_evaluated_non_sitedir_paths="0" dir dirs=() evaluated_dirs=() evaluated_files=() file files=() iterated_PYTHON_ABIS options=() other_dirs=() other_files=() previous_PYTHON_ABI="${PYTHON_ABI}" return_code root site_packages_dirs=() site_packages_files=()
 
@@ -2272,11 +2422,7 @@
 		fi
 
 		if [[ "$#" -eq 0 ]]; then
-			ewarn
-			ewarn "Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be"
-			ewarn "disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules."
-			ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported."
-			ewarn
+			die "${FUNCNAME}(): Missing files or directories"
 		fi
 
 		while (($#)); do
@@ -2388,12 +2534,18 @@
 				if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
 					"$(PYTHON ${PYTHON_ABI})" -O "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" &> /dev/null || return_code="1"
 				fi
-				_python_clean_compiled_modules "${other_dirs[@]}"
+				_python_clean_compiled_modules "${other_files[@]}"
 			fi
 			eend "${return_code}"
 		fi
 	else
 		# Deprecated part of python_mod_optimize()
+		# ewarn
+		# ewarn "Deprecation Warning: Usage of ${FUNCNAME}() in packages not supporting installation"
+		# ewarn "for multiple Python ABIs in EAPI <=2 is deprecated and will be disallowed on 2011-06-01."
+		# ewarn "Use EAPI >=3 and call ${FUNCNAME}() with paths having appropriate syntax."
+		# ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported."
+		# ewarn
 
 		local myroot mydirs=() myfiles=() myopts=() return_code="0"
 
@@ -2425,11 +2577,7 @@
 		done
 
 		if [[ "$#" -eq 0 ]]; then
-			ewarn
-			ewarn "Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be"
-			ewarn "disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules."
-			ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported."
-			ewarn
+			die "${FUNCNAME}(): Missing files or directories"
 		fi
 
 		while (($#)); do
@@ -2438,8 +2586,7 @@
 			elif [[ -d "${myroot}/${1#/}" ]]; then
 				mydirs+=("${myroot}/${1#/}")
 			elif [[ -f "${myroot}/${1#/}" ]]; then
-				# Files are passed to python_mod_compile which is EROOT-aware
-				myfiles+=("$1")
+				myfiles+=("${myroot}/${1#/}")
 			elif [[ -e "${myroot}/${1#/}" ]]; then
 				eerror "${FUNCNAME}(): ${myroot}/${1#/} is not a regular file or directory"
 			else
@@ -2461,7 +2608,9 @@
 		fi
 
 		if ((${#myfiles[@]})); then
-			python_mod_compile "${myfiles[@]}"
+			"$(PYTHON ${PYTHON_ABI})" "${myroot}$(python_get_libdir)/py_compile.py" "${myfiles[@]}" || return_code="1"
+			"$(PYTHON ${PYTHON_ABI})" -O "${myroot}$(python_get_libdir)/py_compile.py" "${myfiles[@]}" &> /dev/null || return_code="1"
+			_python_clean_compiled_modules "${myfiles[@]}"
 		fi
 
 		eend "${return_code}"
@@ -2469,14 +2618,9 @@
 }
 
 # @FUNCTION: python_mod_cleanup
-# @USAGE: [directory|file]
+# @USAGE: [--allow-evaluated-non-sitedir-paths] [--] <file|directory> [files|directories]
 # @DESCRIPTION:
-# Run with optional arguments, where arguments are Python modules. If none given,
-# it will look in /usr/lib/python[0-9].[0-9].
-#
-# It will recursively scan all compiled Python modules in the directories and
-# determine if they are orphaned (i.e. their corresponding .py files are missing.)
-# If they are, then it will remove their corresponding .pyc and .pyo files.
+# Delete orphaned byte-compiled Python modules corresponding to specified Python modules.
 #
 # This function can be used only in pkg_postrm() phase.
 python_mod_cleanup() {
@@ -2527,61 +2671,48 @@
 		die "${FUNCNAME}(): '--allow-evaluated-non-sitedir-paths' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
 	fi
 
-	if [[ "$#" -gt 0 ]]; then
-		if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
-			while (($#)); do
-				if [[ "$1" =~ ^($|(\.|\.\.|/)($|/)) ]]; then
-					die "${FUNCNAME}(): Invalid argument '$1'"
-				elif ! _python_implementation && [[ "$1" =~ ^/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then
-					die "${FUNCNAME}(): Paths of directories / files in site-packages directories must be relative to site-packages directories"
-				elif [[ "$1" =~ ^/ ]]; then
-					if _python_package_supporting_installation_for_multiple_python_abis; then
-						if [[ "${allow_evaluated_non_sitedir_paths}" != "1" ]]; then
-							die "${FUNCNAME}(): Absolute paths cannot be used in ebuilds of packages supporting installation for multiple Python ABIs"
-						fi
-						if [[ "$1" != *\$* ]]; then
-							die "${FUNCNAME}(): '$1' has invalid syntax"
-						fi
-						for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
-							eval "search_paths+=(\"\${root}$1\")"
-						done
-					else
-						search_paths+=("${root}$1")
+	if [[ "$#" -eq 0 ]]; then
+		die "${FUNCNAME}(): Missing files or directories"
+	fi
+
+	if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis || _python_implementation || [[ "${CATEGORY}/${PN}" == "sys-apps/portage" ]]; then
+		while (($#)); do
+			if [[ "$1" =~ ^($|(\.|\.\.|/)($|/)) ]]; then
+				die "${FUNCNAME}(): Invalid argument '$1'"
+			elif ! _python_implementation && [[ "$1" =~ ^/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then
+				die "${FUNCNAME}(): Paths of directories / files in site-packages directories must be relative to site-packages directories"
+			elif [[ "$1" =~ ^/ ]]; then
+				if _python_package_supporting_installation_for_multiple_python_abis; then
+					if [[ "${allow_evaluated_non_sitedir_paths}" != "1" ]]; then
+						die "${FUNCNAME}(): Absolute paths cannot be used in ebuilds of packages supporting installation for multiple Python ABIs"
+					fi
+					if [[ "$1" != *\$* ]]; then
+						die "${FUNCNAME}(): '$1' has invalid syntax"
 					fi
-				else
 					for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
-						search_paths+=("${root}$(python_get_sitedir)/$1")
+						eval "search_paths+=(\"\${root}$1\")"
 					done
+				else
+					search_paths+=("${root}$1")
 				fi
-				shift
-			done
-		else
-			# Deprecated part of python_mod_cleanup()
-
-			search_paths=("${@#/}")
-			search_paths=("${search_paths[@]/#/${root}/}")
-		fi
-	else
-		ewarn
-		ewarn "Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be"
-		ewarn "disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules."
-		ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported."
-		ewarn
-
-		for dir in "${root}"/usr/lib*; do
-			if [[ -d "${dir}" && ! -L "${dir}" ]]; then
-				for sitedir in "${dir}"/python*/site-packages; do
-					if [[ -d "${sitedir}" ]]; then
-						search_paths+=("${sitedir}")
-					fi
+			else
+				for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
+					search_paths+=("${root}$(python_get_sitedir)/$1")
 				done
 			fi
+			shift
 		done
-		for sitedir in "${root}"/usr/share/jython-*/Lib/site-packages; do
-			if [[ -d "${sitedir}" ]]; then
-				search_paths+=("${sitedir}")
-			fi
-		done
+	else
+		# Deprecated part of python_mod_cleanup()
+		# ewarn
+		# ewarn "Deprecation Warning: Usage of ${FUNCNAME}() in packages not supporting installation"
+		# ewarn "for multiple Python ABIs in EAPI <=2 is deprecated and will be disallowed on 2011-06-01."
+		# ewarn "Use EAPI >=3 and call ${FUNCNAME}() with paths having appropriate syntax."
+		# ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported."
+		# ewarn
+
+		search_paths=("${@#/}")
+		search_paths=("${search_paths[@]/#/${root}/}")
 	fi
 
 	_python_clean_compiled_modules "${search_paths[@]}"
@@ -2609,52 +2740,8 @@
 	die "${FUNCNAME}() is banned"
 }
 
-# @FUNCTION: python_mod_compile
-# @USAGE: <file> [more files ...]
-# @DESCRIPTION:
-# Given filenames, it will pre-compile the module's .pyc and .pyo.
-# This function can be used only in pkg_postinst() phase.
-#
-# Example:
-#         python_mod_compile /usr/lib/python2.3/site-packages/pygoogle.py
-#
+# Scheduled for deletion on 2011-04-01.
 python_mod_compile() {
-	if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
-		eerror "Use python_mod_optimize() instead of ${FUNCNAME}()."
-		die "${FUNCNAME}() cannot be used in this EAPI"
-	fi
-
-	_python_initialize_prefix_variables
-	_python_set_color_variables
-
-	if [[ "${FUNCNAME[1]}" != "python_mod_optimize" ]]; then
-		ewarn
-		ewarn "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-09-01."
-		ewarn "Use python_mod_optimize() instead of ${FUNCNAME}()."
-		ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported."
-		ewarn
-	fi
-
-	local f myroot myfiles=()
-
-	# Check if phase is pkg_postinst()
-	[[ "${EBUILD_PHASE}" != "postinst" ]] && die "${FUNCNAME}() can be used only in pkg_postinst() phase"
-
-	# strip trailing slash
-	myroot="${EROOT%/}"
-
-	# respect EROOT
-	for f in "$@"; do
-		[[ -f "${myroot}/${f}" ]] && myfiles+=("${myroot}/${f}")
-	done
-
-	PYTHON_ABI="$(PYTHON --ABI)"
-
-	if ((${#myfiles[@]})); then
-		"$(PYTHON ${PYTHON_ABI})" "${myroot}$(python_get_libdir)/py_compile.py" "${myfiles[@]}"
-		"$(PYTHON ${PYTHON_ABI})" -O "${myroot}$(python_get_libdir)/py_compile.py" "${myfiles[@]}" &> /dev/null
-		_python_clean_compiled_modules "${myfiles[@]}"
-	else
-		ewarn "No files to compile!"
-	fi
+	eerror "Use python_mod_optimize() instead of ${FUNCNAME}()."
+	die "${FUNCNAME}() is banned"
 }






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2010-10-29 19:09 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2010-10-29 19:09 UTC (permalink / raw
  To: gentoo-commits

arfrever    10/10/29 19:09:08

  Modified:             python.eclass
  Log:
  Temporarily delete some code.

Revision  Changes    Path
1.105                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.105&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.105&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.104&r2=1.105

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -r1.104 -r1.105
--- python.eclass	25 Oct 2010 11:54:19 -0000	1.104
+++ python.eclass	29 Oct 2010 19:09:08 -0000	1.105
@@ -1,6 +1,6 @@
 # Copyright 1999-2010 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.104 2010/10/25 11:54:19 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.105 2010/10/29 19:09:08 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -24,31 +24,6 @@
 # ===================================== HANDLING OF METADATA =====================================
 # ================================================================================================
 
-_python_set_IUSE() {
-	local PYTHON_ABI restricted_ABI restricted_ABIs support_ABI
-
-	_PYTHON_ABIS_USE_FLAGS=""
-	restricted_ABIs="${RESTRICT_PYTHON_ABIS// /$'\n'}"
-
-	for PYTHON_ABI in "${_PYTHON_SUPPORTED_ABIS[@]}"; do
-		support_ABI="1"
-		while read restricted_ABI; do
-			if [[ "${PYTHON_ABI}" == ${restricted_ABI} ]]; then
-				support_ABI="0"
-				break
-			fi
-		done <<< "${restricted_ABIs}"
-		[[ "${support_ABI}" == "1" ]] && _PYTHON_ABIS_USE_FLAGS+="${_PYTHON_ABIS_USE_FLAGS:+ }python_abis_${PYTHON_ABI}"
-	done
-
-	IUSE="${_PYTHON_ABIS_USE_FLAGS}"
-}
-
-if ! has "${EAPI:-0}" 0 1 2 3 && [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
-	_python_set_IUSE
-fi
-unset -f _python_set_IUSE
-
 # @ECLASS-VARIABLE: PYTHON_DEPEND
 # @DESCRIPTION:
 # Specification of dependency on dev-lang/python.
@@ -239,135 +214,6 @@
 
 unset _PYTHON_ATOMS
 
-# @FUNCTION: python_abi_depend
-# @USAGE: [-e|--exclude-ABIs Python_ABIs] [-i|--include-ABIs Python_ABIs] [--] <dependency_atom> [dependency_atoms]
-# @DESCRIPTION:
-# Print dependency atoms with USE dependencies for Python ABIs added.
-# If --exclude-ABIs option is specified, then Python ABIs matching its argument are not used.
-# If --include-ABIs option is specified, then only Python ABIs matching its argument are used.
-# --exclude-ABIs and --include-ABIs options cannot be specified simultaneously.
-python_abi_depend() {
-	local atom atom_index atoms=() exclude_ABIs="0" excluded_ABI excluded_ABIs include_ABIs="0" included_ABI included_ABIs support_ABI USE_dependencies USE_flag USE_flag_index USE_flags=()
-
-	if has "${EAPI:-0}" 0 1 2 3; then
-		die "${FUNCNAME}() cannot be used in this EAPI"
-	fi
-
-	if [[ -z "${SUPPORT_PYTHON_ABIS}" ]]; then
-		die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
-	fi
-
-	while (($#)); do
-		case "$1" in
-			-e|--exclude-ABIs)
-				exclude_ABIs="1"
-				excluded_ABIs="${2// /$'\n'}"
-				shift
-				;;
-			-i|--include-ABIs)
-				include_ABIs="1"
-				included_ABIs="${2// /$'\n'}"
-				shift
-				;;
-			--)
-				shift
-				break
-				;;
-			-*)
-				die "${FUNCNAME}(): Unrecognized option '$1'"
-				;;
-			*)
-				break
-				;;
-		esac
-		shift
-	done
-
-	if [[ "${exclude_ABIs}" == "1" && "${include_ABIs}" == "1" ]]; then
-		die "${FUNCNAME}(): '--exclude-ABIs' and '--include-ABIs' options cannot be specified simultaneously"
-	fi
-
-	if [[ "$#" -eq 0 ]]; then
-		die "${FUNCNAME}(): Missing dependency atoms"
-	fi
-
-	atoms=("$@")
-
-	if [[ "${exclude_ABIs}" == "0" && "${include_ABIs}" == "0" ]]; then
-		USE_dependencies="$(printf ",%s?" ${_PYTHON_ABIS_USE_FLAGS})"
-		USE_dependencies="${USE_dependencies#,}"
-
-		for atom_index in "${!atoms[@]}"; do
-			atom="${atoms[${atom_index}]}"
-
-			if [[ "${atom}" == *"["*"]" ]]; then
-				echo -n "${atom%]},"
-			else
-				echo -n "${atom}["
-			fi
-			echo -n "${USE_dependencies}]"
-
-			if [[ "${atom_index}" -ne $((${#atoms[@]} - 1)) ]]; then
-				echo -n " "
-			fi
-		done
-	else
-		if [[ "${exclude_ABIs}" == "1" ]]; then
-			for USE_flag in ${_PYTHON_ABIS_USE_FLAGS}; do
-				while read excluded_ABI; do
-				support_ABI="1"
-					if [[ "${USE_flag}" == python_abis_${excluded_ABI} ]]; then
-						support_ABI="0"
-						break
-					fi
-				done <<< "${excluded_ABIs}"
-			[[ "${support_ABI}" == "1" ]] && USE_flags+=("${USE_flag}")
-			done
-		elif [[ "${include_ABIs}" == "1" ]]; then
-			for USE_flag in ${_PYTHON_ABIS_USE_FLAGS}; do
-				while read included_ABI; do
-				support_ABI="0"
-					if [[ "${USE_flag}" == python_abis_${included_ABI} ]]; then
-						support_ABI="1"
-						break
-					fi
-				done <<< "${included_ABIs}"
-			[[ "${support_ABI}" == "1" ]] && USE_flags+=("${USE_flag}")
-			done
-		else
-			die "${FUNCNAME}(): Internal error"
-		fi
-
-		for USE_flag_index in "${!USE_flags[@]}"; do
-			USE_flag="${USE_flags[${USE_flag_index}]}"
-			USE_dependencies="${USE_flag}"
-
-			echo -n "${USE_flag}? ( "
-
-			for atom_index in "${!atoms[@]}"; do
-				atom="${atoms[${atom_index}]}"
-
-				if [[ "${atom}" == *"["*"]" ]]; then
-					echo -n "${atom%]},"
-				else
-					echo -n "${atom}["
-				fi
-				echo -n "${USE_dependencies}]"
-
-				if [[ "${atom_index}" -ne $((${#atoms[@]} - 1)) ]]; then
-					echo -n " "
-				fi
-			done
-
-			echo -n " )"
-
-			if [[ "${USE_flag_index}" -ne $((${#USE_flags[@]} - 1)) ]]; then
-				echo -n " "
-			fi
-		done
-	fi
-}
-
 # ================================================================================================
 # =================================== MISCELLANEOUS FUNCTIONS ====================================
 # ================================================================================================






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2010-12-24 15:01 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2010-12-24 15:01 UTC (permalink / raw
  To: gentoo-commits

arfrever    10/12/24 15:01:09

  Modified:             python.eclass
  Log:
  Improve support for Jython.
  Improve python_generate_wrapper_scripts().
  Add python_merge_intermediate_installation_images().

Revision  Changes    Path
1.106                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.106&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.106&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.105&r2=1.106

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.105
retrieving revision 1.106
diff -u -r1.105 -r1.106
--- python.eclass	29 Oct 2010 19:09:08 -0000	1.105
+++ python.eclass	24 Dec 2010 15:01:09 -0000	1.106
@@ -1,6 +1,6 @@
 # Copyright 1999-2010 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.105 2010/10/29 19:09:08 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.106 2010/12/24 15:01:09 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -15,15 +15,35 @@
 	die "API of python.eclass in EAPI=\"${EAPI}\" not established"
 fi
 
-_CPYTHON2_SUPPORTED_ABIS=(2.4 2.5 2.6 2.7)
-_CPYTHON3_SUPPORTED_ABIS=(3.0 3.1 3.2)
-_JYTHON_SUPPORTED_ABIS=(2.5-jython)
-_PYTHON_SUPPORTED_ABIS=(${_CPYTHON2_SUPPORTED_ABIS[@]} ${_CPYTHON3_SUPPORTED_ABIS[@]} ${_JYTHON_SUPPORTED_ABIS[@]})
+_CPYTHON2_GLOBALLY_SUPPORTED_ABIS=(2.4 2.5 2.6 2.7)
+_CPYTHON3_GLOBALLY_SUPPORTED_ABIS=(3.0 3.1 3.2)
+_JYTHON_GLOBALLY_SUPPORTED_ABIS=(2.5-jython)
+_PYTHON_GLOBALLY_SUPPORTED_ABIS=(${_CPYTHON2_GLOBALLY_SUPPORTED_ABIS[@]} ${_CPYTHON3_GLOBALLY_SUPPORTED_ABIS[@]} ${_JYTHON_GLOBALLY_SUPPORTED_ABIS[@]})
 
 # ================================================================================================
 # ===================================== HANDLING OF METADATA =====================================
 # ================================================================================================
 
+_python_check_python_abi_matching() {
+	if [[ "$#" -ne 2 ]]; then
+		die "${FUNCNAME}() requires 2 arguments"
+	fi
+
+	if [[ "$2" == *"-cpython" ]]; then
+		[[ "$1" =~ ^[[:digit:]]+\.[[:digit:]]+$ && "$1" == ${2%-cpython} ]]
+	elif [[ "$2" == *"-jython" ]]; then
+		[[ "$1" == $2 ]]
+	else
+		if [[ "$1" =~ ^[[:digit:]]+\.[[:digit:]]+$ ]]; then
+			[[ "$1" == $2 ]]
+		elif [[ "$1" =~ ^[[:digit:]]+\.[[:digit:]]+-jython$ ]]; then
+			[[ "${1%-jython}" == $2 ]]
+		else
+			die "${FUNCNAME}(): Unrecognized Python ABI '$1'"
+		fi
+	fi
+}
+
 # @ECLASS-VARIABLE: PYTHON_DEPEND
 # @DESCRIPTION:
 # Specification of dependency on dev-lang/python.
@@ -67,17 +87,17 @@
 
 			if [[ "${major_version}" == "2" ]]; then
 				python2="1"
-				python_versions=("${_CPYTHON2_SUPPORTED_ABIS[@]}")
+				python_versions=("${_CPYTHON2_GLOBALLY_SUPPORTED_ABIS[@]}")
 				python2_minimal_version="${minimal_version}"
 				python2_maximal_version="${maximal_version}"
 			elif [[ "${major_version}" == "3" ]]; then
 				python3="1"
-				python_versions=("${_CPYTHON3_SUPPORTED_ABIS[@]}")
+				python_versions=("${_CPYTHON3_GLOBALLY_SUPPORTED_ABIS[@]}")
 				python3_minimal_version="${minimal_version}"
 				python3_maximal_version="${maximal_version}"
 			else
 				python_all="1"
-				python_versions=("${_CPYTHON2_SUPPORTED_ABIS[@]}" "${_CPYTHON3_SUPPORTED_ABIS[@]}")
+				python_versions=("${_CPYTHON2_GLOBALLY_SUPPORTED_ABIS[@]}" "${_CPYTHON3_GLOBALLY_SUPPORTED_ABIS[@]}")
 				python_minimal_version="${minimal_version}"
 				python_maximal_version="${maximal_version}"
 			fi
@@ -115,7 +135,7 @@
 			if [[ -z "${python_minimal_version}" && -z "${python_maximal_version}" ]]; then
 				_PYTHON_ATOMS+=("dev-lang/python")
 			else
-				python_versions=("${_CPYTHON2_SUPPORTED_ABIS[@]}" "${_CPYTHON3_SUPPORTED_ABIS[@]}")
+				python_versions=("${_CPYTHON2_GLOBALLY_SUPPORTED_ABIS[@]}" "${_CPYTHON3_GLOBALLY_SUPPORTED_ABIS[@]}")
 				python_minimal_version="${python_minimal_version:-${python_versions[0]}}"
 				python_maximal_version="${python_maximal_version:-${python_versions[${#python_versions[@]}-1]}}"
 				_append_accepted_versions_range
@@ -125,7 +145,7 @@
 				if [[ -z "${python3_minimal_version}" && -z "${python3_maximal_version}" ]]; then
 					_PYTHON_ATOMS+=("=dev-lang/python-3*")
 				else
-					python_versions=("${_CPYTHON3_SUPPORTED_ABIS[@]}")
+					python_versions=("${_CPYTHON3_GLOBALLY_SUPPORTED_ABIS[@]}")
 					python_minimal_version="${python3_minimal_version:-${python_versions[0]}}"
 					python_maximal_version="${python3_maximal_version:-${python_versions[${#python_versions[@]}-1]}}"
 					_append_accepted_versions_range
@@ -135,7 +155,7 @@
 				if [[ -z "${python2_minimal_version}" && -z "${python2_maximal_version}" ]]; then
 					_PYTHON_ATOMS+=("=dev-lang/python-2*")
 				else
-					python_versions=("${_CPYTHON2_SUPPORTED_ABIS[@]}")
+					python_versions=("${_CPYTHON2_GLOBALLY_SUPPORTED_ABIS[@]}")
 					python_minimal_version="${python2_minimal_version:-${python_versions[0]}}"
 					python_maximal_version="${python2_maximal_version:-${python_versions[${#python_versions[@]}-1]}}"
 					_append_accepted_versions_range
@@ -350,6 +370,9 @@
 		die "${FUNCNAME}() does not accept arguments"
 	fi
 
+	export JYTHON_SYSTEM_CACHEDIR="1"
+	addwrite "${EPREFIX}/var/cache/jython"
+
 	if _python_package_supporting_installation_for_multiple_python_abis; then
 		_python_calculate_PYTHON_ABIS
 		export EPYTHON="$(PYTHON -f)"
@@ -405,14 +428,16 @@
 	EXPORT_FUNCTIONS pkg_setup
 fi
 
+_PYTHON_SHEBANG_BASE_PART_REGEX='^#![[:space:]]*([^[:space:]]*/usr/bin/env[[:space:]]+)?([^[:space:]]*/)?(jython|python)'
+
 # @FUNCTION: python_convert_shebangs
-# @USAGE: [-q|--quiet] [-r|--recursive] [-x|--only-executables] [--] <Python_version> <file|directory> [files|directories]
+# @USAGE: [-q|--quiet] [-r|--recursive] [-x|--only-executables] [--] <Python_ABI|Python_version> <file|directory> [files|directories]
 # @DESCRIPTION:
 # Convert shebangs in specified files. Directories can be specified only with --recursive option.
 python_convert_shebangs() {
 	_python_check_python_pkg_setup_execution
 
-	local argument file files=() only_executables="0" python_version quiet="0" recursive="0"
+	local argument file files=() only_executables="0" python_interpreter quiet="0" recursive="0"
 
 	while (($#)); do
 		case "$1" in
@@ -445,7 +470,11 @@
 		die "${FUNCNAME}(): Missing files or directories"
 	fi
 
-	python_version="$1"
+	if [[ -n "$(_python_get_implementation --ignore-invalid "$1")" ]]; then
+		python_interpreter="$(PYTHON "$1")"
+	else
+		python_interpreter="python$1"
+	fi
 	shift
 
 	for argument in "$@"; do
@@ -470,17 +499,14 @@
 		file="${file#./}"
 		[[ "${only_executables}" == "1" && ! -x "${file}" ]] && continue
 
-		if [[ "$(head -n1 "${file}")" =~ ^'#!'.*python ]]; then
+		if [[ "$(head -n1 "${file}")" =~ ${_PYTHON_SHEBANG_BASE_PART_REGEX} ]]; then
 			[[ "$(sed -ne "2p" "${file}")" =~ ^"# Gentoo '".*"' wrapper script generated by python_generate_wrapper_scripts()"$ ]] && continue
 
 			if [[ "${quiet}" == "0" ]]; then
 				einfo "Converting shebang in '${file}'"
 			fi
 
-			sed -e "1s/python\([[:digit:]]\+\(\.[[:digit:]]\+\)\?\)\?/python${python_version}/" -i "${file}" || die "Conversion of shebang in '${file}' failed"
-
-			# Delete potential whitespace after "#!".
-			sed -e '1s/\(^#!\)[[:space:]]*/\1/' -i "${file}" || die "sed '${file}' failed"
+			sed -e "1s:^#![[:space:]]*\([^[:space:]]*/usr/bin/env[[:space:]]\)\?[[:space:]]*\([^[:space:]]*/\)\?\(jython\|python\)\([[:digit:]]\+\(\.[[:digit:]]\+\)\?\)\?\(\$\|[[:space:]].*\):#!\1\2${python_interpreter}\6:" -i "${file}" || die "Conversion of shebang in '${file}' failed"
 		fi
 	done
 }
@@ -618,17 +644,17 @@
 			fi
 
 			for PYTHON_ABI in ${USE_PYTHON}; do
-				if ! has "${PYTHON_ABI}" ${_PYTHON_SUPPORTED_ABIS[@]}; then
+				if ! has "${PYTHON_ABI}" "${_PYTHON_GLOBALLY_SUPPORTED_ABIS[@]}"; then
 					die "USE_PYTHON variable contains invalid value '${PYTHON_ABI}'"
 				fi
 
-				if has "${PYTHON_ABI}" "${_CPYTHON2_SUPPORTED_ABIS[@]}" "${_CPYTHON3_SUPPORTED_ABIS[@]}"; then
+				if has "${PYTHON_ABI}" "${_CPYTHON2_GLOBALLY_SUPPORTED_ABIS[@]}" "${_CPYTHON3_GLOBALLY_SUPPORTED_ABIS[@]}"; then
 					cpython_enabled="1"
 				fi
 
 				support_ABI="1"
 				while read restricted_ABI; do
-					if [[ "${PYTHON_ABI}" == ${restricted_ABI} ]]; then
+					if _python_check_python_abi_matching "${PYTHON_ABI}" "${restricted_ABI}"; then
 						support_ABI="0"
 						break
 					fi
@@ -659,10 +685,10 @@
 
 				python2_version="$("${EPREFIX}/usr/bin/python2" -c 'from sys import version_info; print(".".join(str(x) for x in version_info[:2]))')"
 
-				for PYTHON_ABI in "${_CPYTHON2_SUPPORTED_ABIS[@]}"; do
+				for PYTHON_ABI in "${_CPYTHON2_GLOBALLY_SUPPORTED_ABIS[@]}"; do
 					support_python_major_version="1"
 					while read restricted_ABI; do
-						if [[ "${PYTHON_ABI}" == ${restricted_ABI} ]]; then
+						if _python_check_python_abi_matching "${PYTHON_ABI}" "${restricted_ABI}"; then
 							support_python_major_version="0"
 						fi
 					done <<< "${restricted_ABIs}"
@@ -670,8 +696,8 @@
 				done
 				if [[ "${support_python_major_version}" == "1" ]]; then
 					while read restricted_ABI; do
-						if [[ "${python2_version}" == ${restricted_ABI} ]]; then
-							die "Active version of Python 2 is not supported by ${CATEGORY}/${PF}"
+						if _python_check_python_abi_matching "${python2_version}" "${restricted_ABI}"; then
+							die "Active version of CPython 2 is not supported by ${CATEGORY}/${PF}"
 						fi
 					done <<< "${restricted_ABIs}"
 				else
@@ -686,10 +712,10 @@
 
 				python3_version="$("${EPREFIX}/usr/bin/python3" -c 'from sys import version_info; print(".".join(str(x) for x in version_info[:2]))')"
 
-				for PYTHON_ABI in "${_CPYTHON3_SUPPORTED_ABIS[@]}"; do
+				for PYTHON_ABI in "${_CPYTHON3_GLOBALLY_SUPPORTED_ABIS[@]}"; do
 					support_python_major_version="1"
 					while read restricted_ABI; do
-						if [[ "${PYTHON_ABI}" == ${restricted_ABI} ]]; then
+						if _python_check_python_abi_matching "${PYTHON_ABI}" "${restricted_ABI}"; then
 							support_python_major_version="0"
 						fi
 					done <<< "${restricted_ABIs}"
@@ -697,8 +723,8 @@
 				done
 				if [[ "${support_python_major_version}" == "1" ]]; then
 					while read restricted_ABI; do
-						if [[ "${python3_version}" == ${restricted_ABI} ]]; then
-							die "Active version of Python 3 is not supported by ${CATEGORY}/${PF}"
+						if _python_check_python_abi_matching "${python3_version}" "${restricted_ABI}"; then
+							die "Active version of CPython 3 is not supported by ${CATEGORY}/${PF}"
 						fi
 					done <<< "${restricted_ABIs}"
 				else
@@ -740,7 +766,7 @@
 						element="${element#* }"
 						operator="${element%% *}"
 						flags="${element#* }"
-						if [[ "${PYTHON_ABI}" == ${pattern} ]]; then
+						if _python_check_python_abi_matching "${PYTHON_ABI}" "${pattern}"; then
 							if [[ "${operator}" == "+" ]]; then
 								eval "export ${variable}+=\"\${variable:+ }${flags}\""
 							elif [[ "${operator}" == "-" ]]; then
@@ -1057,7 +1083,7 @@
 
 	_python_initialize_prefix_variables
 
-	local eselect_python_option file force="0" quiet="0" PYTHON_ABI python2_enabled="0" python3_enabled="0" respect_EPYTHON="0"
+	local eselect_python_option file force="0" quiet="0" PYTHON_ABI PYTHON_ABIS_list python2_enabled="0" python3_enabled="0" respect_EPYTHON="0"
 
 	while (($#)); do
 		case "$1" in
@@ -1089,12 +1115,12 @@
 	fi
 
 	_python_calculate_PYTHON_ABIS
-	for PYTHON_ABI in "${_CPYTHON2_SUPPORTED_ABIS[@]}"; do
+	for PYTHON_ABI in "${_CPYTHON2_GLOBALLY_SUPPORTED_ABIS[@]}"; do
 		if has "${PYTHON_ABI}" ${PYTHON_ABIS}; then
 			python2_enabled="1"
 		fi
 	done
-	for PYTHON_ABI in "${_CPYTHON3_SUPPORTED_ABIS[@]}"; do
+	for PYTHON_ABI in "${_CPYTHON3_GLOBALLY_SUPPORTED_ABIS[@]}"; do
 		if has "${PYTHON_ABI}" ${PYTHON_ABIS}; then
 			python3_enabled="1"
 		fi
@@ -1110,9 +1136,11 @@
 		die "${FUNCNAME}(): Unsupported environment"
 	fi
 
+	PYTHON_ABIS_list="$("$(PYTHON -f)" -c "print(', '.join('\"%s\"' % x for x in reversed('${PYTHON_ABIS}'.split())))")"
+
 	for file in "$@"; do
 		if [[ -f "${file}" && "${force}" == "0" ]]; then
-			die "${FUNCNAME}(): '$1' already exists"
+			die "${FUNCNAME}(): '${file}' already exists"
 		fi
 
 		if [[ "${quiet}" == "0" ]]; then
@@ -1128,10 +1156,22 @@
 import subprocess
 import sys
 
-EPYTHON_re = re.compile(r"^python(\d+\.\d+)$")
+cpython_re = re.compile(r"^python(\d+\.\d+)$")
+jython_re = re.compile(r"^jython(\d+\.\d+)$")
 python_shebang_re = re.compile(r"^#! *(${EPREFIX}/usr/bin/python|(${EPREFIX})?/usr/bin/env +(${EPREFIX}/usr/bin/)?python)")
 python_verification_output_re = re.compile("^GENTOO_PYTHON_TARGET_SCRIPT_PATH supported\n$")
 
+def get_PYTHON_ABI(EPYTHON):
+	cpython_matched = cpython_re.match(EPYTHON)
+	jython_matched = jython_re.match(EPYTHON)
+	if cpython_matched is not None:
+		PYTHON_ABI = cpython_matched.group(1)
+	elif jython_matched is not None:
+		PYTHON_ABI = jython_matched.group(1) + "-jython"
+	else:
+		PYTHON_ABI = None
+	return PYTHON_ABI
+
 EOF
 		if [[ "$?" != "0" ]]; then
 			die "${FUNCNAME}(): Generation of '$1' failed"
@@ -1140,10 +1180,8 @@
 			cat << EOF >> "${file}"
 EPYTHON = os.environ.get("EPYTHON")
 if EPYTHON:
-	EPYTHON_matched = EPYTHON_re.match(EPYTHON)
-	if EPYTHON_matched:
-		PYTHON_ABI = EPYTHON_matched.group(1)
-	else:
+	PYTHON_ABI = get_PYTHON_ABI(EPYTHON)
+	if PYTHON_ABI is None:
 		sys.stderr.write("EPYTHON variable has unrecognized value '%s'\n" % EPYTHON)
 		sys.exit(1)
 else:
@@ -1161,12 +1199,16 @@
 		EPYTHON = EPYTHON.decode()
 	EPYTHON = EPYTHON.rstrip("\n")
 
-	EPYTHON_matched = EPYTHON_re.match(EPYTHON)
-	if EPYTHON_matched:
-		PYTHON_ABI = EPYTHON_matched.group(1)
-	else:
+	PYTHON_ABI = get_PYTHON_ABI(EPYTHON)
+	if PYTHON_ABI is None:
 		sys.stderr.write("'eselect python show${eselect_python_option:+ }${eselect_python_option}' printed unrecognized value '%s'\n" % EPYTHON)
 		sys.exit(1)
+
+wrapper_script_path = os.path.realpath(sys.argv[0])
+target_executable_path = "%s-%s" % (wrapper_script_path, PYTHON_ABI)
+if not os.path.exists(target_executable_path):
+	sys.stderr.write("'%s' does not exist\n" % target_executable_path)
+	sys.exit(1)
 EOF
 			if [[ "$?" != "0" ]]; then
 				die "${FUNCNAME}(): Generation of '$1' failed"
@@ -1187,12 +1229,19 @@
 	EPYTHON = EPYTHON.decode()
 EPYTHON = EPYTHON.rstrip("\n")
 
-EPYTHON_matched = EPYTHON_re.match(EPYTHON)
-if EPYTHON_matched:
-	PYTHON_ABI = EPYTHON_matched.group(1)
-else:
+PYTHON_ABI = get_PYTHON_ABI(EPYTHON)
+if PYTHON_ABI is None:
 	sys.stderr.write("'eselect python show${eselect_python_option:+ }${eselect_python_option}' printed unrecognized value '%s'\n" % EPYTHON)
 	sys.exit(1)
+
+wrapper_script_path = os.path.realpath(sys.argv[0])
+for PYTHON_ABI in [PYTHON_ABI, ${PYTHON_ABIS_list}]:
+	target_executable_path = "%s-%s" % (wrapper_script_path, PYTHON_ABI)
+	if os.path.exists(target_executable_path):
+		break
+else:
+	sys.stderr.write("No target script exists for '%s'\n" % wrapper_script_path)
+	sys.exit(1)
 EOF
 			if [[ "$?" != "0" ]]; then
 				die "${FUNCNAME}(): Generation of '$1' failed"
@@ -1200,15 +1249,6 @@
 		fi
 		cat << EOF >> "${file}"
 
-wrapper_script_path = os.path.realpath(sys.argv[0])
-target_executable_path = "%s-%s" % (wrapper_script_path, PYTHON_ABI)
-os.environ["GENTOO_PYTHON_PROCESS_NAME"] = os.path.basename(sys.argv[0])
-os.environ["GENTOO_PYTHON_WRAPPER_SCRIPT_PATH"] = sys.argv[0]
-os.environ["GENTOO_PYTHON_TARGET_SCRIPT_PATH"] = target_executable_path
-if not os.path.exists(target_executable_path):
-	sys.stderr.write("'%s' does not exist\n" % target_executable_path)
-	sys.exit(1)
-
 target_executable = open(target_executable_path, "rb")
 target_executable_first_line = target_executable.readline()
 if not isinstance(target_executable_first_line, str):
@@ -1218,7 +1258,7 @@
 python_shebang_matched = python_shebang_re.match(target_executable_first_line)
 target_executable.close()
 
-if python_shebang_matched:
+if python_shebang_matched is not None:
 	try:
 		python_interpreter_path = "${EPREFIX}/usr/bin/%s" % EPYTHON
 		os.environ["GENTOO_PYTHON_TARGET_SCRIPT_PATH_VERIFICATION"] = "1"
@@ -1235,13 +1275,27 @@
 		if not python_verification_output_re.match(python_verification_output):
 			raise ValueError
 
-		os.execv(python_interpreter_path, [python_interpreter_path] + sys.argv)
+		if cpython_re.match(EPYTHON) is not None:
+			os.environ["GENTOO_PYTHON_PROCESS_NAME"] = os.path.basename(sys.argv[0])
+			os.environ["GENTOO_PYTHON_WRAPPER_SCRIPT_PATH"] = sys.argv[0]
+			os.environ["GENTOO_PYTHON_TARGET_SCRIPT_PATH"] = target_executable_path
+
+		if hasattr(os, "execv"):
+			os.execv(python_interpreter_path, [python_interpreter_path] + sys.argv)
+		else:
+			sys.exit(subprocess.Popen([python_interpreter_path] + sys.argv).wait())
+	except (KeyboardInterrupt, SystemExit):
+		raise
 	except:
 		pass
-	if "GENTOO_PYTHON_TARGET_SCRIPT_PATH_VERIFICATION" in os.environ:
-		del os.environ["GENTOO_PYTHON_TARGET_SCRIPT_PATH_VERIFICATION"]
+	for variable in ("GENTOO_PYTHON_PROCESS_NAME", "GENTOO_PYTHON_WRAPPER_SCRIPT_PATH", "GENTOO_PYTHON_TARGET_SCRIPT_PATH", "GENTOO_PYTHON_TARGET_SCRIPT_PATH_VERIFICATION"):
+		if variable in os.environ:
+			del os.environ[variable]
 
-os.execv(target_executable_path, sys.argv)
+if hasattr(os, "execv"):
+	os.execv(target_executable_path, sys.argv)
+else:
+	sys.exit(subprocess.Popen([target_executable_path] + sys.argv[1:]).wait())
 EOF
 		if [[ "$?" != "0" ]]; then
 			die "${FUNCNAME}(): Generation of '$1' failed"
@@ -1250,6 +1304,184 @@
 	done
 }
 
+# @ECLASS-VARIABLE: PYTHON_VERSIONED_SCRIPTS
+# @DESCRIPTION:
+# Array of regular expressions of paths to versioned Python scripts.
+# Python scripts in /usr/bin and /usr/sbin are versioned by default.
+
+# @ECLASS-VARIABLE: PYTHON_VERSIONED_EXECUTABLES
+# @DESCRIPTION:
+# Array of regular expressions of paths to versioned executables (including Python scripts).
+
+# @ECLASS-VARIABLE: PYTHON_NONVERSIONED_EXECUTABLES
+# @DESCRIPTION:
+# Array of regular expressions of paths to nonversioned executables (including Python scripts).
+
+# @FUNCTION: python_merge_intermediate_installation_images
+# @USAGE: [-q|--quiet] [--] <intermediate_installation_images_directory>
+# @DESCRIPTION:
+# Merge intermediate installation images into installation image.
+python_merge_intermediate_installation_images() {
+	_python_check_python_pkg_setup_execution
+	_python_initialize_prefix_variables
+
+	local b file files=() intermediate_installation_images_directory PYTHON_ABI quiet="0" regex shebang version_executable wrapper_scripts=() wrapper_scripts_set=()
+
+	# Check if phase is src_install().
+	[[ "${EBUILD_PHASE}" != "install" ]] && die "${FUNCNAME}() can be used only in src_install() phase"
+
+	while (($#)); do
+		case "$1" in
+			-q|--quiet)
+				quiet="1"
+				;;
+			--)
+				shift
+				break
+				;;
+			-*)
+				die "${FUNCNAME}(): Unrecognized option '$1'"
+				;;
+			*)
+				break
+				;;
+		esac
+		shift
+	done
+
+	if [[ "$#" -ne 1 ]]; then
+		die "${FUNCNAME}() requires 1 argument"
+	fi
+
+	intermediate_installation_images_directory="$1"
+
+	if [[ ! -d "${intermediate_installation_images_directory}" ]]; then
+		die "${FUNCNAME}(): Intermediate installation images directory '${intermediate_installation_images_directory}' does not exist"
+	fi
+
+	_python_calculate_PYTHON_ABIS
+	if [[ "$(PYTHON -f --ABI)" == 3.* ]]; then
+		b="b"
+	fi
+
+	while read -d $'\0' -r file; do
+		files+=("${file}")
+	done < <("$(PYTHON -f)" -c \
+"import os
+import sys
+
+if hasattr(sys.stdout, 'buffer'):
+	# Python 3
+	stdout = sys.stdout.buffer
+else:
+	# Python 2
+	stdout = sys.stdout
+
+files_set = set()
+
+os.chdir(${b}'${intermediate_installation_images_directory}')
+
+for PYTHON_ABI in ${b}'${PYTHON_ABIS}'.split():
+	for root, dirs, files in os.walk(PYTHON_ABI + ${b}'${EPREFIX}'):
+		root = root[len(PYTHON_ABI + ${b}'${EPREFIX}')+1:]
+		files_set.update(root + ${b}'/' + file for file in files)
+
+for file in sorted(files_set):
+	stdout.write(file)
+	stdout.write(${b}'\x00')" || die "${FUNCNAME}(): Failure of extraction of files in intermediate installation images")
+
+	for PYTHON_ABI in ${PYTHON_ABIS}; do
+		if [[ ! -d "${intermediate_installation_images_directory}/${PYTHON_ABI}" ]]; then
+			die "${FUNCNAME}(): Intermediate installation image for Python ABI '${PYTHON_ABI}' does not exist"
+		fi
+
+		pushd "${intermediate_installation_images_directory}/${PYTHON_ABI}${EPREFIX}" > /dev/null || die "pushd failed"
+
+		for file in "${files[@]}"; do
+			version_executable="0"
+			for regex in "/usr/bin/.*" "/usr/sbin/.*" "${PYTHON_VERSIONED_SCRIPTS[@]}"; do
+				if [[ "/${file}" =~ ^${regex}$ ]]; then
+					version_executable="1"
+					break
+				fi
+			done
+			for regex in "${PYTHON_VERSIONED_EXECUTABLES[@]}"; do
+				if [[ "/${file}" =~ ^${regex}$ ]]; then
+					version_executable="2"
+					break
+				fi
+			done
+			if [[ "${version_executable}" != "0" ]]; then
+				for regex in "${PYTHON_NONVERSIONED_EXECUTABLES[@]}"; do
+					if [[ "/${file}" =~ ^${regex}$ ]]; then
+						version_executable="0"
+						break
+					fi
+				done
+			fi
+
+			[[ "${version_executable}" == "0" || ! -x "${file}" ]] && continue
+
+			shebang="$(head -n1 "${file}")" || die "Extraction of shebang from '${file}' failed"
+
+			if [[ "${version_executable}" == "2" ]]; then
+				wrapper_scripts+=("${ED}${file}")
+			elif [[ "${version_executable}" == "1" ]]; then
+				if [[ "${shebang}" =~ ${_PYTHON_SHEBANG_BASE_PART_REGEX}([[:digit:]]+(\.[[:digit:]]+)?)?($|[[:space:]]+) ]]; then
+					wrapper_scripts+=("${ED}${file}")
+				else
+					version_executable="0"
+				fi
+			fi
+
+			[[ "${version_executable}" == "0" ]] && continue
+
+			if [[ -e "${file}-${PYTHON_ABI}" ]]; then
+				die "${FUNCNAME}(): '${EPREFIX}/${file}-${PYTHON_ABI}' already exists"
+			fi
+
+			mv "${file}" "${file}-${PYTHON_ABI}" || die "Renaming of '${file}' failed"
+
+			if [[ "${shebang}" =~ ${_PYTHON_SHEBANG_BASE_PART_REGEX}[[:digit:]]*($|[[:space:]]+) ]]; then
+				python_convert_shebangs $([[ "${quiet}" == "1" ]] && echo --quiet) "${PYTHON_ABI}" "${file}-${PYTHON_ABI}"
+			fi
+		done
+
+		popd > /dev/null || die "popd failed"
+
+		cp -fr --preserve=all "${intermediate_installation_images_directory}/${PYTHON_ABI}/"* "${ED}" || die "Merging of intermediate installation image for Python ABI '${PYTHON_ABI} into installation image failed"
+	done
+
+	if [[ "${#wrapper_scripts[@]}" -ge 1 ]]; then
+		rm -f "${T}/python_wrapper_scripts"
+
+		for file in "${wrapper_scripts[@]}"; do
+			echo -n "${file}" >> "${T}/python_wrapper_scripts"
+			echo -en "\x00" >> "${T}/python_wrapper_scripts"
+		done
+
+		while read -d $'\0' -r file; do
+			wrapper_scripts_set+=("${file}")
+		done < <("$(PYTHON -f)" -c \
+"import sys
+
+if hasattr(sys.stdout, 'buffer'):
+	# Python 3
+	stdout = sys.stdout.buffer
+else:
+	# Python 2
+	stdout = sys.stdout
+
+files = set(open('${T}/python_wrapper_scripts', 'rb').read().rstrip(${b}'\x00').split(${b}'\x00'))
+
+for file in sorted(files):
+	stdout.write(file)
+	stdout.write(${b}'\x00')" || die "${FUNCNAME}(): Failure of extraction of set of wrapper scripts")
+
+		python_generate_wrapper_scripts $([[ "${quiet}" == "1" ]] && echo --quiet) "${wrapper_scripts_set[@]}"
+	fi
+}
+
 # ================================================================================================
 # ========= FUNCTIONS FOR PACKAGES NOT SUPPORTING INSTALLATION FOR MULTIPLE PYTHON ABIS ==========
 # ================================================================================================
@@ -1257,9 +1489,12 @@
 unset EPYTHON PYTHON_ABI
 
 # @FUNCTION: python_set_active_version
-# @USAGE: <CPython_ABI|2|3>
+# @USAGE: <Python_ABI|2|3>
 # @DESCRIPTION:
-# Set specified version of CPython as active version of Python.
+# Set locally active version of Python.
+# If Python_ABI argument is specified, then version of Python corresponding to Python_ABI is used.
+# If 2 argument is specified, then active version of CPython 2 is used.
+# If 3 argument is specified, then active version of CPython 3 is used.
 #
 # This function can be used only in pkg_setup() phase.
 python_set_active_version() {
@@ -1277,9 +1512,12 @@
 	_python_initial_sanity_checks
 
 	if [[ -z "${PYTHON_ABI}" ]]; then
-		if [[ "$1" =~ ^[[:digit:]]+\.[[:digit:]]+$ ]]; then
-			if ! _python_implementation && ! has_version "dev-lang/python:$1"; then
-				die "${FUNCNAME}(): 'dev-lang/python:$1' is not installed"
+		if [[ -n "$(_python_get_implementation --ignore-invalid "$1")" ]]; then
+			# PYTHON_ABI variable is intended to be used only in ebuilds/eclasses,
+			# so it does not need to be exported to subprocesses.
+			PYTHON_ABI="$1"
+			if ! _python_implementation && ! has_version "$(python_get_implementational_package)"; then
+				die "${FUNCNAME}(): '$(python_get_implementational_package)' is not installed"
 			fi
 			export EPYTHON="$(PYTHON "$1")"
 		elif [[ "$1" == "2" ]]; then
@@ -1287,19 +1525,18 @@
 				die "${FUNCNAME}(): '=dev-lang/python-2*' is not installed"
 			fi
 			export EPYTHON="$(PYTHON -2)"
+			PYTHON_ABI="${EPYTHON#python}"
+			PYTHON_ABI="${PYTHON_ABI%%-*}"
 		elif [[ "$1" == "3" ]]; then
 			if ! _python_implementation && ! has_version "=dev-lang/python-3*"; then
 				die "${FUNCNAME}(): '=dev-lang/python-3*' is not installed"
 			fi
 			export EPYTHON="$(PYTHON -3)"
+			PYTHON_ABI="${EPYTHON#python}"
+			PYTHON_ABI="${PYTHON_ABI%%-*}"
 		else
 			die "${FUNCNAME}(): Unrecognized argument '$1'"
 		fi
-
-		# PYTHON_ABI variable is intended to be used only in ebuilds/eclasses,
-		# so it does not need to be exported to subprocesses.
-		PYTHON_ABI="${EPYTHON#python}"
-		PYTHON_ABI="${PYTHON_ABI%%-*}"
 	fi
 
 	_python_final_sanity_checks
@@ -1336,6 +1573,27 @@
 	sys.stdout.write("-jython")'
 
 _python_get_implementation() {
+	local ignore_invalid="0"
+
+	while (($#)); do
+		case "$1" in
+			--ignore-invalid)
+				ignore_invalid="1"
+				;;
+			--)
+				shift
+				break
+				;;
+			-*)
+				die "${FUNCNAME}(): Unrecognized option '$1'"
+				;;
+			*)
+				break
+				;;
+		esac
+		shift
+	done
+
 	if [[ "$#" -ne 1 ]]; then
 		die "${FUNCNAME}() requires 1 argument"
 	fi
@@ -1345,7 +1603,9 @@
 	elif [[ "$1" =~ ^[[:digit:]]+\.[[:digit:]]+-jython$ ]]; then
 		echo "Jython"
 	else
-		die "${FUNCNAME}(): Unrecognized Python ABI '$1'"
+		if [[ "${ignore_invalid}" == "0" ]]; then
+			die "${FUNCNAME}(): Unrecognized Python ABI '$1'"
+		fi
 	fi
 }
 
@@ -1354,8 +1614,8 @@
 # @DESCRIPTION:
 # Print filename of Python interpreter for specified Python ABI. If Python_ABI argument
 # is ommitted, then PYTHON_ABI environment variable must be set and is used.
-# If -2 option is specified, then active version of Python 2 is used.
-# If -3 option is specified, then active version of Python 3 is used.
+# If -2 option is specified, then active version of CPython 2 is used.
+# If -3 option is specified, then active version of CPython 3 is used.
 # If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
 # -2, -3 and --final-ABI options and Python_ABI argument cannot be specified simultaneously.
 # If --ABI option is specified, then only specified Python ABI is printed instead of
@@ -1416,14 +1676,14 @@
 		elif [[ "${python2}" == "1" ]]; then
 			PYTHON_ABI="$(eselect python show --python2 --ABI)"
 			if [[ -z "${PYTHON_ABI}" ]]; then
-				die "${FUNCNAME}(): Active version of Python 2 not set"
+				die "${FUNCNAME}(): Active version of CPython 2 not set"
 			elif [[ "${PYTHON_ABI}" != "2."* ]]; then
 				die "${FUNCNAME}(): Internal error in \`eselect python show --python2\`"
 			fi
 		elif [[ "${python3}" == "1" ]]; then
 			PYTHON_ABI="$(eselect python show --python3 --ABI)"
 			if [[ -z "${PYTHON_ABI}" ]]; then
-				die "${FUNCNAME}(): Active version of Python 3 not set"
+				die "${FUNCNAME}(): Active version of CPython 3 not set"
 			elif [[ "${PYTHON_ABI}" != "3."* ]]; then
 				die "${FUNCNAME}(): Internal error in \`eselect python show --python3\`"
 			fi
@@ -1459,7 +1719,7 @@
 		if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
 			python_interpreter="python${PYTHON_ABI}"
 		elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
-			python_interpreter="jython-${PYTHON_ABI%-jython}"
+			python_interpreter="jython${PYTHON_ABI%-jython}"
 		fi
 
 		if [[ "${absolute_path_output}" == "1" ]]; then
@@ -2176,7 +2436,7 @@
 					base_module_name="${base_module_name%\$py.class}"
 					py_file="${compiled_file%__pycache__/*}${base_module_name}.py"
 				else
-					py_file="${compiled_file%\$py.class}"
+					py_file="${compiled_file%\$py.class}.py"
 				fi
 				if [[ "${EBUILD_PHASE}" == "postinst" ]]; then
 					[[ -f "${py_file}" && "${compiled_file}" -nt "${py_file}" ]] && continue






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2010-12-26 11:30 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2010-12-26 11:30 UTC (permalink / raw
  To: gentoo-commits

arfrever    10/12/26 11:30:27

  Modified:             python.eclass
  Log:
  Allow using of python_merge_intermediate_installation_images() multiple times.

Revision  Changes    Path
1.107                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.107&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.107&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.106&r2=1.107

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.106
retrieving revision 1.107
diff -u -r1.106 -r1.107
--- python.eclass	24 Dec 2010 15:01:09 -0000	1.106
+++ python.eclass	26 Dec 2010 11:30:27 -0000	1.107
@@ -1,6 +1,6 @@
 # Copyright 1999-2010 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.106 2010/12/24 15:01:09 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.107 2010/12/26 11:30:27 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -1452,6 +1452,8 @@
 		cp -fr --preserve=all "${intermediate_installation_images_directory}/${PYTHON_ABI}/"* "${ED}" || die "Merging of intermediate installation image for Python ABI '${PYTHON_ABI} into installation image failed"
 	done
 
+	rm -fr "${intermediate_installation_images_directory}"
+
 	if [[ "${#wrapper_scripts[@]}" -ge 1 ]]; then
 		rm -f "${T}/python_wrapper_scripts"
 






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2010-12-31 21:51 Jonathan Callen (abcd)
  0 siblings, 0 replies; 108+ messages in thread
From: Jonathan Callen (abcd) @ 2010-12-31 21:51 UTC (permalink / raw
  To: gentoo-commits

abcd        10/12/31 21:51:41

  Modified:             python.eclass
  Log:
  Fix handling of EPREFIX in python_merge_intermediate_installation_images()

Revision  Changes    Path
1.108                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.108&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.108&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.107&r2=1.108

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.107
retrieving revision 1.108
diff -u -r1.107 -r1.108
--- python.eclass	26 Dec 2010 11:30:27 -0000	1.107
+++ python.eclass	31 Dec 2010 21:51:41 -0000	1.108
@@ -1,6 +1,6 @@
 # Copyright 1999-2010 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.107 2010/12/26 11:30:27 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.108 2010/12/31 21:51:41 abcd Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -1449,7 +1449,7 @@
 
 		popd > /dev/null || die "popd failed"
 
-		cp -fr --preserve=all "${intermediate_installation_images_directory}/${PYTHON_ABI}/"* "${ED}" || die "Merging of intermediate installation image for Python ABI '${PYTHON_ABI} into installation image failed"
+		cp -fr --preserve=all "${intermediate_installation_images_directory}/${PYTHON_ABI}/"* "${D}" || die "Merging of intermediate installation image for Python ABI '${PYTHON_ABI} into installation image failed"
 	done
 
 	rm -fr "${intermediate_installation_images_directory}"






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2011-02-14 20:46 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2011-02-14 20:46 UTC (permalink / raw
  To: gentoo-commits

arfrever    11/02/14 20:46:52

  Modified:             python.eclass
  Log:
  Fix support for non-GNU cp in python_merge_intermediate_installation_images() (bug #352406).

Revision  Changes    Path
1.109                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.109&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.109&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.108&r2=1.109

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.108
retrieving revision 1.109
diff -u -r1.108 -r1.109
--- python.eclass	31 Dec 2010 21:51:41 -0000	1.108
+++ python.eclass	14 Feb 2011 20:46:52 -0000	1.109
@@ -1,6 +1,6 @@
-# Copyright 1999-2010 Gentoo Foundation
+# Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.108 2010/12/31 21:51:41 abcd Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.109 2011/02/14 20:46:52 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -1449,7 +1449,11 @@
 
 		popd > /dev/null || die "popd failed"
 
-		cp -fr --preserve=all "${intermediate_installation_images_directory}/${PYTHON_ABI}/"* "${D}" || die "Merging of intermediate installation image for Python ABI '${PYTHON_ABI} into installation image failed"
+		if ROOT="/" has_version sys-apps/coreutils; then
+			cp -fr --preserve=all "${intermediate_installation_images_directory}/${PYTHON_ABI}/"* "${D}" || die "Merging of intermediate installation image for Python ABI '${PYTHON_ABI} into installation image failed"
+		else
+			cp -fpr "${intermediate_installation_images_directory}/${PYTHON_ABI}/"* "${D}" || die "Merging of intermediate installation image for Python ABI '${PYTHON_ABI} into installation image failed"
+		fi
 	done
 
 	rm -fr "${intermediate_installation_images_directory}"






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2011-03-10 17:49 Arfrever Frehtes Taifersar Arahesis (arfrever)
  0 siblings, 0 replies; 108+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis (arfrever) @ 2011-03-10 17:49 UTC (permalink / raw
  To: gentoo-commits

arfrever    11/03/10 17:49:49

  Modified:             python.eclass
  Log:
  Support 3.3 Python ABI.
  Update EAPI checks.

Revision  Changes    Path
1.110                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.110&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.110&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.109&r2=1.110

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.109
retrieving revision 1.110
diff -u -r1.109 -r1.110
--- python.eclass	14 Feb 2011 20:46:52 -0000	1.109
+++ python.eclass	10 Mar 2011 17:49:49 -0000	1.110
@@ -1,6 +1,6 @@
 # Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.109 2011/02/14 20:46:52 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.110 2011/03/10 17:49:49 arfrever Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -16,7 +16,7 @@
 fi
 
 _CPYTHON2_GLOBALLY_SUPPORTED_ABIS=(2.4 2.5 2.6 2.7)
-_CPYTHON3_GLOBALLY_SUPPORTED_ABIS=(3.0 3.1 3.2)
+_CPYTHON3_GLOBALLY_SUPPORTED_ABIS=(3.0 3.1 3.2 3.3)
 _JYTHON_GLOBALLY_SUPPORTED_ABIS=(2.5-jython)
 _PYTHON_GLOBALLY_SUPPORTED_ABIS=(${_CPYTHON2_GLOBALLY_SUPPORTED_ABIS[@]} ${_CPYTHON3_GLOBALLY_SUPPORTED_ABIS[@]} ${_JYTHON_GLOBALLY_SUPPORTED_ABIS[@]})
 
@@ -620,7 +620,7 @@
 	fi
 fi
 
-if has "${EAPI:-0}" 0 1 2 3; then
+if has "${EAPI:-0}" 0 1 2 3 4; then
 	unset PYTHON_ABIS
 fi
 
@@ -631,7 +631,7 @@
 
 	_python_initial_sanity_checks
 
-	if [[ "$(declare -p PYTHON_ABIS 2> /dev/null)" != "declare -x PYTHON_ABIS="* ]] && has "${EAPI:-0}" 0 1 2 3; then
+	if [[ "$(declare -p PYTHON_ABIS 2> /dev/null)" != "declare -x PYTHON_ABIS="* ]] && has "${EAPI:-0}" 0 1 2 3 4; then
 		local PYTHON_ABI restricted_ABI restricted_ABIs support_ABI supported_PYTHON_ABIS
 
 		restricted_ABIs="${RESTRICT_PYTHON_ABIS// /$'\n'}"






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2011-07-04 10:48 Dirkjan Ochtman (djc)
  0 siblings, 0 replies; 108+ messages in thread
From: Dirkjan Ochtman (djc) @ 2011-07-04 10:48 UTC (permalink / raw
  To: gentoo-commits

djc         11/07/04 10:48:01

  Modified:             python.eclass
  Log:
  Delete python_version(), python_mod_exists(), python_tkinter_exists() and
  python_mod_compile(). (Patch by Arfrever. Backported from python overlay.)

Revision  Changes    Path
1.111                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.111&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.111&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.110&r2=1.111

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.110
retrieving revision 1.111
diff -u -r1.110 -r1.111
--- python.eclass	10 Mar 2011 17:49:49 -0000	1.110
+++ python.eclass	4 Jul 2011 10:48:01 -0000	1.111
@@ -1,6 +1,6 @@
 # Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.110 2011/03/10 17:49:49 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.111 2011/07/04 10:48:01 djc Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -2833,27 +2833,3 @@
 # ================================================================================================
 # ===================================== DEPRECATED FUNCTIONS =====================================
 # ================================================================================================
-
-# Scheduled for deletion on 2011-01-01.
-python_version() {
-	eerror "Use PYTHON() instead of python variable. Use python_get_*() instead of PYVER* variables."
-	die "${FUNCNAME}() is banned"
-}
-
-# Scheduled for deletion on 2011-01-01.
-python_mod_exists() {
-	eerror "Use USE dependencies and/or has_version() instead of ${FUNCNAME}()."
-	die "${FUNCNAME}() is banned"
-}
-
-# Scheduled for deletion on 2011-01-01.
-python_tkinter_exists() {
-	eerror "Use PYTHON_USE_WITH=\"xml\" and python_pkg_setup() instead of ${FUNCNAME}()."
-	die "${FUNCNAME}() is banned"
-}
-
-# Scheduled for deletion on 2011-04-01.
-python_mod_compile() {
-	eerror "Use python_mod_optimize() instead of ${FUNCNAME}()."
-	die "${FUNCNAME}() is banned"
-}






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2011-07-04 10:50 Dirkjan Ochtman (djc)
  0 siblings, 0 replies; 108+ messages in thread
From: Dirkjan Ochtman (djc) @ 2011-07-04 10:50 UTC (permalink / raw
  To: gentoo-commits

djc         11/07/04 10:50:28

  Modified:             python.eclass
  Log:
  Print deprecation warnings in deprecated parts of python_mod_optimize() and
  python_mod_cleanup(). (Patch by Arfrever. Backported from python overlay.)

Revision  Changes    Path
1.112                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.112&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.112&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.111&r2=1.112

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.111
retrieving revision 1.112
diff -u -r1.111 -r1.112
--- python.eclass	4 Jul 2011 10:48:01 -0000	1.111
+++ python.eclass	4 Jul 2011 10:50:28 -0000	1.112
@@ -1,6 +1,6 @@
 # Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.111 2011/07/04 10:48:01 djc Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.112 2011/07/04 10:50:28 djc Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -2652,12 +2652,12 @@
 		fi
 	else
 		# Deprecated part of python_mod_optimize()
-		# ewarn
-		# ewarn "Deprecation Warning: Usage of ${FUNCNAME}() in packages not supporting installation"
-		# ewarn "for multiple Python ABIs in EAPI <=2 is deprecated and will be disallowed on 2011-06-01."
-		# ewarn "Use EAPI >=3 and call ${FUNCNAME}() with paths having appropriate syntax."
-		# ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported."
-		# ewarn
+		ewarn
+		ewarn "Deprecation Warning: Usage of ${FUNCNAME}() in packages not supporting installation"
+		ewarn "for multiple Python ABIs in EAPI <=2 is deprecated and will be disallowed on 2011-08-01."
+		ewarn "Use EAPI >=3 and call ${FUNCNAME}() with paths having appropriate syntax."
+		ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported."
+		ewarn
 
 		local myroot mydirs=() myfiles=() myopts=() return_code="0"
 
@@ -2816,12 +2816,12 @@
 		done
 	else
 		# Deprecated part of python_mod_cleanup()
-		# ewarn
-		# ewarn "Deprecation Warning: Usage of ${FUNCNAME}() in packages not supporting installation"
-		# ewarn "for multiple Python ABIs in EAPI <=2 is deprecated and will be disallowed on 2011-06-01."
-		# ewarn "Use EAPI >=3 and call ${FUNCNAME}() with paths having appropriate syntax."
-		# ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported."
-		# ewarn
+		ewarn
+		ewarn "Deprecation Warning: Usage of ${FUNCNAME}() in packages not supporting installation"
+		ewarn "for multiple Python ABIs in EAPI <=2 is deprecated and will be disallowed on 2011-08-01."
+		ewarn "Use EAPI >=3 and call ${FUNCNAME}() with paths having appropriate syntax."
+		ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported."
+		ewarn
 
 		search_paths=("${@#/}")
 		search_paths=("${search_paths[@]/#/${root}/}")






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2011-07-04 10:59 Dirkjan Ochtman (djc)
  0 siblings, 0 replies; 108+ messages in thread
From: Dirkjan Ochtman (djc) @ 2011-07-04 10:59 UTC (permalink / raw
  To: gentoo-commits

djc         11/07/04 10:59:26

  Modified:             python.eclass
  Log:
  Support EAPI >=4 in python_src_install().
  (Patch by Arfrever. Backported from python overlay.)

Revision  Changes    Path
1.113                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.113&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.113&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.112&r2=1.113

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.112
retrieving revision 1.113
diff -u -r1.112 -r1.113
--- python.eclass	4 Jul 2011 10:50:28 -0000	1.112
+++ python.eclass	4 Jul 2011 10:59:25 -0000	1.113
@@ -1,6 +1,6 @@
 # Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.112 2011/07/04 10:50:28 djc Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.113 2011/07/04 10:59:25 djc Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -602,7 +602,7 @@
 		python_copy_sources
 	}
 
-	for python_default_function in src_configure src_compile src_test src_install; do
+	for python_default_function in src_configure src_compile src_test; do
 		eval "python_${python_default_function}() {
 			_python_check_python_pkg_setup_execution
 
@@ -615,6 +615,26 @@
 	done
 	unset python_default_function
 
+	python_src_install() {
+		if ! _python_package_supporting_installation_for_multiple_python_abis; then
+			die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
+		fi
+
+		_python_check_python_pkg_setup_execution
+
+		if has "${EAPI:-0}" 0 1 2 3; then
+			python_execute_function -d -s -- "$@"
+		else
+			python_installation() {
+				emake DESTDIR="${T}/images/${PYTHON_ABI}" install "$@"
+			}
+			python_execute_function -s python_installation "$@"
+			unset python_installation
+
+			python_merge_intermediate_installation_images "${T}/images"
+		fi
+	}
+
 	if [[ -n "${PYTHON_EXPORT_PHASE_FUNCTIONS}" ]]; then
 		EXPORT_FUNCTIONS src_prepare src_configure src_compile src_test src_install
 	fi






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2011-07-04 11:00 Dirkjan Ochtman (djc)
  0 siblings, 0 replies; 108+ messages in thread
From: Dirkjan Ochtman (djc) @ 2011-07-04 11:00 UTC (permalink / raw
  To: gentoo-commits

djc         11/07/04 11:00:52

  Modified:             python.eclass
  Log:
  Fix coding style in some functions for consistency with other functions.
  (Patch by Arfrever. Backported from python overlay.)

Revision  Changes    Path
1.114                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.114&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.114&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.113&r2=1.114

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.113
retrieving revision 1.114
diff -u -r1.113 -r1.114
--- python.eclass	4 Jul 2011 10:59:25 -0000	1.113
+++ python.eclass	4 Jul 2011 11:00:52 -0000	1.114
@@ -1,6 +1,6 @@
 # Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.113 2011/07/04 10:59:25 djc Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.114 2011/07/04 11:00:52 djc Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -360,11 +360,10 @@
 #
 # This function is exported in EAPI 2 and 3 when PYTHON_USE_WITH or PYTHON_USE_WITH_OR variable
 # is set and always in EAPI >=4. Calling of this function is mandatory in EAPI >=4.
-#
-# This function can be used only in pkg_setup() phase.
 python_pkg_setup() {
-	# Check if phase is pkg_setup().
-	[[ "${EBUILD_PHASE}" != "setup" ]] && die "${FUNCNAME}() can be used only in pkg_setup() phase"
+	if [[ "${EBUILD_PHASE}" != "setup" ]]; then
+		die "${FUNCNAME}() can be used only in pkg_setup() phase"
+	fi
 
 	if [[ "$#" -ne 0 ]]; then
 		die "${FUNCNAME}() does not accept arguments"
@@ -515,15 +514,18 @@
 # @USAGE: [-q|--quiet]
 # @DESCRIPTION:
 # Delete needless files in installation image.
+#
+# This function can be used only in src_install() phase.
 python_clean_installation_image() {
+	if [[ "${EBUILD_PHASE}" != "install" ]]; then
+		die "${FUNCNAME}() can be used only in src_install() phase"
+	fi
+
 	_python_check_python_pkg_setup_execution
 	_python_initialize_prefix_variables
 
 	local file files=() quiet="0"
 
-	# Check if phase is src_install().
-	[[ "${EBUILD_PHASE}" != "install" ]] && die "${FUNCNAME}() can be used only in src_install() phase"
-
 	while (($#)); do
 		case "$1" in
 			-q|--quiet)
@@ -586,15 +588,19 @@
 # @ECLASS-VARIABLE: PYTHON_EXPORT_PHASE_FUNCTIONS
 # @DESCRIPTION:
 # Set this to export phase functions for the following ebuild phases:
-# src_prepare, src_configure, src_compile, src_test, src_install.
+# src_prepare(), src_configure(), src_compile(), src_test(), src_install().
 if ! has "${EAPI:-0}" 0 1; then
 	python_src_prepare() {
-		_python_check_python_pkg_setup_execution
+		if [[ "${EBUILD_PHASE}" != "prepare" ]]; then
+			die "${FUNCNAME}() can be used only in src_prepare() phase"
+		fi
 
 		if ! _python_package_supporting_installation_for_multiple_python_abis; then
 			die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
 		fi
 
+		_python_check_python_pkg_setup_execution
+
 		if [[ "$#" -ne 0 ]]; then
 			die "${FUNCNAME}() does not accept arguments"
 		fi
@@ -604,18 +610,26 @@
 
 	for python_default_function in src_configure src_compile src_test; do
 		eval "python_${python_default_function}() {
-			_python_check_python_pkg_setup_execution
+			if [[ \"\${EBUILD_PHASE}\" != \"${python_default_function#src_}\" ]]; then
+				die \"\${FUNCNAME}() can be used only in ${python_default_function}() phase\"
+			fi
 
 			if ! _python_package_supporting_installation_for_multiple_python_abis; then
 				die \"\${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs\"
 			fi
 
+			_python_check_python_pkg_setup_execution
+
 			python_execute_function -d -s -- \"\$@\"
 		}"
 	done
 	unset python_default_function
 
 	python_src_install() {
+		if [[ "${EBUILD_PHASE}" != "install" ]]; then
+			die "${FUNCNAME}() can be used only in src_install() phase"
+		fi
+
 		if ! _python_package_supporting_installation_for_multiple_python_abis; then
 			die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
 		fi
@@ -690,7 +704,7 @@
 				die "USE_PYTHON variable does not enable any CPython ABI"
 			fi
 		else
-			local python_version python2_version= python3_version= support_python_major_version
+			local python_version python2_version python3_version support_python_major_version
 
 			if ! has_version "dev-lang/python"; then
 				die "${FUNCNAME}(): 'dev-lang/python' is not installed"
@@ -830,15 +844,14 @@
 # Execute specified function for each value of PYTHON_ABIS, optionally passing additional
 # arguments. The specified function can use PYTHON_ABI and BUILDDIR variables.
 python_execute_function() {
-	_python_check_python_pkg_setup_execution
-
 	if ! _python_package_supporting_installation_for_multiple_python_abis; then
 		die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
 	fi
 
+	_python_check_python_pkg_setup_execution
 	_python_set_color_variables
 
-	local action action_message action_message_template= default_function="0" failure_message failure_message_template= final_ABI="0" function iterated_PYTHON_ABIS nonfatal="0" previous_directory previous_directory_stack previous_directory_stack_length PYTHON_ABI quiet="0" return_code separate_build_dirs="0" source_dir=
+	local action action_message action_message_template default_function="0" failure_message failure_message_template final_ABI="0" function iterated_PYTHON_ABIS nonfatal="0" previous_directory previous_directory_stack previous_directory_stack_length PYTHON_ABI quiet="0" return_code separate_build_dirs="0" source_dir
 
 	while (($#)); do
 		case "$1" in
@@ -1063,12 +1076,12 @@
 # @DESCRIPTION:
 # Copy unpacked sources of current package to separate build directory for each Python ABI.
 python_copy_sources() {
-	_python_check_python_pkg_setup_execution
-
 	if ! _python_package_supporting_installation_for_multiple_python_abis; then
 		die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
 	fi
 
+	_python_check_python_pkg_setup_execution
+
 	local dir dirs=() PYTHON_ABI
 
 	if [[ "$#" -eq 0 ]]; then
@@ -1094,13 +1107,18 @@
 # Generate wrapper scripts. Existing files are overwritten only with --force option.
 # If --respect-EPYTHON option is specified, then generated wrapper scripts will
 # respect EPYTHON variable at run time.
+#
+# This function can be used only in src_install() phase.
 python_generate_wrapper_scripts() {
-	_python_check_python_pkg_setup_execution
+	if [[ "${EBUILD_PHASE}" != "install" ]]; then
+		die "${FUNCNAME}() can be used only in src_install() phase"
+	fi
 
 	if ! _python_package_supporting_installation_for_multiple_python_abis; then
 		die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
 	fi
 
+	_python_check_python_pkg_setup_execution
 	_python_initialize_prefix_variables
 
 	local eselect_python_option file force="0" quiet="0" PYTHON_ABI PYTHON_ABIS_list python2_enabled="0" python3_enabled="0" respect_EPYTHON="0"
@@ -1341,15 +1359,22 @@
 # @USAGE: [-q|--quiet] [--] <intermediate_installation_images_directory>
 # @DESCRIPTION:
 # Merge intermediate installation images into installation image.
+#
+# This function can be used only in src_install() phase.
 python_merge_intermediate_installation_images() {
+	if [[ "${EBUILD_PHASE}" != "install" ]]; then
+		die "${FUNCNAME}() can be used only in src_install() phase"
+	fi
+
+	if ! _python_package_supporting_installation_for_multiple_python_abis; then
+		die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
+	fi
+
 	_python_check_python_pkg_setup_execution
 	_python_initialize_prefix_variables
 
 	local b file files=() intermediate_installation_images_directory PYTHON_ABI quiet="0" regex shebang version_executable wrapper_scripts=() wrapper_scripts_set=()
 
-	# Check if phase is src_install().
-	[[ "${EBUILD_PHASE}" != "install" ]] && die "${FUNCNAME}() can be used only in src_install() phase"
-
 	while (($#)); do
 		case "$1" in
 			-q|--quiet)
@@ -1524,8 +1549,9 @@
 #
 # This function can be used only in pkg_setup() phase.
 python_set_active_version() {
-	# Check if phase is pkg_setup().
-	[[ "${EBUILD_PHASE}" != "setup" ]] && die "${FUNCNAME}() can be used only in pkg_setup() phase"
+	if [[ "${EBUILD_PHASE}" != "setup" ]]; then
+		die "${FUNCNAME}() can be used only in pkg_setup() phase"
+	fi
 
 	if _python_package_supporting_installation_for_multiple_python_abis; then
 		die "${FUNCNAME}() cannot be used in ebuilds of packages supporting installation for multiple Python ABIs"
@@ -1575,12 +1601,12 @@
 # @DESCRIPTION: Mark current package for rebuilding by python-updater after
 # switching of active version of Python.
 python_need_rebuild() {
-	_python_check_python_pkg_setup_execution
-
 	if _python_package_supporting_installation_for_multiple_python_abis; then
 		die "${FUNCNAME}() cannot be used in ebuilds of packages supporting installation for multiple Python ABIs"
 	fi
 
+	_python_check_python_pkg_setup_execution
+
 	if [[ "$#" -ne 0 ]]; then
 		die "${FUNCNAME}() does not accept arguments"
 	fi
@@ -2184,7 +2210,7 @@
 	_python_check_python_pkg_setup_execution
 	_python_set_color_variables
 
-	local PYTHONPATH_template= separate_build_dirs=
+	local PYTHONPATH_template separate_build_dirs
 
 	while (($#)); do
 		case "$1" in
@@ -2248,7 +2274,7 @@
 	_python_check_python_pkg_setup_execution
 	_python_set_color_variables
 
-	local PYTHONPATH_template= separate_build_dirs=
+	local PYTHONPATH_template separate_build_dirs
 
 	while (($#)); do
 		case "$1" in
@@ -2312,7 +2338,7 @@
 	_python_check_python_pkg_setup_execution
 	_python_set_color_variables
 
-	local PYTHONPATH_template= separate_build_dirs=
+	local PYTHONPATH_template separate_build_dirs
 
 	while (($#)); do
 		case "$1" in
@@ -2497,12 +2523,13 @@
 #
 # This function can be used only in pkg_postinst() phase.
 python_mod_optimize() {
+	if [[ "${EBUILD_PHASE}" != "postinst" ]]; then
+		die "${FUNCNAME}() can be used only in pkg_postinst() phase"
+	fi
+
 	_python_check_python_pkg_setup_execution
 	_python_initialize_prefix_variables
 
-	# Check if phase is pkg_postinst().
-	[[ "${EBUILD_PHASE}" != "postinst" ]] && die "${FUNCNAME}() can be used only in pkg_postinst() phase"
-
 	if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis || _python_implementation || [[ "${CATEGORY}/${PN}" == "sys-apps/portage" ]]; then
 		# PYTHON_ABI variable cannot be local in packages not supporting installation for multiple Python ABIs.
 		local allow_evaluated_non_sitedir_paths="0" dir dirs=() evaluated_dirs=() evaluated_files=() file files=() iterated_PYTHON_ABIS options=() other_dirs=() other_files=() previous_PYTHON_ABI="${PYTHON_ABI}" return_code root site_packages_dirs=() site_packages_files=()
@@ -2756,14 +2783,15 @@
 #
 # This function can be used only in pkg_postrm() phase.
 python_mod_cleanup() {
+	if [[ "${EBUILD_PHASE}" != "postrm" ]]; then
+		die "${FUNCNAME}() can be used only in pkg_postrm() phase"
+	fi
+
 	_python_check_python_pkg_setup_execution
 	_python_initialize_prefix_variables
 
 	local allow_evaluated_non_sitedir_paths="0" dir iterated_PYTHON_ABIS PYTHON_ABI="${PYTHON_ABI}" root search_paths=() sitedir
 
-	# Check if phase is pkg_postrm().
-	[[ "${EBUILD_PHASE}" != "postrm" ]] && die "${FUNCNAME}() can be used only in pkg_postrm() phase"
-
 	if _python_package_supporting_installation_for_multiple_python_abis; then
 		if has "${EAPI:-0}" 0 1 2 3 && [[ -z "${PYTHON_ABIS}" ]]; then
 			die "${FUNCNAME}(): python_pkg_setup() or python_execute_function() not called"






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2011-07-04 11:27 Dirkjan Ochtman (djc)
  0 siblings, 0 replies; 108+ messages in thread
From: Dirkjan Ochtman (djc) @ 2011-07-04 11:27 UTC (permalink / raw
  To: gentoo-commits

djc         11/07/04 11:27:29

  Modified:             python.eclass
  Log:
  Support Python ABI patterns list in _python_check_python_abi_matching.
  (Patch by Arfrever. Backported from python overlay.)

Revision  Changes    Path
1.115                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.115&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.115&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.114&r2=1.115

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.114
retrieving revision 1.115
diff -u -r1.114 -r1.115
--- python.eclass	4 Jul 2011 11:00:52 -0000	1.114
+++ python.eclass	4 Jul 2011 11:27:29 -0000	1.115
@@ -1,6 +1,6 @@
 # Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.114 2011/07/04 11:00:52 djc Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.115 2011/07/04 11:27:29 djc Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -25,22 +25,59 @@
 # ================================================================================================
 
 _python_check_python_abi_matching() {
+	local pattern patterns patterns_list="0" PYTHON_ABI
+
+	while (($#)); do
+		case "$1" in
+			--patterns-list)
+				patterns_list="1"
+				;;
+			--)
+				shift
+				break
+				;;
+			-*)
+				die "${FUNCNAME}(): Unrecognized option '$1'"
+				;;
+			*)
+				break
+				;;
+		esac
+		shift
+	done
+
 	if [[ "$#" -ne 2 ]]; then
 		die "${FUNCNAME}() requires 2 arguments"
 	fi
 
-	if [[ "$2" == *"-cpython" ]]; then
-		[[ "$1" =~ ^[[:digit:]]+\.[[:digit:]]+$ && "$1" == ${2%-cpython} ]]
-	elif [[ "$2" == *"-jython" ]]; then
-		[[ "$1" == $2 ]]
-	else
-		if [[ "$1" =~ ^[[:digit:]]+\.[[:digit:]]+$ ]]; then
-			[[ "$1" == $2 ]]
-		elif [[ "$1" =~ ^[[:digit:]]+\.[[:digit:]]+-jython$ ]]; then
-			[[ "${1%-jython}" == $2 ]]
-		else
-			die "${FUNCNAME}(): Unrecognized Python ABI '$1'"
+	PYTHON_ABI="$1"
+
+	if [[ "${patterns_list}" == "0" ]]; then
+		pattern="$2"
+
+		if [[ "${pattern}" == *"-cpython" ]]; then
+			[[ "${PYTHON_ABI}" =~ ^[[:digit:]]+\.[[:digit:]]+$ && "${PYTHON_ABI}" == ${pattern%-cpython} ]]
+		elif [[ "${pattern}" == *"-jython" ]]; then
+			[[ "${PYTHON_ABI}" == ${pattern} ]]
+		else
+			if [[ "${PYTHON_ABI}" =~ ^[[:digit:]]+\.[[:digit:]]+$ ]]; then
+				[[ "${PYTHON_ABI}" == ${pattern} ]]
+			elif [[ "${PYTHON_ABI}" =~ ^[[:digit:]]+\.[[:digit:]]+-jython$ ]]; then
+				[[ "${PYTHON_ABI%-jython}" == ${pattern} ]]
+			else
+				die "${FUNCNAME}(): Unrecognized Python ABI '${PYTHON_ABI}'"
+			fi
 		fi
+	else
+		patterns="${2// /$'\n'}"
+
+		while read pattern; do
+			if _python_check_python_abi_matching "${PYTHON_ABI}" "${pattern}"; then
+				return 0
+			fi
+		done <<< "${patterns}"
+
+		return 1
 	fi
 }
 






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2011-07-04 11:27 Dirkjan Ochtman (djc)
  0 siblings, 0 replies; 108+ messages in thread
From: Dirkjan Ochtman (djc) @ 2011-07-04 11:27 UTC (permalink / raw
  To: gentoo-commits

djc         11/07/04 11:27:53

  Modified:             python.eclass
  Log:
  Support PYTHON_TESTS_RESTRICTED_ABIS.
  (Patch by Arfrever. Backported from python overlay.)

Revision  Changes    Path
1.116                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.116&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.116&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.115&r2=1.116

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.115
retrieving revision 1.116
diff -u -r1.115 -r1.116
--- python.eclass	4 Jul 2011 11:27:29 -0000	1.115
+++ python.eclass	4 Jul 2011 11:27:53 -0000	1.116
@@ -1,6 +1,6 @@
 # Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.115 2011/07/04 11:27:29 djc Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.116 2011/07/04 11:27:53 djc Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -622,6 +622,11 @@
 # Set this in EAPI <= 4 to indicate that current package supports installation for
 # multiple Python ABIs.
 
+# @ECLASS-VARIABLE: PYTHON_TESTS_RESTRICTED_ABIS
+# @DESCRIPTION:
+# Space-separated list of Python ABI patterns. Testing in Python ABIs matching any Python ABI
+# patterns specified in this list is skipped.
+
 # @ECLASS-VARIABLE: PYTHON_EXPORT_PHASE_FUNCTIONS
 # @DESCRIPTION:
 # Set this to export phase functions for the following ebuild phases:
@@ -1010,6 +1015,13 @@
 		iterated_PYTHON_ABIS="${PYTHON_ABIS}"
 	fi
 	for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
+		if [[ "${EBUILD_PHASE}" == "test" ]] && _python_check_python_abi_matching --patterns-list "${PYTHON_ABI}" "${PYTHON_TESTS_RESTRICTED_ABIS}"; then
+			if [[ "${quiet}" == "0" ]]; then
+				echo " ${_GREEN}*${_NORMAL} ${_BLUE}Testing of ${CATEGORY}/${PF} with $(python_get_implementation) $(python_get_version) skipped${_NORMAL}"
+			fi
+			continue
+		fi
+
 		_python_prepare_flags
 
 		if [[ "${quiet}" == "0" ]]; then






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2011-07-04 11:28 Dirkjan Ochtman (djc)
  0 siblings, 0 replies; 108+ messages in thread
From: Dirkjan Ochtman (djc) @ 2011-07-04 11:28 UTC (permalink / raw
  To: gentoo-commits

djc         11/07/04 11:28:25

  Modified:             python.eclass
  Log:
  Pass Python ABI patterns list to _python_check_python_abi_matching() to
  simplify some code. (Patch by Arfrever. Backported from python overlay.)

Revision  Changes    Path
1.117                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.117&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.117&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.116&r2=1.117

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.116
retrieving revision 1.117
diff -u -r1.116 -r1.117
--- python.eclass	4 Jul 2011 11:27:53 -0000	1.116
+++ python.eclass	4 Jul 2011 11:28:24 -0000	1.117
@@ -1,6 +1,6 @@
 # Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.116 2011/07/04 11:27:53 djc Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.117 2011/07/04 11:28:24 djc Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -708,9 +708,7 @@
 	_python_initial_sanity_checks
 
 	if [[ "$(declare -p PYTHON_ABIS 2> /dev/null)" != "declare -x PYTHON_ABIS="* ]] && has "${EAPI:-0}" 0 1 2 3 4; then
-		local PYTHON_ABI restricted_ABI restricted_ABIs support_ABI supported_PYTHON_ABIS
-
-		restricted_ABIs="${RESTRICT_PYTHON_ABIS// /$'\n'}"
+		local PYTHON_ABI
 
 		if [[ "$(declare -p USE_PYTHON 2> /dev/null)" == "declare -x USE_PYTHON="* ]]; then
 			local cpython_enabled="0"
@@ -728,14 +726,9 @@
 					cpython_enabled="1"
 				fi
 
-				support_ABI="1"
-				while read restricted_ABI; do
-					if _python_check_python_abi_matching "${PYTHON_ABI}" "${restricted_ABI}"; then
-						support_ABI="0"
-						break
-					fi
-				done <<< "${restricted_ABIs}"
-				[[ "${support_ABI}" == "1" ]] && export PYTHON_ABIS+="${PYTHON_ABIS:+ }${PYTHON_ABI}"
+				if ! _python_check_python_abi_matching --patterns-list "${PYTHON_ABI}" "${RESTRICT_PYTHON_ABIS}"; then
+					export PYTHON_ABIS+="${PYTHON_ABIS:+ }${PYTHON_ABI}"
+				fi
 			done
 
 			if [[ -z "${PYTHON_ABIS//[${IFS}]/}" ]]; then
@@ -761,21 +754,17 @@
 
 				python2_version="$("${EPREFIX}/usr/bin/python2" -c 'from sys import version_info; print(".".join(str(x) for x in version_info[:2]))')"
 
+				support_python_major_version="0"
 				for PYTHON_ABI in "${_CPYTHON2_GLOBALLY_SUPPORTED_ABIS[@]}"; do
-					support_python_major_version="1"
-					while read restricted_ABI; do
-						if _python_check_python_abi_matching "${PYTHON_ABI}" "${restricted_ABI}"; then
-							support_python_major_version="0"
-						fi
-					done <<< "${restricted_ABIs}"
-					[[ "${support_python_major_version}" == "1" ]] && break
+					if ! _python_check_python_abi_matching --patterns-list "${PYTHON_ABI}" "${RESTRICT_PYTHON_ABIS}"; then
+						support_python_major_version="1"
+						break
+					fi
 				done
 				if [[ "${support_python_major_version}" == "1" ]]; then
-					while read restricted_ABI; do
-						if _python_check_python_abi_matching "${python2_version}" "${restricted_ABI}"; then
-							die "Active version of CPython 2 is not supported by ${CATEGORY}/${PF}"
-						fi
-					done <<< "${restricted_ABIs}"
+					if _python_check_python_abi_matching --patterns-list "${python2_version}" "${RESTRICT_PYTHON_ABIS}"; then
+						die "Active version of CPython 2 is not supported by ${CATEGORY}/${PF}"
+					fi
 				else
 					python2_version=""
 				fi
@@ -788,21 +777,17 @@
 
 				python3_version="$("${EPREFIX}/usr/bin/python3" -c 'from sys import version_info; print(".".join(str(x) for x in version_info[:2]))')"
 
+				support_python_major_version="0"
 				for PYTHON_ABI in "${_CPYTHON3_GLOBALLY_SUPPORTED_ABIS[@]}"; do
-					support_python_major_version="1"
-					while read restricted_ABI; do
-						if _python_check_python_abi_matching "${PYTHON_ABI}" "${restricted_ABI}"; then
-							support_python_major_version="0"
-						fi
-					done <<< "${restricted_ABIs}"
-					[[ "${support_python_major_version}" == "1" ]] && break
+					if ! _python_check_python_abi_matching --patterns-list "${PYTHON_ABI}" "${RESTRICT_PYTHON_ABIS}"; then
+						support_python_major_version="1"
+						break
+					fi
 				done
 				if [[ "${support_python_major_version}" == "1" ]]; then
-					while read restricted_ABI; do
-						if _python_check_python_abi_matching "${python3_version}" "${restricted_ABI}"; then
-							die "Active version of CPython 3 is not supported by ${CATEGORY}/${PF}"
-						fi
-					done <<< "${restricted_ABIs}"
+					if _python_check_python_abi_matching --patterns-list "${python3_version}" "${RESTRICT_PYTHON_ABIS}"; then
+						die "Active version of CPython 3 is not supported by ${CATEGORY}/${PF}"
+					fi
 				else
 					python3_version=""
 				fi






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2011-07-08  7:37 Dirkjan Ochtman (djc)
  0 siblings, 0 replies; 108+ messages in thread
From: Dirkjan Ochtman (djc) @ 2011-07-08  7:37 UTC (permalink / raw
  To: gentoo-commits

djc         11/07/08 07:37:49

  Modified:             python.eclass
  Log:
  Support -l / --language option in python_get_version().
  (Patch by Arfrever. Backported from python overlay.)

Revision  Changes    Path
1.118                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.118&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.118&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.117&r2=1.118

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.117
retrieving revision 1.118
diff -u -r1.117 -r1.118
--- python.eclass	4 Jul 2011 11:28:24 -0000	1.117
+++ python.eclass	8 Jul 2011 07:37:49 -0000	1.118
@@ -1,6 +1,6 @@
 # Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.117 2011/07/04 11:28:24 djc Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.118 2011/07/08 07:37:49 djc Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -2139,22 +2139,28 @@
 }
 
 # @FUNCTION: python_get_version
-# @USAGE: [-f|--final-ABI] [--full] [--major] [--minor] [--micro]
+# @USAGE: [-f|--final-ABI] [-l|--language] [--full] [--major] [--minor] [--micro]
 # @DESCRIPTION:
 # Print Python version.
 # --full, --major, --minor and --micro options cannot be specified simultaneously.
 # If --full, --major, --minor and --micro options are not specified, then "${major_version}.${minor_version}" is printed.
+# If --language option is specified, then Python language version is printed.
+# --language and --full options cannot be specified simultaneously.
+# --language and --micro options cannot be specified simultaneously.
 # If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
 python_get_version() {
 	_python_check_python_pkg_setup_execution
 
-	local final_ABI="0" full="0" major="0" minor="0" micro="0" python_command
+	local final_ABI="0" language="0" language_version full="0" major="0" minor="0" micro="0" PYTHON_ABI="${PYTHON_ABI}" python_command
 
 	while (($#)); do
 		case "$1" in
 			-f|--final-ABI)
 				final_ABI="1"
 				;;
+			-l|--language)
+				language="1"
+				;;
 			--full)
 				full="1"
 				;;
@@ -2177,40 +2183,64 @@
 		shift
 	done
 
-	if [[ "$((${full} + ${major} + ${minor} + ${micro}))" -gt 1 ]]; then
-		die "${FUNCNAME}(): '--full', '--major', '--minor' or '--micro' options cannot be specified simultaneously"
-	fi
-
-	if [[ "${full}" == "1" ]]; then
-		python_command="from sys import version_info; print('.'.join(str(x) for x in version_info[:3]))"
-	elif [[ "${major}" == "1" ]]; then
-		python_command="from sys import version_info; print(version_info[0])"
-	elif [[ "${minor}" == "1" ]]; then
-		python_command="from sys import version_info; print(version_info[1])"
-	elif [[ "${micro}" == "1" ]]; then
-		python_command="from sys import version_info; print(version_info[2])"
-	else
-		if [[ -n "${PYTHON_ABI}" && "${final_ABI}" == "0" ]]; then
-			if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
-				echo "${PYTHON_ABI}"
-			elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
-				echo "${PYTHON_ABI%-jython}"
-			fi
-			return
-		fi
-		python_command="from sys import version_info; print('.'.join(str(x) for x in version_info[:2]))"
-	fi
-
 	if [[ "${final_ABI}" == "1" ]]; then
 		if ! _python_package_supporting_installation_for_multiple_python_abis; then
 			die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
 		fi
-		"$(PYTHON -f)" -c "${python_command}"
 	else
 		if _python_package_supporting_installation_for_multiple_python_abis && ! _python_abi-specific_local_scope; then
 			die "${FUNCNAME}() should be used in ABI-specific local scope"
 		fi
-		"$(PYTHON ${PYTHON_ABI})" -c "${python_command}"
+	fi
+
+	if [[ "$((${full} + ${major} + ${minor} + ${micro}))" -gt 1 ]]; then
+		die "${FUNCNAME}(): '--full', '--major', '--minor' or '--micro' options cannot be specified simultaneously"
+	fi
+
+	if [[ "${language}" == "1" ]]; then
+		if [[ "${final_ABI}" == "1" ]]; then
+			PYTHON_ABI="$(PYTHON -f --ABI)"
+		elif [[ -z "${PYTHON_ABI}" ]]; then
+			PYTHON_ABI="$(PYTHON --ABI)"
+		fi
+		language_version="${PYTHON_ABI%%-*}"
+		if [[ "${full}" == "1" ]]; then
+			die "${FUNCNAME}(): '--language' and '--full' options cannot be specified simultaneously"
+		elif [[ "${major}" == "1" ]]; then
+			echo "${language_version%.*}"
+		elif [[ "${minor}" == "1" ]]; then
+			echo "${language_version#*.}"
+		elif [[ "${micro}" == "1" ]]; then
+			die "${FUNCNAME}(): '--language' and '--micro' options cannot be specified simultaneously"
+		else
+			echo "${language_version}"
+		fi
+	else
+		if [[ "${full}" == "1" ]]; then
+			python_command="from sys import version_info; print('.'.join(str(x) for x in version_info[:3]))"
+		elif [[ "${major}" == "1" ]]; then
+			python_command="from sys import version_info; print(version_info[0])"
+		elif [[ "${minor}" == "1" ]]; then
+			python_command="from sys import version_info; print(version_info[1])"
+		elif [[ "${micro}" == "1" ]]; then
+			python_command="from sys import version_info; print(version_info[2])"
+		else
+			if [[ -n "${PYTHON_ABI}" && "${final_ABI}" == "0" ]]; then
+				if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
+					echo "${PYTHON_ABI}"
+				elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
+					echo "${PYTHON_ABI%-jython}"
+				fi
+				return
+			fi
+			python_command="from sys import version_info; print('.'.join(str(x) for x in version_info[:2]))"
+		fi
+
+		if [[ "${final_ABI}" == "1" ]]; then
+			"$(PYTHON -f)" -c "${python_command}"
+		else
+			"$(PYTHON ${PYTHON_ABI})" -c "${python_command}"
+		fi
 	fi
 }
 






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2011-07-08  7:39 Dirkjan Ochtman (djc)
  0 siblings, 0 replies; 108+ messages in thread
From: Dirkjan Ochtman (djc) @ 2011-07-08  7:39 UTC (permalink / raw
  To: gentoo-commits

djc         11/07/08 07:39:03

  Modified:             python.eclass
  Log:
  Log syntax errors / warnings in python_mod_optimize().
  (Patch by Arfrever. Backported from python overlay.)

Revision  Changes    Path
1.119                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.119&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.119&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.118&r2=1.119

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.118
retrieving revision 1.119
diff -u -r1.118 -r1.119
--- python.eclass	8 Jul 2011 07:37:49 -0000	1.118
+++ python.eclass	8 Jul 2011 07:39:03 -0000	1.119
@@ -1,6 +1,6 @@
 # Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.118 2011/07/08 07:37:49 djc Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.119 2011/07/08 07:39:03 djc Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -2596,7 +2596,7 @@
 
 	if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis || _python_implementation || [[ "${CATEGORY}/${PN}" == "sys-apps/portage" ]]; then
 		# PYTHON_ABI variable cannot be local in packages not supporting installation for multiple Python ABIs.
-		local allow_evaluated_non_sitedir_paths="0" dir dirs=() evaluated_dirs=() evaluated_files=() file files=() iterated_PYTHON_ABIS options=() other_dirs=() other_files=() previous_PYTHON_ABI="${PYTHON_ABI}" return_code root site_packages_dirs=() site_packages_files=()
+		local allow_evaluated_non_sitedir_paths="0" dir dirs=() evaluated_dirs=() evaluated_files=() file files=() iterated_PYTHON_ABIS options=() other_dirs=() other_files=() previous_PYTHON_ABI="${PYTHON_ABI}" return_code root site_packages_dirs=() site_packages_files=() stderr stderr_line
 
 		if _python_package_supporting_installation_for_multiple_python_abis; then
 			if has "${EAPI:-0}" 0 1 2 3 && [[ -z "${PYTHON_ABIS}" ]]; then
@@ -2701,6 +2701,7 @@
 		for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
 			if ((${#site_packages_dirs[@]})) || ((${#site_packages_files[@]})) || ((${#evaluated_dirs[@]})) || ((${#evaluated_files[@]})); then
 				return_code="0"
+				stderr=""
 				ebegin "Compilation and optimization of Python modules for $(python_get_implementation) $(python_get_version)"
 				if ((${#site_packages_dirs[@]})) || ((${#evaluated_dirs[@]})); then
 					for dir in "${site_packages_dirs[@]}"; do
@@ -2709,7 +2710,7 @@
 					for dir in "${evaluated_dirs[@]}"; do
 						eval "dirs+=(\"\${root}${dir}\")"
 					done
-					"$(PYTHON)" "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${dirs[@]}" || return_code="1"
+					stderr+="${stderr:+$'\n'}$("$(PYTHON)" "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${dirs[@]}" 2>&1)" || return_code="1"
 					if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
 						"$(PYTHON)" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${dirs[@]}" &> /dev/null || return_code="1"
 					fi
@@ -2722,13 +2723,19 @@
 					for file in "${evaluated_files[@]}"; do
 						eval "files+=(\"\${root}${file}\")"
 					done
-					"$(PYTHON)" "${root}$(python_get_libdir)/py_compile.py" "${files[@]}" || return_code="1"
+					stderr+="${stderr:+$'\n'}$("$(PYTHON)" "${root}$(python_get_libdir)/py_compile.py" "${files[@]}" 2>&1)" || return_code="1"
 					if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
 						"$(PYTHON)" -O "${root}$(python_get_libdir)/py_compile.py" "${files[@]}" &> /dev/null || return_code="1"
 					fi
 					_python_clean_compiled_modules "${files[@]}"
 				fi
 				eend "${return_code}"
+				if [[ -n "${stderr}" ]]; then
+					eerror "Syntax errors / warnings in Python modules for $(python_get_implementation) $(python_get_version):" &> /dev/null
+					while read stderr_line; do
+						eerror "    ${stderr_line}"
+					done <<< "${stderr}"
+				fi
 			fi
 			unset dirs files
 		done
@@ -2744,22 +2751,29 @@
 
 		if ((${#other_dirs[@]})) || ((${#other_files[@]})); then
 			return_code="0"
+			stderr=""
 			ebegin "Compilation and optimization of Python modules placed outside of site-packages directories for $(python_get_implementation) $(python_get_version)"
 			if ((${#other_dirs[@]})); then
-				"$(PYTHON ${PYTHON_ABI})" "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" || return_code="1"
+				stderr+="${stderr:+$'\n'}$("$(PYTHON ${PYTHON_ABI})" "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" 2>&1)" || return_code="1"
 				if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
 					"$(PYTHON ${PYTHON_ABI})" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" &> /dev/null || return_code="1"
 				fi
 				_python_clean_compiled_modules "${other_dirs[@]}"
 			fi
 			if ((${#other_files[@]})); then
-				"$(PYTHON ${PYTHON_ABI})" "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" || return_code="1"
+				stderr+="${stderr:+$'\n'}$("$(PYTHON ${PYTHON_ABI})" "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" 2>&1)" || return_code="1"
 				if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
 					"$(PYTHON ${PYTHON_ABI})" -O "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" &> /dev/null || return_code="1"
 				fi
 				_python_clean_compiled_modules "${other_files[@]}"
 			fi
 			eend "${return_code}"
+			if [[ -n "${stderr}" ]]; then
+				eerror "Syntax errors / warnings in Python modules placed outside of site-packages directories for $(python_get_implementation) $(python_get_version):" &> /dev/null
+				while read stderr_line; do
+					eerror "    ${stderr_line}"
+				done <<< "${stderr}"
+			fi
 		fi
 	else
 		# Deprecated part of python_mod_optimize()






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2011-07-08  7:40 Dirkjan Ochtman (djc)
  0 siblings, 0 replies; 108+ messages in thread
From: Dirkjan Ochtman (djc) @ 2011-07-08  7:40 UTC (permalink / raw
  To: gentoo-commits

djc         11/07/08 07:40:02

  Modified:             python.eclass
  Log:
  Add _PYTHON_ABI_PATTERN_REGEX.
  (Patch by Arfrever. Backported from python overlay.)

Revision  Changes    Path
1.120                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.120&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.120&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.119&r2=1.120

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.119
retrieving revision 1.120
diff -u -r1.119 -r1.120
--- python.eclass	8 Jul 2011 07:39:03 -0000	1.119
+++ python.eclass	8 Jul 2011 07:40:02 -0000	1.120
@@ -1,6 +1,6 @@
 # Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.119 2011/07/08 07:39:03 djc Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.120 2011/07/08 07:40:02 djc Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -24,6 +24,8 @@
 # ===================================== HANDLING OF METADATA =====================================
 # ================================================================================================
 
+_PYTHON_ABI_PATTERN_REGEX="([[:alnum:]]|\.|-|\*|\[|\])+"
+
 _python_check_python_abi_matching() {
 	local pattern patterns patterns_list="0" PYTHON_ABI
 
@@ -822,7 +824,7 @@
 			if [[ "$(declare -p ${prefix}${variable} 2> /dev/null)" == "declare -a ${prefix}${variable}="* ]]; then
 				eval "array=(\"\${${prefix}${variable}[@]}\")"
 				for element in "${array[@]}"; do
-					if [[ "${element}" =~ ^([[:alnum:]]|\.|-|\*|\[|\])+\ (\+|-)\ .+ ]]; then
+					if [[ "${element}" =~ ^${_PYTHON_ABI_PATTERN_REGEX}\ (\+|-)\ .+ ]]; then
 						pattern="${element%% *}"
 						element="${element#* }"
 						operator="${element%% *}"






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2011-07-08  7:41 Dirkjan Ochtman (djc)
  0 siblings, 0 replies; 108+ messages in thread
From: Dirkjan Ochtman (djc) @ 2011-07-08  7:41 UTC (permalink / raw
  To: gentoo-commits

djc         11/07/08 07:41:56

  Modified:             python.eclass
  Log:
  Allow to use _python_package_supporting_installation_for_multiple_python_abis()
  in global scope and define it earlier.
  (Patch by Arfrever. Backported from python overlay.)

Revision  Changes    Path
1.121                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.121&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.121&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.120&r2=1.121

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.120
retrieving revision 1.121
diff -u -r1.120 -r1.121
--- python.eclass	8 Jul 2011 07:40:02 -0000	1.120
+++ python.eclass	8 Jul 2011 07:41:56 -0000	1.121
@@ -1,6 +1,6 @@
 # Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.120 2011/07/08 07:40:02 djc Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.121 2011/07/08 07:41:56 djc Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -83,6 +83,18 @@
 	fi
 }
 
+_python_package_supporting_installation_for_multiple_python_abis() {
+	if has "${EAPI:-0}" 0 1 2 3 4; then
+		if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
+			return 0
+		else
+			return 1
+		fi
+	else
+		die "${FUNCNAME}(): Support for EAPI=\"${EAPI}\" not implemented"
+	fi
+}
+
 # @ECLASS-VARIABLE: PYTHON_DEPEND
 # @DESCRIPTION:
 # Specification of dependency on dev-lang/python.
@@ -287,22 +299,6 @@
 	fi
 }
 
-_python_package_supporting_installation_for_multiple_python_abis() {
-	if [[ "${EBUILD_PHASE}" == "depend" ]]; then
-		die "${FUNCNAME}() cannot be used in global scope"
-	fi
-
-	if has "${EAPI:-0}" 0 1 2 3 4; then
-		if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
-			return 0
-		else
-			return 1
-		fi
-	else
-		die "${FUNCNAME}(): Support for EAPI=\"${EAPI}\" not implemented"
-	fi
-}
-
 _python_abi-specific_local_scope() {
 	[[ " ${FUNCNAME[@]:2} " =~ " "(_python_final_sanity_checks|python_execute_function|python_mod_optimize|python_mod_cleanup)" " ]]
 }






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2011-07-08  7:43 Dirkjan Ochtman (djc)
  0 siblings, 0 replies; 108+ messages in thread
From: Dirkjan Ochtman (djc) @ 2011-07-08  7:43 UTC (permalink / raw
  To: gentoo-commits

djc         11/07/08 07:43:38

  Modified:             python.eclass
  Log:
  Fix handling of ROOT in wrapper scripts generated by
  python_generate_wrapper_scripts().
  (Patch by Arfrever. Backported from python overlay.)

Revision  Changes    Path
1.122                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.122&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.122&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.121&r2=1.122

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.121
retrieving revision 1.122
diff -u -r1.121 -r1.122
--- python.eclass	8 Jul 2011 07:41:56 -0000	1.121
+++ python.eclass	8 Jul 2011 07:43:38 -0000	1.122
@@ -1,6 +1,6 @@
 # Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.121 2011/07/08 07:41:56 djc Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.122 2011/07/08 07:43:38 djc Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -1256,7 +1256,9 @@
 		sys.exit(1)
 else:
 	try:
-		eselect_process = subprocess.Popen(["${EPREFIX}/usr/bin/eselect", "python", "show"${eselect_python_option:+, $(echo "\"")}${eselect_python_option}${eselect_python_option:+$(echo "\"")}], stdout=subprocess.PIPE)
+		environment = os.environ.copy()
+		environment["ROOT"] = "/"
+		eselect_process = subprocess.Popen(["${EPREFIX}/usr/bin/eselect", "python", "show"${eselect_python_option:+, $(echo "\"")}${eselect_python_option}${eselect_python_option:+$(echo "\"")}], env=environment, stdout=subprocess.PIPE)
 		if eselect_process.wait() != 0:
 			raise ValueError
 	except (OSError, ValueError):
@@ -1286,7 +1288,9 @@
 		else
 			cat << EOF >> "${file}"
 try:
-	eselect_process = subprocess.Popen(["${EPREFIX}/usr/bin/eselect", "python", "show"${eselect_python_option:+, $(echo "\"")}${eselect_python_option}${eselect_python_option:+$(echo "\"")}], stdout=subprocess.PIPE)
+	environment = os.environ.copy()
+	environment["ROOT"] = "/"
+	eselect_process = subprocess.Popen(["${EPREFIX}/usr/bin/eselect", "python", "show"${eselect_python_option:+, $(echo "\"")}${eselect_python_option}${eselect_python_option:+$(echo "\"")}], env=environment, stdout=subprocess.PIPE)
 	if eselect_process.wait() != 0:
 		raise ValueError
 except (OSError, ValueError):
@@ -1758,14 +1762,14 @@
 			_python_calculate_PYTHON_ABIS
 			PYTHON_ABI="${PYTHON_ABIS##* }"
 		elif [[ "${python2}" == "1" ]]; then
-			PYTHON_ABI="$(eselect python show --python2 --ABI)"
+			PYTHON_ABI="$(ROOT="/" eselect python show --python2 --ABI)"
 			if [[ -z "${PYTHON_ABI}" ]]; then
 				die "${FUNCNAME}(): Active version of CPython 2 not set"
 			elif [[ "${PYTHON_ABI}" != "2."* ]]; then
 				die "${FUNCNAME}(): Internal error in \`eselect python show --python2\`"
 			fi
 		elif [[ "${python3}" == "1" ]]; then
-			PYTHON_ABI="$(eselect python show --python3 --ABI)"
+			PYTHON_ABI="$(ROOT="/" eselect python show --python3 --ABI)"
 			if [[ -z "${PYTHON_ABI}" ]]; then
 				die "${FUNCNAME}(): Active version of CPython 3 not set"
 			elif [[ "${PYTHON_ABI}" != "3."* ]]; then






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2011-07-08  7:44 Dirkjan Ochtman (djc)
  0 siblings, 0 replies; 108+ messages in thread
From: Dirkjan Ochtman (djc) @ 2011-07-08  7:44 UTC (permalink / raw
  To: gentoo-commits

djc         11/07/08 07:44:52

  Modified:             python.eclass
  Log:
  Include paths to wrapper scripts in error messages in wrapper scripts generated
  by python_generate_wrapper_scripts().
  (Patch by Arfrever. Backported from python overlay.)

Revision  Changes    Path
1.123                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.123&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.123&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.122&r2=1.123

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.122
retrieving revision 1.123
diff -u -r1.122 -r1.123
--- python.eclass	8 Jul 2011 07:43:38 -0000	1.122
+++ python.eclass	8 Jul 2011 07:44:52 -0000	1.123
@@ -1,6 +1,6 @@
 # Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.122 2011/07/08 07:43:38 djc Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.123 2011/07/08 07:44:52 djc Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -1252,7 +1252,7 @@
 if EPYTHON:
 	PYTHON_ABI = get_PYTHON_ABI(EPYTHON)
 	if PYTHON_ABI is None:
-		sys.stderr.write("EPYTHON variable has unrecognized value '%s'\n" % EPYTHON)
+		sys.stderr.write("%s: EPYTHON variable has unrecognized value '%s'\n" % (sys.argv[0], EPYTHON))
 		sys.exit(1)
 else:
 	try:
@@ -1262,7 +1262,7 @@
 		if eselect_process.wait() != 0:
 			raise ValueError
 	except (OSError, ValueError):
-		sys.stderr.write("Execution of 'eselect python show${eselect_python_option:+ }${eselect_python_option}' failed\n")
+		sys.stderr.write("%s: Execution of 'eselect python show${eselect_python_option:+ }${eselect_python_option}' failed\n" % sys.argv[0])
 		sys.exit(1)
 
 	EPYTHON = eselect_process.stdout.read()
@@ -1273,13 +1273,13 @@
 
 	PYTHON_ABI = get_PYTHON_ABI(EPYTHON)
 	if PYTHON_ABI is None:
-		sys.stderr.write("'eselect python show${eselect_python_option:+ }${eselect_python_option}' printed unrecognized value '%s'\n" % EPYTHON)
+		sys.stderr.write("%s: 'eselect python show${eselect_python_option:+ }${eselect_python_option}' printed unrecognized value '%s'\n" % (sys.argv[0], EPYTHON))
 		sys.exit(1)
 
 wrapper_script_path = os.path.realpath(sys.argv[0])
 target_executable_path = "%s-%s" % (wrapper_script_path, PYTHON_ABI)
 if not os.path.exists(target_executable_path):
-	sys.stderr.write("'%s' does not exist\n" % target_executable_path)
+	sys.stderr.write("%s: '%s' does not exist\n" % (sys.argv[0], target_executable_path))
 	sys.exit(1)
 EOF
 			if [[ "$?" != "0" ]]; then
@@ -1294,7 +1294,7 @@
 	if eselect_process.wait() != 0:
 		raise ValueError
 except (OSError, ValueError):
-	sys.stderr.write("Execution of 'eselect python show${eselect_python_option:+ }${eselect_python_option}' failed\n")
+	sys.stderr.write("%s: Execution of 'eselect python show${eselect_python_option:+ }${eselect_python_option}' failed\n" % sys.argv[0])
 	sys.exit(1)
 
 EPYTHON = eselect_process.stdout.read()
@@ -1305,7 +1305,7 @@
 
 PYTHON_ABI = get_PYTHON_ABI(EPYTHON)
 if PYTHON_ABI is None:
-	sys.stderr.write("'eselect python show${eselect_python_option:+ }${eselect_python_option}' printed unrecognized value '%s'\n" % EPYTHON)
+	sys.stderr.write("%s: 'eselect python show${eselect_python_option:+ }${eselect_python_option}' printed unrecognized value '%s'\n" % (sys.argv[0], EPYTHON))
 	sys.exit(1)
 
 wrapper_script_path = os.path.realpath(sys.argv[0])
@@ -1314,7 +1314,7 @@
 	if os.path.exists(target_executable_path):
 		break
 else:
-	sys.stderr.write("No target script exists for '%s'\n" % wrapper_script_path)
+	sys.stderr.write("%s: No target script exists for '%s'\n" % (sys.argv[0], wrapper_script_path))
 	sys.exit(1)
 EOF
 			if [[ "$?" != "0" ]]; then






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2011-07-08  7:46 Dirkjan Ochtman (djc)
  0 siblings, 0 replies; 108+ messages in thread
From: Dirkjan Ochtman (djc) @ 2011-07-08  7:46 UTC (permalink / raw
  To: gentoo-commits

djc         11/07/08 07:46:53

  Modified:             python.eclass
  Log:
  Add python_get_implementation_and_version().
  (Patch by Arfrever. Backported from python overlay.)

Revision  Changes    Path
1.124                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.124&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.124&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.123&r2=1.124

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.123
retrieving revision 1.124
diff -u -r1.123 -r1.124
--- python.eclass	8 Jul 2011 07:44:52 -0000	1.123
+++ python.eclass	8 Jul 2011 07:46:53 -0000	1.124
@@ -1,6 +1,6 @@
 # Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.123 2011/07/08 07:44:52 djc Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.124 2011/07/08 07:46:53 djc Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -1000,7 +1000,7 @@
 	for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
 		if [[ "${EBUILD_PHASE}" == "test" ]] && _python_check_python_abi_matching --patterns-list "${PYTHON_ABI}" "${PYTHON_TESTS_RESTRICTED_ABIS}"; then
 			if [[ "${quiet}" == "0" ]]; then
-				echo " ${_GREEN}*${_NORMAL} ${_BLUE}Testing of ${CATEGORY}/${PF} with $(python_get_implementation) $(python_get_version) skipped${_NORMAL}"
+				echo " ${_GREEN}*${_NORMAL} ${_BLUE}Testing of ${CATEGORY}/${PF} with $(python_get_implementation_and_version) skipped${_NORMAL}"
 			fi
 			continue
 		fi
@@ -1011,7 +1011,7 @@
 			if [[ -n "${action_message_template}" ]]; then
 				eval "action_message=\"${action_message_template}\""
 			else
-				action_message="${action} of ${CATEGORY}/${PF} with $(python_get_implementation) $(python_get_version)..."
+				action_message="${action} of ${CATEGORY}/${PF} with $(python_get_implementation_and_version)..."
 			fi
 			echo " ${_GREEN}*${_NORMAL} ${_BLUE}${action_message}${_NORMAL}"
 		fi
@@ -1045,7 +1045,7 @@
 			if [[ -n "${failure_message_template}" ]]; then
 				eval "failure_message=\"${failure_message_template}\""
 			else
-				failure_message="${action} failed with $(python_get_implementation) $(python_get_version) in ${function}() function"
+				failure_message="${action} failed with $(python_get_implementation_and_version) in ${function}() function"
 			fi
 
 			if [[ "${nonfatal}" == "1" ]]; then
@@ -2143,10 +2143,10 @@
 # @FUNCTION: python_get_version
 # @USAGE: [-f|--final-ABI] [-l|--language] [--full] [--major] [--minor] [--micro]
 # @DESCRIPTION:
-# Print Python version.
+# Print version of Python implementation.
 # --full, --major, --minor and --micro options cannot be specified simultaneously.
 # If --full, --major, --minor and --micro options are not specified, then "${major_version}.${minor_version}" is printed.
-# If --language option is specified, then Python language version is printed.
+# If --language option is specified, then version of Python language is printed.
 # --language and --full options cannot be specified simultaneously.
 # --language and --micro options cannot be specified simultaneously.
 # If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
@@ -2246,6 +2246,55 @@
 	fi
 }
 
+# @FUNCTION: python_get_implementation_and_version
+# @USAGE: [-f|--final-ABI]
+# @DESCRIPTION:
+# Print name and version of Python implementation.
+# If version of Python implementation is not bound to version of Python language, then
+# version of Python language is additionally printed.
+# If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
+python_get_implementation_and_version() {
+	_python_check_python_pkg_setup_execution
+
+	local final_ABI="0" PYTHON_ABI="${PYTHON_ABI}"
+
+	while (($#)); do
+		case "$1" in
+			-f|--final-ABI)
+				final_ABI="1"
+				;;
+			-*)
+				die "${FUNCNAME}(): Unrecognized option '$1'"
+				;;
+			*)
+				die "${FUNCNAME}(): Invalid usage"
+				;;
+		esac
+		shift
+	done
+
+	if [[ "${final_ABI}" == "1" ]]; then
+		if ! _python_package_supporting_installation_for_multiple_python_abis; then
+			die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
+		fi
+		PYTHON_ABI="$(PYTHON -f --ABI)"
+	else
+		if _python_package_supporting_installation_for_multiple_python_abis; then
+			if ! _python_abi-specific_local_scope; then
+				die "${FUNCNAME}() should be used in ABI-specific local scope"
+			fi
+		else
+			PYTHON_ABI="${PYTHON_ABI:-$(PYTHON --ABI)}"
+		fi
+	fi
+
+	if [[ "${PYTHON_ABI}" =~ ^[[:digit:]]+\.[[:digit:]]+-[[:alnum:]]+-[[:digit:]]+\.[[:digit:]]+$ ]]; then
+		echo "$(_python_get_implementation "${PYTHON_ABI}") ${PYTHON_ABI##*-} (Python ${PYTHON_ABI%%-*})"
+	else
+		echo "$(_python_get_implementation "${PYTHON_ABI}") ${PYTHON_ABI%%-*}"
+	fi
+}
+
 # ================================================================================================
 # ================================ FUNCTIONS FOR RUNNING OF TESTS ================================
 # ================================================================================================
@@ -2704,7 +2753,7 @@
 			if ((${#site_packages_dirs[@]})) || ((${#site_packages_files[@]})) || ((${#evaluated_dirs[@]})) || ((${#evaluated_files[@]})); then
 				return_code="0"
 				stderr=""
-				ebegin "Compilation and optimization of Python modules for $(python_get_implementation) $(python_get_version)"
+				ebegin "Compilation and optimization of Python modules for $(python_get_implementation_and_version)"
 				if ((${#site_packages_dirs[@]})) || ((${#evaluated_dirs[@]})); then
 					for dir in "${site_packages_dirs[@]}"; do
 						dirs+=("${root}$(python_get_sitedir)/${dir}")
@@ -2733,7 +2782,7 @@
 				fi
 				eend "${return_code}"
 				if [[ -n "${stderr}" ]]; then
-					eerror "Syntax errors / warnings in Python modules for $(python_get_implementation) $(python_get_version):" &> /dev/null
+					eerror "Syntax errors / warnings in Python modules for $(python_get_implementation_and_version):" &> /dev/null
 					while read stderr_line; do
 						eerror "    ${stderr_line}"
 					done <<< "${stderr}"
@@ -2754,7 +2803,7 @@
 		if ((${#other_dirs[@]})) || ((${#other_files[@]})); then
 			return_code="0"
 			stderr=""
-			ebegin "Compilation and optimization of Python modules placed outside of site-packages directories for $(python_get_implementation) $(python_get_version)"
+			ebegin "Compilation and optimization of Python modules placed outside of site-packages directories for $(python_get_implementation_and_version)"
 			if ((${#other_dirs[@]})); then
 				stderr+="${stderr:+$'\n'}$("$(PYTHON ${PYTHON_ABI})" "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" 2>&1)" || return_code="1"
 				if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
@@ -2771,7 +2820,7 @@
 			fi
 			eend "${return_code}"
 			if [[ -n "${stderr}" ]]; then
-				eerror "Syntax errors / warnings in Python modules placed outside of site-packages directories for $(python_get_implementation) $(python_get_version):" &> /dev/null
+				eerror "Syntax errors / warnings in Python modules placed outside of site-packages directories for $(python_get_implementation_and_version):" &> /dev/null
 				while read stderr_line; do
 					eerror "    ${stderr_line}"
 				done <<< "${stderr}"






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2011-07-08  7:47 Dirkjan Ochtman (djc)
  0 siblings, 0 replies; 108+ messages in thread
From: Dirkjan Ochtman (djc) @ 2011-07-08  7:47 UTC (permalink / raw
  To: gentoo-commits

djc         11/07/08 07:47:30

  Modified:             python.eclass
  Log:
  Delete support for installation of Python packages for Python 3.0.
  (Patch by Arfrever. Backported from python overlay.)

Revision  Changes    Path
1.125                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.125&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.125&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.124&r2=1.125

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.124
retrieving revision 1.125
diff -u -r1.124 -r1.125
--- python.eclass	8 Jul 2011 07:46:53 -0000	1.124
+++ python.eclass	8 Jul 2011 07:47:30 -0000	1.125
@@ -1,6 +1,6 @@
 # Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.124 2011/07/08 07:46:53 djc Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.125 2011/07/08 07:47:30 djc Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -16,7 +16,7 @@
 fi
 
 _CPYTHON2_GLOBALLY_SUPPORTED_ABIS=(2.4 2.5 2.6 2.7)
-_CPYTHON3_GLOBALLY_SUPPORTED_ABIS=(3.0 3.1 3.2 3.3)
+_CPYTHON3_GLOBALLY_SUPPORTED_ABIS=(3.1 3.2 3.3)
 _JYTHON_GLOBALLY_SUPPORTED_ABIS=(2.5-jython)
 _PYTHON_GLOBALLY_SUPPORTED_ABIS=(${_CPYTHON2_GLOBALLY_SUPPORTED_ABIS[@]} ${_CPYTHON3_GLOBALLY_SUPPORTED_ABIS[@]} ${_JYTHON_GLOBALLY_SUPPORTED_ABIS[@]})
 






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2011-07-08  7:48 Dirkjan Ochtman (djc)
  0 siblings, 0 replies; 108+ messages in thread
From: Dirkjan Ochtman (djc) @ 2011-07-08  7:48 UTC (permalink / raw
  To: gentoo-commits

djc         11/07/08 07:48:38

  Modified:             python.eclass
  Log:
  Add initial support for PyPy.
  (Patch by Arfrever. Backported from python overlay.)

Revision  Changes    Path
1.126                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.126&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.126&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.125&r2=1.126

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.125
retrieving revision 1.126
diff -u -r1.125 -r1.126
--- python.eclass	8 Jul 2011 07:47:30 -0000	1.125
+++ python.eclass	8 Jul 2011 07:48:38 -0000	1.126
@@ -1,6 +1,6 @@
 # Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.125 2011/07/08 07:47:30 djc Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.126 2011/07/08 07:48:38 djc Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -18,7 +18,8 @@
 _CPYTHON2_GLOBALLY_SUPPORTED_ABIS=(2.4 2.5 2.6 2.7)
 _CPYTHON3_GLOBALLY_SUPPORTED_ABIS=(3.1 3.2 3.3)
 _JYTHON_GLOBALLY_SUPPORTED_ABIS=(2.5-jython)
-_PYTHON_GLOBALLY_SUPPORTED_ABIS=(${_CPYTHON2_GLOBALLY_SUPPORTED_ABIS[@]} ${_CPYTHON3_GLOBALLY_SUPPORTED_ABIS[@]} ${_JYTHON_GLOBALLY_SUPPORTED_ABIS[@]})
+_PYPY_GLOBALLY_SUPPORTED_ABIS=(2.7-pypy-1.5)
+_PYTHON_GLOBALLY_SUPPORTED_ABIS=(${_CPYTHON2_GLOBALLY_SUPPORTED_ABIS[@]} ${_CPYTHON3_GLOBALLY_SUPPORTED_ABIS[@]} ${_JYTHON_GLOBALLY_SUPPORTED_ABIS[@]} ${_PYPY_GLOBALLY_SUPPORTED_ABIS[@]})
 
 # ================================================================================================
 # ===================================== HANDLING OF METADATA =====================================
@@ -61,11 +62,15 @@
 			[[ "${PYTHON_ABI}" =~ ^[[:digit:]]+\.[[:digit:]]+$ && "${PYTHON_ABI}" == ${pattern%-cpython} ]]
 		elif [[ "${pattern}" == *"-jython" ]]; then
 			[[ "${PYTHON_ABI}" == ${pattern} ]]
+		elif [[ "${pattern}" == *"-pypy-"* ]]; then
+			[[ "${PYTHON_ABI}" == ${pattern} ]]
 		else
 			if [[ "${PYTHON_ABI}" =~ ^[[:digit:]]+\.[[:digit:]]+$ ]]; then
 				[[ "${PYTHON_ABI}" == ${pattern} ]]
 			elif [[ "${PYTHON_ABI}" =~ ^[[:digit:]]+\.[[:digit:]]+-jython$ ]]; then
 				[[ "${PYTHON_ABI%-jython}" == ${pattern} ]]
+			elif [[ "${PYTHON_ABI}" =~ ^[[:digit:]]+\.[[:digit:]]+-pypy-[[:digit:]]+\.[[:digit:]]+$ ]]; then
+				[[ "${PYTHON_ABI%-pypy-*}" == ${pattern} ]]
 			else
 				die "${FUNCNAME}(): Unrecognized Python ABI '${PYTHON_ABI}'"
 			fi
@@ -294,6 +299,8 @@
 		return 0
 	elif [[ "${CATEGORY}/${PN}" == "dev-java/jython" ]]; then
 		return 0
+	elif [[ "${CATEGORY}/${PN}" == "dev-python/pypy" ]]; then
+		return 0
 	else
 		return 1
 	fi
@@ -462,7 +469,7 @@
 	EXPORT_FUNCTIONS pkg_setup
 fi
 
-_PYTHON_SHEBANG_BASE_PART_REGEX='^#![[:space:]]*([^[:space:]]*/usr/bin/env[[:space:]]+)?([^[:space:]]*/)?(jython|python)'
+_PYTHON_SHEBANG_BASE_PART_REGEX='^#![[:space:]]*([^[:space:]]*/usr/bin/env[[:space:]]+)?([^[:space:]]*/)?(jython|pypy-c|python)'
 
 # @FUNCTION: python_convert_shebangs
 # @USAGE: [-q|--quiet] [-r|--recursive] [-x|--only-executables] [--] <Python_ABI|Python_version> <file|directory> [files|directories]
@@ -540,7 +547,7 @@
 				einfo "Converting shebang in '${file}'"
 			fi
 
-			sed -e "1s:^#![[:space:]]*\([^[:space:]]*/usr/bin/env[[:space:]]\)\?[[:space:]]*\([^[:space:]]*/\)\?\(jython\|python\)\([[:digit:]]\+\(\.[[:digit:]]\+\)\?\)\?\(\$\|[[:space:]].*\):#!\1\2${python_interpreter}\6:" -i "${file}" || die "Conversion of shebang in '${file}' failed"
+			sed -e "1s:^#![[:space:]]*\([^[:space:]]*/usr/bin/env[[:space:]]\)\?[[:space:]]*\([^[:space:]]*/\)\?\(jython\|pypy-c\|python\)\([[:digit:]]\+\(\.[[:digit:]]\+\)\?\)\?\(\$\|[[:space:]].*\):#!\1\2${python_interpreter}\6:" -i "${file}" || die "Conversion of shebang in '${file}' failed"
 		fi
 	done
 }
@@ -1228,16 +1235,24 @@
 
 cpython_re = re.compile(r"^python(\d+\.\d+)$")
 jython_re = re.compile(r"^jython(\d+\.\d+)$")
+pypy_re = re.compile(r"^pypy-c(\d+\.\d+)$")
 python_shebang_re = re.compile(r"^#! *(${EPREFIX}/usr/bin/python|(${EPREFIX})?/usr/bin/env +(${EPREFIX}/usr/bin/)?python)")
 python_verification_output_re = re.compile("^GENTOO_PYTHON_TARGET_SCRIPT_PATH supported\n$")
 
+pypy_versions_mapping = {
+	"1.5": "2.7"
+}
+
 def get_PYTHON_ABI(EPYTHON):
 	cpython_matched = cpython_re.match(EPYTHON)
 	jython_matched = jython_re.match(EPYTHON)
+	pypy_matched = pypy_re.match(EPYTHON)
 	if cpython_matched is not None:
 		PYTHON_ABI = cpython_matched.group(1)
 	elif jython_matched is not None:
 		PYTHON_ABI = jython_matched.group(1) + "-jython"
+	elif pypy_matched is not None:
+		PYTHON_ABI = pypy_versions_mapping[pypy_matched.group(1)] + "-pypy-" + pypy_matched.group(1)
 	else:
 		PYTHON_ABI = None
 	return PYTHON_ABI
@@ -1654,11 +1669,14 @@
 # ======================================= GETTER FUNCTIONS =======================================
 # ================================================================================================
 
-_PYTHON_ABI_EXTRACTION_COMMAND='import platform
+_PYTHON_ABI_EXTRACTION_COMMAND=\
+'import platform
 import sys
 sys.stdout.write(".".join(str(x) for x in sys.version_info[:2]))
 if platform.system()[:4] == "Java":
-	sys.stdout.write("-jython")'
+	sys.stdout.write("-jython")
+elif hasattr(platform, "python_implementation") and platform.python_implementation() == "PyPy":
+	sys.stdout.write("-pypy-" + ".".join(str(x) for x in sys.pypy_version_info[:2]))'
 
 _python_get_implementation() {
 	local ignore_invalid="0"
@@ -1690,6 +1708,8 @@
 		echo "CPython"
 	elif [[ "$1" =~ ^[[:digit:]]+\.[[:digit:]]+-jython$ ]]; then
 		echo "Jython"
+	elif [[ "$1" =~ ^[[:digit:]]+\.[[:digit:]]+-pypy-[[:digit:]]+\.[[:digit:]]+$ ]]; then
+		echo "PyPy"
 	else
 		if [[ "${ignore_invalid}" == "0" ]]; then
 			die "${FUNCNAME}(): Unrecognized Python ABI '$1'"
@@ -1808,6 +1828,8 @@
 			python_interpreter="python${PYTHON_ABI}"
 		elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
 			python_interpreter="jython${PYTHON_ABI%-jython}"
+		elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "PyPy" ]]; then
+			python_interpreter="pypy-c${PYTHON_ABI#*-pypy-}"
 		fi
 
 		if [[ "${absolute_path_output}" == "1" ]]; then
@@ -1910,12 +1932,16 @@
 			echo "=dev-lang/python-${PYTHON_ABI}*"
 		elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
 			echo "=dev-java/jython-${PYTHON_ABI%-jython}*"
+		elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "PyPy" ]]; then
+			echo "=dev-python/pypy-${PYTHON_ABI#*-pypy-}*"
 		fi
 	else
 		if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
 			echo "dev-lang/python:${PYTHON_ABI}"
 		elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
 			echo "dev-java/jython:${PYTHON_ABI%-jython}"
+		elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "PyPy" ]]; then
+			echo "dev-python/pypy:${PYTHON_ABI#*-pypy-}"
 		fi
 	fi
 }
@@ -1972,13 +1998,15 @@
 		echo "${prefix}usr/include/python${PYTHON_ABI}"
 	elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
 		echo "${prefix}usr/share/jython-${PYTHON_ABI%-jython}/Include"
+	elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "PyPy" ]]; then
+		echo "${prefix}usr/$(get_libdir)/pypy${PYTHON_ABI#*-pypy-}/include"
 	fi
 }
 
 # @FUNCTION: python_get_libdir
 # @USAGE: [-b|--base-path] [-f|--final-ABI]
 # @DESCRIPTION:
-# Print path to Python library directory.
+# Print path to Python standard library directory.
 # If --base-path option is specified, then path not prefixed with "/" is printed.
 # If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
 python_get_libdir() {
@@ -2027,6 +2055,8 @@
 		echo "${prefix}usr/$(get_libdir)/python${PYTHON_ABI}"
 	elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
 		echo "${prefix}usr/share/jython-${PYTHON_ABI%-jython}/Lib"
+	elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "PyPy" ]]; then
+		die "${FUNCNAME}(): PyPy has multiple standard library directories"
 	fi
 }
 
@@ -2039,16 +2069,15 @@
 python_get_sitedir() {
 	_python_check_python_pkg_setup_execution
 
-	local final_ABI="0" options=()
+	local base_path="0" final_ABI="0" prefix PYTHON_ABI="${PYTHON_ABI}"
 
 	while (($#)); do
 		case "$1" in
 			-b|--base-path)
-				options+=("$1")
+				base_path="1"
 				;;
 			-f|--final-ABI)
 				final_ABI="1"
-				options+=("$1")
 				;;
 			-*)
 				die "${FUNCNAME}(): Unrecognized option '$1'"
@@ -2060,17 +2089,32 @@
 		shift
 	done
 
+	if [[ "${base_path}" == "0" ]]; then
+		prefix="/"
+	fi
+
 	if [[ "${final_ABI}" == "1" ]]; then
 		if ! _python_package_supporting_installation_for_multiple_python_abis; then
 			die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
 		fi
+		PYTHON_ABI="$(PYTHON -f --ABI)"
 	else
-		if _python_package_supporting_installation_for_multiple_python_abis && ! _python_abi-specific_local_scope; then
-			die "${FUNCNAME}() should be used in ABI-specific local scope"
+		if _python_package_supporting_installation_for_multiple_python_abis; then
+			if ! _python_abi-specific_local_scope; then
+				die "${FUNCNAME}() should be used in ABI-specific local scope"
+			fi
+		else
+			PYTHON_ABI="${PYTHON_ABI:-$(PYTHON --ABI)}"
 		fi
 	fi
 
-	echo "$(python_get_libdir "${options[@]}")/site-packages"
+	if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
+		echo "${prefix}usr/$(get_libdir)/python${PYTHON_ABI}/site-packages"
+	elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
+		echo "${prefix}usr/share/jython-${PYTHON_ABI%-jython}/Lib/site-packages"
+	elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "PyPy" ]]; then
+		echo "${prefix}usr/$(get_libdir)/pypy${PYTHON_ABI#*-pypy-}/site-packages"
+	fi
 }
 
 # @FUNCTION: python_get_library
@@ -2137,6 +2181,8 @@
 		fi
 	elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
 		die "${FUNCNAME}(): Jython does not have shared library"
+	elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "PyPy" ]]; then
+		die "${FUNCNAME}(): PyPy does not have shared library"
 	fi
 }
 
@@ -2219,19 +2265,21 @@
 		fi
 	else
 		if [[ "${full}" == "1" ]]; then
-			python_command="from sys import version_info; print('.'.join(str(x) for x in version_info[:3]))"
+			python_command="import sys; print('.'.join(str(x) for x in getattr(sys, 'pypy_version_info', sys.version_info)[:3]))"
 		elif [[ "${major}" == "1" ]]; then
-			python_command="from sys import version_info; print(version_info[0])"
+			python_command="import sys; print(getattr(sys, 'pypy_version_info', sys.version_info)[0])"
 		elif [[ "${minor}" == "1" ]]; then
-			python_command="from sys import version_info; print(version_info[1])"
+			python_command="import sys; print(getattr(sys, 'pypy_version_info', sys.version_info)[1])"
 		elif [[ "${micro}" == "1" ]]; then
-			python_command="from sys import version_info; print(version_info[2])"
+			python_command="import sys; print(getattr(sys, 'pypy_version_info', sys.version_info)[2])"
 		else
 			if [[ -n "${PYTHON_ABI}" && "${final_ABI}" == "0" ]]; then
 				if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
 					echo "${PYTHON_ABI}"
 				elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
 					echo "${PYTHON_ABI%-jython}"
+				elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "PyPy" ]]; then
+					echo "${PYTHON_ABI#*-pypy-}"
 				fi
 				return
 			fi
@@ -2761,9 +2809,9 @@
 					for dir in "${evaluated_dirs[@]}"; do
 						eval "dirs+=(\"\${root}${dir}\")"
 					done
-					stderr+="${stderr:+$'\n'}$("$(PYTHON)" "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${dirs[@]}" 2>&1)" || return_code="1"
+					stderr+="${stderr:+$'\n'}$("$(PYTHON)" -m compileall "${options[@]}" "${dirs[@]}" 2>&1)" || return_code="1"
 					if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
-						"$(PYTHON)" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${dirs[@]}" &> /dev/null || return_code="1"
+						"$(PYTHON)" -O -m compileall "${options[@]}" "${dirs[@]}" &> /dev/null || return_code="1"
 					fi
 					_python_clean_compiled_modules "${dirs[@]}"
 				fi
@@ -2774,9 +2822,9 @@
 					for file in "${evaluated_files[@]}"; do
 						eval "files+=(\"\${root}${file}\")"
 					done
-					stderr+="${stderr:+$'\n'}$("$(PYTHON)" "${root}$(python_get_libdir)/py_compile.py" "${files[@]}" 2>&1)" || return_code="1"
+					stderr+="${stderr:+$'\n'}$("$(PYTHON)" -m py_compile "${files[@]}" 2>&1)" || return_code="1"
 					if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
-						"$(PYTHON)" -O "${root}$(python_get_libdir)/py_compile.py" "${files[@]}" &> /dev/null || return_code="1"
+						"$(PYTHON)" -O -m py_compile "${files[@]}" &> /dev/null || return_code="1"
 					fi
 					_python_clean_compiled_modules "${files[@]}"
 				fi
@@ -2805,16 +2853,16 @@
 			stderr=""
 			ebegin "Compilation and optimization of Python modules placed outside of site-packages directories for $(python_get_implementation_and_version)"
 			if ((${#other_dirs[@]})); then
-				stderr+="${stderr:+$'\n'}$("$(PYTHON ${PYTHON_ABI})" "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" 2>&1)" || return_code="1"
+				stderr+="${stderr:+$'\n'}$("$(PYTHON ${PYTHON_ABI})" -m compileall "${options[@]}" "${other_dirs[@]}" 2>&1)" || return_code="1"
 				if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
-					"$(PYTHON ${PYTHON_ABI})" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" &> /dev/null || return_code="1"
+					"$(PYTHON ${PYTHON_ABI})" -O -m compileall "${options[@]}" "${other_dirs[@]}" &> /dev/null || return_code="1"
 				fi
 				_python_clean_compiled_modules "${other_dirs[@]}"
 			fi
 			if ((${#other_files[@]})); then
-				stderr+="${stderr:+$'\n'}$("$(PYTHON ${PYTHON_ABI})" "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" 2>&1)" || return_code="1"
+				stderr+="${stderr:+$'\n'}$("$(PYTHON ${PYTHON_ABI})" -m py_compile "${other_files[@]}" 2>&1)" || return_code="1"
 				if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
-					"$(PYTHON ${PYTHON_ABI})" -O "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" &> /dev/null || return_code="1"
+					"$(PYTHON ${PYTHON_ABI})" -O -m py_compile "${other_files[@]}" &> /dev/null || return_code="1"
 				fi
 				_python_clean_compiled_modules "${other_files[@]}"
 			fi






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2011-07-08  7:49 Dirkjan Ochtman (djc)
  0 siblings, 0 replies; 108+ messages in thread
From: Dirkjan Ochtman (djc) @ 2011-07-08  7:49 UTC (permalink / raw
  To: gentoo-commits

djc         11/07/08 07:49:36

  Modified:             python.eclass
  Log:
  Fix handling of symlinks in python_merge_intermediate_installation_images().
  (Patch by Arfrever. Backported from python overlay.)

Revision  Changes    Path
1.127                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.127&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.127&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.126&r2=1.127

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.126
retrieving revision 1.127
diff -u -r1.126 -r1.127
--- python.eclass	8 Jul 2011 07:48:38 -0000	1.126
+++ python.eclass	8 Jul 2011 07:49:36 -0000	1.127
@@ -1,6 +1,6 @@
 # Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.126 2011/07/08 07:48:38 djc Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.127 2011/07/08 07:49:36 djc Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -1424,7 +1424,7 @@
 	_python_check_python_pkg_setup_execution
 	_python_initialize_prefix_variables
 
-	local b file files=() intermediate_installation_images_directory PYTHON_ABI quiet="0" regex shebang version_executable wrapper_scripts=() wrapper_scripts_set=()
+	local absolute_file b file files=() intermediate_installation_images_directory PYTHON_ABI quiet="0" regex shebang version_executable wrapper_scripts=() wrapper_scripts_set=()
 
 	while (($#)); do
 		case "$1" in
@@ -1516,9 +1516,26 @@
 				done
 			fi
 
-			[[ "${version_executable}" == "0" || ! -x "${file}" ]] && continue
+			[[ "${version_executable}" == "0" ]] && continue
 
-			shebang="$(head -n1 "${file}")" || die "Extraction of shebang from '${file}' failed"
+			if [[ -L "${file}" ]]; then
+				absolute_file="$(readlink "${file}")"
+				if [[ "${absolute_file}" == /* ]]; then
+					absolute_file="${intermediate_installation_images_directory}/${PYTHON_ABI}${EPREFIX}/${absolute_file##/}"
+				else
+					if [[ "${file}" == */* ]]; then
+						absolute_file="${intermediate_installation_images_directory}/${PYTHON_ABI}${EPREFIX}/${file%/*}/${absolute_file}"
+					else
+						absolute_file="${intermediate_installation_images_directory}/${PYTHON_ABI}${EPREFIX}/${absolute_file}"
+					fi
+				fi
+			else
+				absolute_file="${intermediate_installation_images_directory}/${PYTHON_ABI}${EPREFIX}/${file}"
+			fi
+
+			[[ ! -x "${absolute_file}" ]] && continue
+
+			shebang="$(head -n1 "${absolute_file}")" || die "Extraction of shebang from '${absolute_file}' failed"
 
 			if [[ "${version_executable}" == "2" ]]; then
 				wrapper_scripts+=("${ED}${file}")
@@ -1539,7 +1556,11 @@
 			mv "${file}" "${file}-${PYTHON_ABI}" || die "Renaming of '${file}' failed"
 
 			if [[ "${shebang}" =~ ${_PYTHON_SHEBANG_BASE_PART_REGEX}[[:digit:]]*($|[[:space:]]+) ]]; then
-				python_convert_shebangs $([[ "${quiet}" == "1" ]] && echo --quiet) "${PYTHON_ABI}" "${file}-${PYTHON_ABI}"
+				if [[ -L "${file}-${PYTHON_ABI}" ]]; then
+					python_convert_shebangs $([[ "${quiet}" == "1" ]] && echo --quiet) "${PYTHON_ABI}" "${absolute_file}"
+				else
+					python_convert_shebangs $([[ "${quiet}" == "1" ]] && echo --quiet) "${PYTHON_ABI}" "${file}-${PYTHON_ABI}"
+				fi
 			fi
 		done
 






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2011-08-19 10:10 Fabio Erculiani (lxnay)
  0 siblings, 0 replies; 108+ messages in thread
From: Fabio Erculiani (lxnay) @ 2011-08-19 10:10 UTC (permalink / raw
  To: gentoo-commits

lxnay       11/08/19 10:10:03

  Modified:             python.eclass
  Log:
  kill pkg_setup USE dependencies check for EAPI>=2 with fire, take the blame, but live happier afterwards, see bug 337320

Revision  Changes    Path
1.128                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.128&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.128&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.127&r2=1.128

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.127
retrieving revision 1.128
diff -u -r1.127 -r1.128
--- python.eclass	8 Jul 2011 07:49:36 -0000	1.127
+++ python.eclass	19 Aug 2011 10:10:03 -0000	1.128
@@ -1,6 +1,6 @@
 # Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.127 2011/07/08 07:49:36 djc Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.128 2011/08/19 10:10:03 lxnay Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -400,8 +400,7 @@
 # @DESCRIPTION:
 # Perform sanity checks and initialize environment.
 #
-# This function is exported in EAPI 2 and 3 when PYTHON_USE_WITH or PYTHON_USE_WITH_OR variable
-# is set and always in EAPI >=4. Calling of this function is mandatory in EAPI >=4.
+# This function is exported in EAPI 2 and 3. Calling of this function is mandatory in EAPI >=4.
 python_pkg_setup() {
 	if [[ "${EBUILD_PHASE}" != "setup" ]]; then
 		die "${FUNCNAME}() can be used only in pkg_setup() phase"
@@ -421,47 +420,6 @@
 		PYTHON_ABI="${PYTHON_ABI:-$(PYTHON --ABI)}"
 	fi
 
-	if ! has "${EAPI:-0}" 0 1 && [[ -n "${PYTHON_USE_WITH}" || -n "${PYTHON_USE_WITH_OR}" ]]; then
-		if [[ "${PYTHON_USE_WITH_OPT}" ]]; then
-			if [[ "${PYTHON_USE_WITH_OPT}" == !* ]]; then
-				use ${PYTHON_USE_WITH_OPT#!} && return
-			else
-				use !${PYTHON_USE_WITH_OPT} && return
-			fi
-		fi
-
-		python_pkg_setup_check_USE_flags() {
-			local python_atom USE_flag
-			python_atom="$(python_get_implementational_package)"
-
-			for USE_flag in ${PYTHON_USE_WITH}; do
-				if ! has_version "${python_atom}[${USE_flag}]"; then
-					eerror "Please rebuild ${python_atom} with the following USE flags enabled: ${PYTHON_USE_WITH}"
-					die "Please rebuild ${python_atom} with the following USE flags enabled: ${PYTHON_USE_WITH}"
-				fi
-			done
-
-			for USE_flag in ${PYTHON_USE_WITH_OR}; do
-				if has_version "${python_atom}[${USE_flag}]"; then
-					return
-				fi
-			done
-
-			if [[ ${PYTHON_USE_WITH_OR} ]]; then
-				eerror "Please rebuild ${python_atom} with at least one of the following USE flags enabled: ${PYTHON_USE_WITH_OR}"
-				die "Please rebuild ${python_atom} with at least one of the following USE flags enabled: ${PYTHON_USE_WITH_OR}"
-			fi
-		}
-
-		if _python_package_supporting_installation_for_multiple_python_abis; then
-			PYTHON_SKIP_SANITY_CHECKS="1" python_execute_function -q python_pkg_setup_check_USE_flags
-		else
-			python_pkg_setup_check_USE_flags
-		fi
-
-		unset -f python_pkg_setup_check_USE_flags
-	fi
-
 	PYTHON_PKG_SETUP_EXECUTED="1"
 }
 






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2011-08-19 10:18 Fabio Erculiani (lxnay)
  0 siblings, 0 replies; 108+ messages in thread
From: Fabio Erculiani (lxnay) @ 2011-08-19 10:18 UTC (permalink / raw
  To: gentoo-commits

lxnay       11/08/19 10:18:59

  Modified:             python.eclass
  Log:
  restore USE deps check for EAPI=0,1 in pkg_setup

Revision  Changes    Path
1.129                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.129&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.129&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.128&r2=1.129

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.128
retrieving revision 1.129
diff -u -r1.128 -r1.129
--- python.eclass	19 Aug 2011 10:10:03 -0000	1.128
+++ python.eclass	19 Aug 2011 10:18:59 -0000	1.129
@@ -1,6 +1,6 @@
 # Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.128 2011/08/19 10:10:03 lxnay Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.129 2011/08/19 10:18:59 lxnay Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -400,7 +400,8 @@
 # @DESCRIPTION:
 # Perform sanity checks and initialize environment.
 #
-# This function is exported in EAPI 2 and 3. Calling of this function is mandatory in EAPI >=4.
+# This function is exported in EAPI 2 and 3 when PYTHON_USE_WITH or PYTHON_USE_WITH_OR variable
+# is set and always in EAPI >=4. Calling of this function is mandatory in EAPI >=4.
 python_pkg_setup() {
 	if [[ "${EBUILD_PHASE}" != "setup" ]]; then
 		die "${FUNCNAME}() can be used only in pkg_setup() phase"
@@ -420,6 +421,47 @@
 		PYTHON_ABI="${PYTHON_ABI:-$(PYTHON --ABI)}"
 	fi
 
+	if has "${EAPI:-0}" 0 1 && [[ -n "${PYTHON_USE_WITH}" || -n "${PYTHON_USE_WITH_OR}" ]]; then
+		if [[ "${PYTHON_USE_WITH_OPT}" ]]; then
+			if [[ "${PYTHON_USE_WITH_OPT}" == !* ]]; then
+				use ${PYTHON_USE_WITH_OPT#!} && return
+			else
+				use !${PYTHON_USE_WITH_OPT} && return
+			fi
+		fi
+
+		python_pkg_setup_check_USE_flags() {
+			local python_atom USE_flag
+			python_atom="$(python_get_implementational_package)"
+
+			for USE_flag in ${PYTHON_USE_WITH}; do
+				if ! has_version "${python_atom}[${USE_flag}]"; then
+					eerror "Please rebuild ${python_atom} with the following USE flags enabled: ${PYTHON_USE_WITH}"
+					die "Please rebuild ${python_atom} with the following USE flags enabled: ${PYTHON_USE_WITH}"
+				fi
+			done
+
+			for USE_flag in ${PYTHON_USE_WITH_OR}; do
+				if has_version "${python_atom}[${USE_flag}]"; then
+					return
+				fi
+			done
+
+			if [[ ${PYTHON_USE_WITH_OR} ]]; then
+				eerror "Please rebuild ${python_atom} with at least one of the following USE flags enabled: ${PYTHON_USE_WITH_OR}"
+				die "Please rebuild ${python_atom} with at least one of the following USE flags enabled: ${PYTHON_USE_WITH_OR}"
+			fi
+		}
+
+		if _python_package_supporting_installation_for_multiple_python_abis; then
+			PYTHON_SKIP_SANITY_CHECKS="1" python_execute_function -q python_pkg_setup_check_USE_flags
+		else
+			python_pkg_setup_check_USE_flags
+		fi
+
+		unset -f python_pkg_setup_check_USE_flags
+	fi
+
 	PYTHON_PKG_SETUP_EXECUTED="1"
 }
 






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2011-08-19 12:16 Fabio Erculiani (lxnay)
  0 siblings, 0 replies; 108+ messages in thread
From: Fabio Erculiani (lxnay) @ 2011-08-19 12:16 UTC (permalink / raw
  To: gentoo-commits

lxnay       11/08/19 12:16:56

  Modified:             python.eclass
  Log:
  revert as suggested by Arfrever

Revision  Changes    Path
1.130                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.130&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.130&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.129&r2=1.130

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.129
retrieving revision 1.130
diff -u -r1.129 -r1.130
--- python.eclass	19 Aug 2011 10:18:59 -0000	1.129
+++ python.eclass	19 Aug 2011 12:16:56 -0000	1.130
@@ -1,6 +1,6 @@
 # Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.129 2011/08/19 10:18:59 lxnay Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.130 2011/08/19 12:16:56 lxnay Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -421,7 +421,7 @@
 		PYTHON_ABI="${PYTHON_ABI:-$(PYTHON --ABI)}"
 	fi
 
-	if has "${EAPI:-0}" 0 1 && [[ -n "${PYTHON_USE_WITH}" || -n "${PYTHON_USE_WITH_OR}" ]]; then
+	if ! has "${EAPI:-0}" 0 1 && [[ -n "${PYTHON_USE_WITH}" || -n "${PYTHON_USE_WITH_OR}" ]]; then
 		if [[ "${PYTHON_USE_WITH_OPT}" ]]; then
 			if [[ "${PYTHON_USE_WITH_OPT}" == !* ]]; then
 				use ${PYTHON_USE_WITH_OPT#!} && return






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2011-09-10 13:48 Dirkjan Ochtman (djc)
  0 siblings, 0 replies; 108+ messages in thread
From: Dirkjan Ochtman (djc) @ 2011-09-10 13:48 UTC (permalink / raw
  To: gentoo-commits

djc         11/09/10 13:48:46

  Modified:             python.eclass
  Log:
  Remove 3.3 from support python ABIs for now.

Revision  Changes    Path
1.132                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.132&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.132&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.131&r2=1.132

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.131
retrieving revision 1.132
diff -u -r1.131 -r1.132
--- python.eclass	22 Aug 2011 04:46:32 -0000	1.131
+++ python.eclass	10 Sep 2011 13:48:46 -0000	1.132
@@ -1,6 +1,6 @@
 # Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.131 2011/08/22 04:46:32 vapier Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.132 2011/09/10 13:48:46 djc Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -16,7 +16,7 @@
 fi
 
 _CPYTHON2_GLOBALLY_SUPPORTED_ABIS=(2.4 2.5 2.6 2.7)
-_CPYTHON3_GLOBALLY_SUPPORTED_ABIS=(3.1 3.2 3.3)
+_CPYTHON3_GLOBALLY_SUPPORTED_ABIS=(3.1 3.2)
 _JYTHON_GLOBALLY_SUPPORTED_ABIS=(2.5-jython)
 _PYPY_GLOBALLY_SUPPORTED_ABIS=(2.7-pypy-1.5)
 _PYTHON_GLOBALLY_SUPPORTED_ABIS=(${_CPYTHON2_GLOBALLY_SUPPORTED_ABIS[@]} ${_CPYTHON3_GLOBALLY_SUPPORTED_ABIS[@]} ${_JYTHON_GLOBALLY_SUPPORTED_ABIS[@]} ${_PYPY_GLOBALLY_SUPPORTED_ABIS[@]})






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2011-10-07 10:48 Dirkjan Ochtman (djc)
  0 siblings, 0 replies; 108+ messages in thread
From: Dirkjan Ochtman (djc) @ 2011-10-07 10:48 UTC (permalink / raw
  To: gentoo-commits

djc         11/10/07 10:48:24

  Modified:             python.eclass
  Log:
  Respect options from shebangs of target scripts in wrapper scripts generated
  by python_generate_wrapper_scripts(). (Patch by Arfrever.)

Revision  Changes    Path
1.133                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.133&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.133&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.132&r2=1.133

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.132
retrieving revision 1.133
diff -u -r1.132 -r1.133
--- python.eclass	10 Sep 2011 13:48:46 -0000	1.132
+++ python.eclass	7 Oct 2011 10:48:24 -0000	1.133
@@ -1,6 +1,6 @@
 # Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.132 2011/09/10 13:48:46 djc Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.133 2011/10/07 10:48:24 djc Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -1236,7 +1236,8 @@
 cpython_re = re.compile(r"^python(\d+\.\d+)$")
 jython_re = re.compile(r"^jython(\d+\.\d+)$")
 pypy_re = re.compile(r"^pypy-c(\d+\.\d+)$")
-python_shebang_re = re.compile(r"^#! *(${EPREFIX}/usr/bin/python|(${EPREFIX})?/usr/bin/env +(${EPREFIX}/usr/bin/)?python)")
+cpython_shebang_re = re.compile(r"^#![ \t]*(?:${EPREFIX}/usr/bin/python|(?:${EPREFIX})?/usr/bin/env[ \t]+(?:${EPREFIX}/usr/bin/)?python)")
+python_shebang_options_re = re.compile(r"^#![ \t]*${EPREFIX}/usr/bin/(?:jython|pypy-c|python)(?:\d+(?:\.\d+)?)?[ \t]+(-\S)")
 python_verification_output_re = re.compile("^GENTOO_PYTHON_TARGET_SCRIPT_PATH supported\n$")
 
 pypy_versions_mapping = {
@@ -1340,14 +1341,19 @@
 
 target_executable = open(target_executable_path, "rb")
 target_executable_first_line = target_executable.readline()
+target_executable.close()
 if not isinstance(target_executable_first_line, str):
 	# Python 3
 	target_executable_first_line = target_executable_first_line.decode("utf_8", "replace")
 
-python_shebang_matched = python_shebang_re.match(target_executable_first_line)
-target_executable.close()
+options = []
+python_shebang_options_matched = python_shebang_options_re.match(target_executable_first_line)
+if python_shebang_options_matched is not None:
+	options = [python_shebang_options_matched.group(1)]
+
+cpython_shebang_matched = cpython_shebang_re.match(target_executable_first_line)
 
-if python_shebang_matched is not None:
+if cpython_shebang_matched is not None:
 	try:
 		python_interpreter_path = "${EPREFIX}/usr/bin/%s" % EPYTHON
 		os.environ["GENTOO_PYTHON_TARGET_SCRIPT_PATH_VERIFICATION"] = "1"
@@ -1370,9 +1376,9 @@
 			os.environ["GENTOO_PYTHON_TARGET_SCRIPT_PATH"] = target_executable_path
 
 		if hasattr(os, "execv"):
-			os.execv(python_interpreter_path, [python_interpreter_path] + sys.argv)
+			os.execv(python_interpreter_path, [python_interpreter_path] + options + sys.argv)
 		else:
-			sys.exit(subprocess.Popen([python_interpreter_path] + sys.argv).wait())
+			sys.exit(subprocess.Popen([python_interpreter_path] + options + sys.argv).wait())
 	except (KeyboardInterrupt, SystemExit):
 		raise
 	except:






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2011-10-07 10:49 Dirkjan Ochtman (djc)
  0 siblings, 0 replies; 108+ messages in thread
From: Dirkjan Ochtman (djc) @ 2011-10-07 10:49 UTC (permalink / raw
  To: gentoo-commits

djc         11/10/07 10:49:26

  Modified:             python.eclass
  Log:
  Improve support for SELinux in python_merge_intermediate_installation_images().
  (Patch by Arfrever.)

Revision  Changes    Path
1.134                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.134&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.134&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.133&r2=1.134

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.133
retrieving revision 1.134
diff -u -r1.133 -r1.134
--- python.eclass	7 Oct 2011 10:48:24 -0000	1.133
+++ python.eclass	7 Oct 2011 10:49:26 -0000	1.134
@@ -1,6 +1,6 @@
 # Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.133 2011/10/07 10:48:24 djc Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.134 2011/10/07 10:49:26 djc Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -1573,7 +1573,7 @@
 		popd > /dev/null || die "popd failed"
 
 		if ROOT="/" has_version sys-apps/coreutils; then
-			cp -fr --preserve=all "${intermediate_installation_images_directory}/${PYTHON_ABI}/"* "${D}" || die "Merging of intermediate installation image for Python ABI '${PYTHON_ABI} into installation image failed"
+			cp -fr --preserve=all --no-preserve=context "${intermediate_installation_images_directory}/${PYTHON_ABI}/"* "${D}" || die "Merging of intermediate installation image for Python ABI '${PYTHON_ABI} into installation image failed"
 		else
 			cp -fpr "${intermediate_installation_images_directory}/${PYTHON_ABI}/"* "${D}" || die "Merging of intermediate installation image for Python ABI '${PYTHON_ABI} into installation image failed"
 		fi






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2011-10-07 10:52 Dirkjan Ochtman (djc)
  0 siblings, 0 replies; 108+ messages in thread
From: Dirkjan Ochtman (djc) @ 2011-10-07 10:52 UTC (permalink / raw
  To: gentoo-commits

djc         11/10/07 10:52:32

  Modified:             python.eclass
  Log:
  Fix synchronization of variables in wrapper scripts generated by
  python_generate_wrapper_scripts(). (Patch by Arfrever.)

Revision  Changes    Path
1.135                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.135&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.135&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.134&r2=1.135

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.134
retrieving revision 1.135
diff -u -r1.134 -r1.135
--- python.eclass	7 Oct 2011 10:49:26 -0000	1.134
+++ python.eclass	7 Oct 2011 10:52:31 -0000	1.135
@@ -1,6 +1,6 @@
 # Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.134 2011/10/07 10:49:26 djc Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.135 2011/10/07 10:52:31 djc Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -1233,9 +1233,12 @@
 import subprocess
 import sys
 
-cpython_re = re.compile(r"^python(\d+\.\d+)$")
-jython_re = re.compile(r"^jython(\d+\.\d+)$")
-pypy_re = re.compile(r"^pypy-c(\d+\.\d+)$")
+cpython_ABI_re = re.compile(r"^(\d+\.\d+)$")
+jython_ABI_re = re.compile(r"^(\d+\.\d+)-jython$")
+pypy_ABI_re = re.compile(r"^\d+\.\d+-pypy-(\d+\.\d+)$")
+cpython_interpreter_re = re.compile(r"^python(\d+\.\d+)$")
+jython_interpreter_re = re.compile(r"^jython(\d+\.\d+)$")
+pypy_interpreter_re = re.compile(r"^pypy-c(\d+\.\d+)$")
 cpython_shebang_re = re.compile(r"^#![ \t]*(?:${EPREFIX}/usr/bin/python|(?:${EPREFIX})?/usr/bin/env[ \t]+(?:${EPREFIX}/usr/bin/)?python)")
 python_shebang_options_re = re.compile(r"^#![ \t]*${EPREFIX}/usr/bin/(?:jython|pypy-c|python)(?:\d+(?:\.\d+)?)?[ \t]+(-\S)")
 python_verification_output_re = re.compile("^GENTOO_PYTHON_TARGET_SCRIPT_PATH supported\n$")
@@ -1244,10 +1247,10 @@
 	"1.5": "2.7"
 }
 
-def get_PYTHON_ABI(EPYTHON):
-	cpython_matched = cpython_re.match(EPYTHON)
-	jython_matched = jython_re.match(EPYTHON)
-	pypy_matched = pypy_re.match(EPYTHON)
+def get_PYTHON_ABI(python_interpreter):
+	cpython_matched = cpython_interpreter_re.match(python_interpreter)
+	jython_matched = jython_interpreter_re.match(python_interpreter)
+	pypy_matched = pypy_interpreter_re.match(python_interpreter)
 	if cpython_matched is not None:
 		PYTHON_ABI = cpython_matched.group(1)
 	elif jython_matched is not None:
@@ -1258,17 +1261,31 @@
 		PYTHON_ABI = None
 	return PYTHON_ABI
 
+def get_python_interpreter(PYTHON_ABI):
+	cpython_matched = cpython_ABI_re.match(PYTHON_ABI)
+	jython_matched = jython_ABI_re.match(PYTHON_ABI)
+	pypy_matched = pypy_ABI_re.match(PYTHON_ABI)
+	if cpython_matched is not None:
+		python_interpreter = "python" + cpython_matched.group(1)
+	elif jython_matched is not None:
+		python_interpreter = "jython" + jython_matched.group(1)
+	elif pypy_matched is not None:
+		python_interpreter = "pypy-c" + pypy_matched.group(1)
+	else:
+		python_interpreter = None
+	return python_interpreter
+
 EOF
 		if [[ "$?" != "0" ]]; then
 			die "${FUNCNAME}(): Generation of '$1' failed"
 		fi
 		if [[ "${respect_EPYTHON}" == "1" ]]; then
 			cat << EOF >> "${file}"
-EPYTHON = os.environ.get("EPYTHON")
-if EPYTHON:
-	PYTHON_ABI = get_PYTHON_ABI(EPYTHON)
+python_interpreter = os.environ.get("EPYTHON")
+if python_interpreter:
+	PYTHON_ABI = get_PYTHON_ABI(python_interpreter)
 	if PYTHON_ABI is None:
-		sys.stderr.write("%s: EPYTHON variable has unrecognized value '%s'\n" % (sys.argv[0], EPYTHON))
+		sys.stderr.write("%s: EPYTHON variable has unrecognized value '%s'\n" % (sys.argv[0], python_interpreter))
 		sys.exit(1)
 else:
 	try:
@@ -1281,15 +1298,15 @@
 		sys.stderr.write("%s: Execution of 'eselect python show${eselect_python_option:+ }${eselect_python_option}' failed\n" % sys.argv[0])
 		sys.exit(1)
 
-	EPYTHON = eselect_process.stdout.read()
-	if not isinstance(EPYTHON, str):
+	python_interpreter = eselect_process.stdout.read()
+	if not isinstance(python_interpreter, str):
 		# Python 3
-		EPYTHON = EPYTHON.decode()
-	EPYTHON = EPYTHON.rstrip("\n")
+		python_interpreter = python_interpreter.decode()
+	python_interpreter = python_interpreter.rstrip("\n")
 
-	PYTHON_ABI = get_PYTHON_ABI(EPYTHON)
+	PYTHON_ABI = get_PYTHON_ABI(python_interpreter)
 	if PYTHON_ABI is None:
-		sys.stderr.write("%s: 'eselect python show${eselect_python_option:+ }${eselect_python_option}' printed unrecognized value '%s'\n" % (sys.argv[0], EPYTHON))
+		sys.stderr.write("%s: 'eselect python show${eselect_python_option:+ }${eselect_python_option}' printed unrecognized value '%s'\n" % (sys.argv[0], python_interpreter))
 		sys.exit(1)
 
 wrapper_script_path = os.path.realpath(sys.argv[0])
@@ -1313,15 +1330,15 @@
 	sys.stderr.write("%s: Execution of 'eselect python show${eselect_python_option:+ }${eselect_python_option}' failed\n" % sys.argv[0])
 	sys.exit(1)
 
-EPYTHON = eselect_process.stdout.read()
-if not isinstance(EPYTHON, str):
+python_interpreter = eselect_process.stdout.read()
+if not isinstance(python_interpreter, str):
 	# Python 3
-	EPYTHON = EPYTHON.decode()
-EPYTHON = EPYTHON.rstrip("\n")
+	python_interpreter = python_interpreter.decode()
+python_interpreter = python_interpreter.rstrip("\n")
 
-PYTHON_ABI = get_PYTHON_ABI(EPYTHON)
+PYTHON_ABI = get_PYTHON_ABI(python_interpreter)
 if PYTHON_ABI is None:
-	sys.stderr.write("%s: 'eselect python show${eselect_python_option:+ }${eselect_python_option}' printed unrecognized value '%s'\n" % (sys.argv[0], EPYTHON))
+	sys.stderr.write("%s: 'eselect python show${eselect_python_option:+ }${eselect_python_option}' printed unrecognized value '%s'\n" % (sys.argv[0], python_interpreter))
 	sys.exit(1)
 
 wrapper_script_path = os.path.realpath(sys.argv[0])
@@ -1332,6 +1349,11 @@
 else:
 	sys.stderr.write("%s: No target script exists for '%s'\n" % (sys.argv[0], wrapper_script_path))
 	sys.exit(1)
+
+python_interpreter = get_python_interpreter(PYTHON_ABI)
+if python_interpreter is None:
+	sys.stderr.write("%s: Unrecognized Python ABI '%s'\n" % (sys.argv[0], PYTHON_ABI))
+	sys.exit(1)
 EOF
 			if [[ "$?" != "0" ]]; then
 				die "${FUNCNAME}(): Generation of '$1' failed"
@@ -1355,7 +1377,7 @@
 
 if cpython_shebang_matched is not None:
 	try:
-		python_interpreter_path = "${EPREFIX}/usr/bin/%s" % EPYTHON
+		python_interpreter_path = "${EPREFIX}/usr/bin/%s" % python_interpreter
 		os.environ["GENTOO_PYTHON_TARGET_SCRIPT_PATH_VERIFICATION"] = "1"
 		python_verification_process = subprocess.Popen([python_interpreter_path, "-c", "pass"], stdout=subprocess.PIPE)
 		del os.environ["GENTOO_PYTHON_TARGET_SCRIPT_PATH_VERIFICATION"]
@@ -1370,7 +1392,7 @@
 		if not python_verification_output_re.match(python_verification_output):
 			raise ValueError
 
-		if cpython_re.match(EPYTHON) is not None:
+		if cpython_interpreter_re.match(python_interpreter) is not None:
 			os.environ["GENTOO_PYTHON_PROCESS_NAME"] = os.path.basename(sys.argv[0])
 			os.environ["GENTOO_PYTHON_WRAPPER_SCRIPT_PATH"] = sys.argv[0]
 			os.environ["GENTOO_PYTHON_TARGET_SCRIPT_PATH"] = target_executable_path






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2011-10-07 10:53 Dirkjan Ochtman (djc)
  0 siblings, 0 replies; 108+ messages in thread
From: Dirkjan Ochtman (djc) @ 2011-10-07 10:53 UTC (permalink / raw
  To: gentoo-commits

djc         11/10/07 10:53:14

  Modified:             python.eclass
  Log:
  Fix calculation of test hook function name in _python_test_hook().
  (Patch by Arfrever.)

Revision  Changes    Path
1.136                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.136&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.136&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.135&r2=1.136

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.135
retrieving revision 1.136
diff -u -r1.135 -r1.136
--- python.eclass	7 Oct 2011 10:52:31 -0000	1.135
+++ python.eclass	7 Oct 2011 10:53:14 -0000	1.136
@@ -1,6 +1,6 @@
 # Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.135 2011/10/07 10:52:31 djc Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.136 2011/10/07 10:53:14 djc Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -2408,8 +2408,8 @@
 		die "${FUNCNAME}() requires 1 argument"
 	fi
 
-	if _python_package_supporting_installation_for_multiple_python_abis && [[ "$(type -t "${FUNCNAME[3]}_$1_hook")" == "function" ]]; then
-		"${FUNCNAME[3]}_$1_hook"
+	if _python_package_supporting_installation_for_multiple_python_abis && [[ "$(type -t "${_PYTHON_TEST_FUNCTION}_$1_hook")" == "function" ]]; then
+		"${_PYTHON_TEST_FUNCTION}_$1_hook"
 	fi
 }
 
@@ -2453,7 +2453,7 @@
 
 		eval "evaluated_PYTHONPATH=\"${PYTHONPATH_template}\""
 
-		_python_test_hook pre
+		_PYTHON_TEST_FUNCTION="python_execute_nosetests" _python_test_hook pre
 
 		if [[ -n "${evaluated_PYTHONPATH}" ]]; then
 			echo ${_BOLD}PYTHONPATH="${evaluated_PYTHONPATH}" nosetests --verbosity="${PYTHON_TEST_VERBOSITY}" "$@"${_NORMAL}
@@ -2463,7 +2463,7 @@
 			nosetests --verbosity="${PYTHON_TEST_VERBOSITY}" "$@" || return "$?"
 		fi
 
-		_python_test_hook post
+		_PYTHON_TEST_FUNCTION="python_execute_nosetests" _python_test_hook post
 	}
 	if _python_package_supporting_installation_for_multiple_python_abis; then
 		python_execute_function ${separate_build_dirs:+-s} python_test_function "$@"
@@ -2517,7 +2517,7 @@
 
 		eval "evaluated_PYTHONPATH=\"${PYTHONPATH_template}\""
 
-		_python_test_hook pre
+		_PYTHON_TEST_FUNCTION="python_execute_py.test" _python_test_hook pre
 
 		if [[ -n "${evaluated_PYTHONPATH}" ]]; then
 			echo ${_BOLD}PYTHONPATH="${evaluated_PYTHONPATH}" py.test $([[ "${PYTHON_TEST_VERBOSITY}" -ge 2 ]] && echo -v) "$@"${_NORMAL}
@@ -2527,7 +2527,7 @@
 			py.test $([[ "${PYTHON_TEST_VERBOSITY}" -gt 1 ]] && echo -v) "$@" || return "$?"
 		fi
 
-		_python_test_hook post
+		_PYTHON_TEST_FUNCTION="python_execute_py.test" _python_test_hook post
 	}
 	if _python_package_supporting_installation_for_multiple_python_abis; then
 		python_execute_function ${separate_build_dirs:+-s} python_test_function "$@"
@@ -2581,7 +2581,7 @@
 
 		eval "evaluated_PYTHONPATH=\"${PYTHONPATH_template}\""
 
-		_python_test_hook pre
+		_PYTHON_TEST_FUNCTION="python_execute_trial" _python_test_hook pre
 
 		if [[ -n "${evaluated_PYTHONPATH}" ]]; then
 			echo ${_BOLD}PYTHONPATH="${evaluated_PYTHONPATH}" trial $([[ "${PYTHON_TEST_VERBOSITY}" -ge 4 ]] && echo --spew) "$@"${_NORMAL}
@@ -2591,7 +2591,7 @@
 			trial $([[ "${PYTHON_TEST_VERBOSITY}" -ge 4 ]] && echo --spew) "$@" || return "$?"
 		fi
 
-		_python_test_hook post
+		_PYTHON_TEST_FUNCTION="python_execute_trial" _python_test_hook post
 	}
 	if _python_package_supporting_installation_for_multiple_python_abis; then
 		python_execute_function ${separate_build_dirs:+-s} python_test_function "$@"






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2011-10-07 10:55 Dirkjan Ochtman (djc)
  0 siblings, 0 replies; 108+ messages in thread
From: Dirkjan Ochtman (djc) @ 2011-10-07 10:55 UTC (permalink / raw
  To: gentoo-commits

djc         11/10/07 10:55:51

  Modified:             python.eclass
  Log:
  Fix ResourceWarning in python_merge_intermediate_installation_images().
  (Patch by Arfrever.)

Revision  Changes    Path
1.137                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.137&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.137&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.136&r2=1.137

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.136
retrieving revision 1.137
diff -u -r1.136 -r1.137
--- python.eclass	7 Oct 2011 10:53:14 -0000	1.136
+++ python.eclass	7 Oct 2011 10:55:51 -0000	1.137
@@ -1,6 +1,6 @@
 # Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.136 2011/10/07 10:53:14 djc Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.137 2011/10/07 10:55:51 djc Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -1623,7 +1623,9 @@
 	# Python 2
 	stdout = sys.stdout
 
-files = set(open('${T}/python_wrapper_scripts', 'rb').read().rstrip(${b}'\x00').split(${b}'\x00'))
+python_wrapper_scripts_file = open('${T}/python_wrapper_scripts', 'rb')
+files = set(python_wrapper_scripts_file.read().rstrip(${b}'\x00').split(${b}'\x00'))
+python_wrapper_scripts_file.close()
 
 for file in sorted(files):
 	stdout.write(file)






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2011-10-07 10:57 Dirkjan Ochtman (djc)
  0 siblings, 0 replies; 108+ messages in thread
From: Dirkjan Ochtman (djc) @ 2011-10-07 10:57 UTC (permalink / raw
  To: gentoo-commits

djc         11/10/07 10:57:49

  Modified:             python.eclass
  Log:
  Improve support for PyPy in python_mod_optimize(). (Patch by Arfrever.)

Revision  Changes    Path
1.138                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.138&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.138&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.137&r2=1.138

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.137
retrieving revision 1.138
diff -u -r1.137 -r1.138
--- python.eclass	7 Oct 2011 10:55:51 -0000	1.137
+++ python.eclass	7 Oct 2011 10:57:48 -0000	1.138
@@ -1,6 +1,6 @@
 # Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.137 2011/10/07 10:55:51 djc Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.138 2011/10/07 10:57:48 djc Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -2862,7 +2862,7 @@
 						eval "dirs+=(\"\${root}${dir}\")"
 					done
 					stderr+="${stderr:+$'\n'}$("$(PYTHON)" -m compileall "${options[@]}" "${dirs[@]}" 2>&1)" || return_code="1"
-					if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
+					if ! has "$(_python_get_implementation "${PYTHON_ABI}")" Jython PyPy; then
 						"$(PYTHON)" -O -m compileall "${options[@]}" "${dirs[@]}" &> /dev/null || return_code="1"
 					fi
 					_python_clean_compiled_modules "${dirs[@]}"
@@ -2875,7 +2875,7 @@
 						eval "files+=(\"\${root}${file}\")"
 					done
 					stderr+="${stderr:+$'\n'}$("$(PYTHON)" -m py_compile "${files[@]}" 2>&1)" || return_code="1"
-					if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
+					if ! has "$(_python_get_implementation "${PYTHON_ABI}")" Jython PyPy; then
 						"$(PYTHON)" -O -m py_compile "${files[@]}" &> /dev/null || return_code="1"
 					fi
 					_python_clean_compiled_modules "${files[@]}"
@@ -2906,14 +2906,14 @@
 			ebegin "Compilation and optimization of Python modules placed outside of site-packages directories for $(python_get_implementation_and_version)"
 			if ((${#other_dirs[@]})); then
 				stderr+="${stderr:+$'\n'}$("$(PYTHON ${PYTHON_ABI})" -m compileall "${options[@]}" "${other_dirs[@]}" 2>&1)" || return_code="1"
-				if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
+				if ! has "$(_python_get_implementation "${PYTHON_ABI}")" Jython PyPy; then
 					"$(PYTHON ${PYTHON_ABI})" -O -m compileall "${options[@]}" "${other_dirs[@]}" &> /dev/null || return_code="1"
 				fi
 				_python_clean_compiled_modules "${other_dirs[@]}"
 			fi
 			if ((${#other_files[@]})); then
 				stderr+="${stderr:+$'\n'}$("$(PYTHON ${PYTHON_ABI})" -m py_compile "${other_files[@]}" 2>&1)" || return_code="1"
-				if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
+				if ! has "$(_python_get_implementation "${PYTHON_ABI}")" Jython PyPy; then
 					"$(PYTHON ${PYTHON_ABI})" -O -m py_compile "${other_files[@]}" &> /dev/null || return_code="1"
 				fi
 				_python_clean_compiled_modules "${other_files[@]}"






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2011-10-15 20:58 PaweA Hajdan (phajdan.jr)
  0 siblings, 0 replies; 108+ messages in thread
From: PaweA Hajdan (phajdan.jr) @ 2011-10-15 20:58 UTC (permalink / raw
  To: gentoo-commits

phajdan.jr    11/10/15 20:58:09

  Modified:             python.eclass
  Log:
  Make python.eclass not die on EAPI-4. This has been OK-ed by python team lead: http://archives.gentoo.org/gentoo-dev/msg_c211342132e8ee5249861eb6503b3ddd.xml

Revision  Changes    Path
1.139                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.139&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.139&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.138&r2=1.139

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.138
retrieving revision 1.139
diff -u -r1.138 -r1.139
--- python.eclass	7 Oct 2011 10:57:48 -0000	1.138
+++ python.eclass	15 Oct 2011 20:58:08 -0000	1.139
@@ -1,6 +1,6 @@
 # Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.138 2011/10/07 10:57:48 djc Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.139 2011/10/15 20:58:08 phajdan.jr Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -11,7 +11,7 @@
 
 inherit multilib
 
-if ! has "${EAPI:-0}" 0 1 2 3; then
+if ! has "${EAPI:-0}" 0 1 2 3 4; then
 	die "API of python.eclass in EAPI=\"${EAPI}\" not established"
 fi
 






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2011-11-18 23:37 Mike Frysinger (vapier)
  0 siblings, 0 replies; 108+ messages in thread
From: Mike Frysinger (vapier) @ 2011-11-18 23:37 UTC (permalink / raw
  To: gentoo-commits

vapier      11/11/18 23:37:03

  Modified:             python.eclass
  Log:
  do not clear out PYTHON_PKG_SETUP_EXECUTED everytime this gets sourced as it breaks `FEATURES=noauto ebuild <ebuild> clean setup unpack prepare configure ...` workflows

Revision  Changes    Path
1.140                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.140&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.140&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.139&r2=1.140

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.139
retrieving revision 1.140
diff -u -r1.139 -r1.140
--- python.eclass	15 Oct 2011 20:58:08 -0000	1.139
+++ python.eclass	18 Nov 2011 23:37:03 -0000	1.140
@@ -1,6 +1,6 @@
 # Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.139 2011/10/15 20:58:08 phajdan.jr Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.140 2011/11/18 23:37:03 vapier Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -386,8 +386,6 @@
 	fi
 }
 
-unset PYTHON_PKG_SETUP_EXECUTED
-
 _python_check_python_pkg_setup_execution() {
 	[[ " ${FUNCNAME[@]:1} " =~ " "(python_set_active_version|python_pkg_setup)" " ]] && return
 






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2011-11-30  8:55 Dirkjan Ochtman (djc)
  0 siblings, 0 replies; 108+ messages in thread
From: Dirkjan Ochtman (djc) @ 2011-11-30  8:55 UTC (permalink / raw
  To: gentoo-commits

djc         11/11/30 08:55:18

  Modified:             python.eclass
  Log:
  Update supported pypy ABIs.

Revision  Changes    Path
1.141                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.141&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.141&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.140&r2=1.141

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.140
retrieving revision 1.141
diff -u -r1.140 -r1.141
--- python.eclass	18 Nov 2011 23:37:03 -0000	1.140
+++ python.eclass	30 Nov 2011 08:55:18 -0000	1.141
@@ -1,6 +1,6 @@
 # Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.140 2011/11/18 23:37:03 vapier Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.141 2011/11/30 08:55:18 djc Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -18,7 +18,7 @@
 _CPYTHON2_GLOBALLY_SUPPORTED_ABIS=(2.4 2.5 2.6 2.7)
 _CPYTHON3_GLOBALLY_SUPPORTED_ABIS=(3.1 3.2)
 _JYTHON_GLOBALLY_SUPPORTED_ABIS=(2.5-jython)
-_PYPY_GLOBALLY_SUPPORTED_ABIS=(2.7-pypy-1.5)
+_PYPY_GLOBALLY_SUPPORTED_ABIS=(2.7-pypy-1.7)
 _PYTHON_GLOBALLY_SUPPORTED_ABIS=(${_CPYTHON2_GLOBALLY_SUPPORTED_ABIS[@]} ${_CPYTHON3_GLOBALLY_SUPPORTED_ABIS[@]} ${_JYTHON_GLOBALLY_SUPPORTED_ABIS[@]} ${_PYPY_GLOBALLY_SUPPORTED_ABIS[@]})
 
 # ================================================================================================






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2011-12-19  1:29 Robin H. Johnson (robbat2)
  0 siblings, 0 replies; 108+ messages in thread
From: Robin H. Johnson (robbat2) @ 2011-12-19  1:29 UTC (permalink / raw
  To: gentoo-commits

robbat2     11/12/19 01:29:57

  Modified:             python.eclass
  Log:
  Fix missing quotes on has_verison call.

Revision  Changes    Path
1.143                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.143&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.143&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.142&r2=1.143

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.142
retrieving revision 1.143
diff -p -w -b -B -u -u -r1.142 -r1.143
--- python.eclass	18 Dec 2011 23:38:11 -0000	1.142
+++ python.eclass	19 Dec 2011 01:29:57 -0000	1.143
@@ -1,6 +1,6 @@
 # Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.142 2011/12/18 23:38:11 robbat2 Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.143 2011/12/19 01:29:57 robbat2 Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -1596,7 +1596,7 @@ for file in sorted(files_set):
 		# the 3-way structure per comment #6. This enable users with old
 		# coreutils to upgrade a lot easier (you need to upgrade python+portage
 		# before coreutils can be upgraded).
-		if ROOT="/" has_version >=sys-apps/coreutils-6.9.90; then
+		if ROOT="/" has_version '>=sys-apps/coreutils-6.9.90'; then
 			cp -fr --preserve=all --no-preserve=context "${intermediate_installation_images_directory}/${PYTHON_ABI}/"* "${D}" || die "Merging of intermediate installation image for Python ABI '${PYTHON_ABI} into installation image failed"
 		elif ROOT="/" has_version sys-apps/coreutils; then
 			cp -fr --preserve=all "${intermediate_installation_images_directory}/${PYTHON_ABI}/"* "${D}" || die "Merging of intermediate installation image for Python ABI '${PYTHON_ABI} into installation image failed"






^ permalink raw reply	[flat|nested] 108+ messages in thread

* [gentoo-commits] gentoo-x86 commit in eclass: python.eclass
@ 2014-02-06  5:34 Mike Frysinger (vapier)
  0 siblings, 0 replies; 108+ messages in thread
From: Mike Frysinger (vapier) @ 2014-02-06  5:34 UTC (permalink / raw
  To: gentoo-commits

vapier      14/02/06 05:34:08

  Modified:             python.eclass
  Log:
  minor grammar fixes

Revision  Changes    Path
1.169                eclass/python.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.169&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?rev=1.169&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python.eclass?r1=1.168&r2=1.169

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.168
retrieving revision 1.169
diff -u -r1.168 -r1.169
--- python.eclass	18 Sep 2013 18:47:59 -0000	1.168
+++ python.eclass	6 Feb 2014 05:34:07 -0000	1.169
@@ -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.eclass,v 1.168 2013/09/18 18:47:59 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.169 2014/02/06 05:34:07 vapier Exp $
 
 # @ECLASS: python.eclass
 # @MAINTAINER:
@@ -341,14 +341,14 @@
 	if [[ "$(declare -p PYTHON_SANITY_CHECKS_EXECUTED 2> /dev/null)" != "declare -- PYTHON_SANITY_CHECKS_EXECUTED="* || " ${FUNCNAME[@]:1} " =~ " "(python_set_active_version|python_pkg_setup)" " && -z "${PYTHON_SKIP_SANITY_CHECKS}" ]]; then
 		# Ensure that /usr/bin/python and /usr/bin/python-config are valid.
 		if [[ "$(readlink "${EPREFIX}/usr/bin/python")" != "python-wrapper" ]]; then
-			eerror "'${EPREFIX}/usr/bin/python' is not valid symlink."
+			eerror "'${EPREFIX}/usr/bin/python' is not a valid symlink."
 			eerror "Use \`eselect python set \${python_interpreter}\` to fix this problem."
-			die "'${EPREFIX}/usr/bin/python' is not valid symlink"
+			die "'${EPREFIX}/usr/bin/python' is not a valid symlink"
 		fi
 		if [[ "$(<"${EPREFIX}/usr/bin/python-config")" != *"Gentoo python-config wrapper script"* ]]; then
-			eerror "'${EPREFIX}/usr/bin/python-config' is not valid script"
+			eerror "'${EPREFIX}/usr/bin/python-config' is not a valid script"
 			eerror "Use \`eselect python set \${python_interpreter}\` to fix this problem."
-			die "'${EPREFIX}/usr/bin/python-config' is not valid script"
+			die "'${EPREFIX}/usr/bin/python-config' is not a valid script"
 		fi
 	fi
 }
@@ -802,7 +802,7 @@
 
 			if has_version "=dev-lang/python-2*"; then
 				if [[ "$(readlink "${EPREFIX}/usr/bin/python2")" != "python2."* ]]; then
-					die "'${EPREFIX}/usr/bin/python2' is not valid symlink"
+					die "'${EPREFIX}/usr/bin/python2' is not a valid symlink"
 				fi
 
 				python2_version="$("${EPREFIX}/usr/bin/python2" -c 'from sys import version_info; print(".".join(str(x) for x in version_info[:2]))')"
@@ -825,7 +825,7 @@
 
 			if has_version "=dev-lang/python-3*"; then
 				if [[ "$(readlink "${EPREFIX}/usr/bin/python3")" != "python3."* ]]; then
-					die "'${EPREFIX}/usr/bin/python3' is not valid symlink"
+					die "'${EPREFIX}/usr/bin/python3' is not a valid symlink"
 				fi
 
 				python3_version="$("${EPREFIX}/usr/bin/python3" -c 'from sys import version_info; print(".".join(str(x) for x in version_info[:2]))')"





^ permalink raw reply	[flat|nested] 108+ messages in thread

end of thread, other threads:[~2014-02-06  5:34 UTC | newest]

Thread overview: 108+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-19  1:29 [gentoo-commits] gentoo-x86 commit in eclass: python.eclass Robin H. Johnson (robbat2)
  -- strict thread matches above, loose matches on Subject: below --
2014-02-06  5:34 Mike Frysinger (vapier)
2011-11-30  8:55 Dirkjan Ochtman (djc)
2011-11-18 23:37 Mike Frysinger (vapier)
2011-10-15 20:58 PaweA Hajdan (phajdan.jr)
2011-10-07 10:57 Dirkjan Ochtman (djc)
2011-10-07 10:55 Dirkjan Ochtman (djc)
2011-10-07 10:53 Dirkjan Ochtman (djc)
2011-10-07 10:52 Dirkjan Ochtman (djc)
2011-10-07 10:49 Dirkjan Ochtman (djc)
2011-10-07 10:48 Dirkjan Ochtman (djc)
2011-09-10 13:48 Dirkjan Ochtman (djc)
2011-08-19 12:16 Fabio Erculiani (lxnay)
2011-08-19 10:18 Fabio Erculiani (lxnay)
2011-08-19 10:10 Fabio Erculiani (lxnay)
2011-07-08  7:49 Dirkjan Ochtman (djc)
2011-07-08  7:48 Dirkjan Ochtman (djc)
2011-07-08  7:47 Dirkjan Ochtman (djc)
2011-07-08  7:46 Dirkjan Ochtman (djc)
2011-07-08  7:44 Dirkjan Ochtman (djc)
2011-07-08  7:43 Dirkjan Ochtman (djc)
2011-07-08  7:41 Dirkjan Ochtman (djc)
2011-07-08  7:40 Dirkjan Ochtman (djc)
2011-07-08  7:39 Dirkjan Ochtman (djc)
2011-07-08  7:37 Dirkjan Ochtman (djc)
2011-07-04 11:28 Dirkjan Ochtman (djc)
2011-07-04 11:27 Dirkjan Ochtman (djc)
2011-07-04 11:27 Dirkjan Ochtman (djc)
2011-07-04 11:00 Dirkjan Ochtman (djc)
2011-07-04 10:59 Dirkjan Ochtman (djc)
2011-07-04 10:50 Dirkjan Ochtman (djc)
2011-07-04 10:48 Dirkjan Ochtman (djc)
2011-03-10 17:49 Arfrever Frehtes Taifersar Arahesis (arfrever)
2011-02-14 20:46 Arfrever Frehtes Taifersar Arahesis (arfrever)
2010-12-31 21:51 Jonathan Callen (abcd)
2010-12-26 11:30 Arfrever Frehtes Taifersar Arahesis (arfrever)
2010-12-24 15:01 Arfrever Frehtes Taifersar Arahesis (arfrever)
2010-10-29 19:09 Arfrever Frehtes Taifersar Arahesis (arfrever)
2010-10-25 11:54 Arfrever Frehtes Taifersar Arahesis (arfrever)
2010-10-03  0:38 Arfrever Frehtes Taifersar Arahesis (arfrever)
2010-07-18 20:45 Arfrever Frehtes Taifersar Arahesis (arfrever)
2010-07-17 23:02 Arfrever Frehtes Taifersar Arahesis (arfrever)
2010-05-29 16:39 Arfrever Frehtes Taifersar Arahesis (arfrever)
2010-05-25 19:49 Arfrever Frehtes Taifersar Arahesis (arfrever)
2010-05-25 15:04 Arfrever Frehtes Taifersar Arahesis (arfrever)
2010-05-17 18:01 Arfrever Frehtes Taifersar Arahesis (arfrever)
2010-03-26 15:23 Arfrever Frehtes Taifersar Arahesis (arfrever)
2010-03-20 17:59 Arfrever Frehtes Taifersar Arahesis (arfrever)
2010-03-13 13:46 Arfrever Frehtes Taifersar Arahesis (arfrever)
2010-03-12 18:27 Petteri Raty (betelgeuse)
2010-03-04 17:42 Arfrever Frehtes Taifersar Arahesis (arfrever)
2010-02-28 15:49 Arfrever Frehtes Taifersar Arahesis (arfrever)
2010-02-28 11:48 Arfrever Frehtes Taifersar Arahesis (arfrever)
2010-02-14 18:53 Arfrever Frehtes Taifersar Arahesis (arfrever)
2010-02-11 18:52 Arfrever Frehtes Taifersar Arahesis (arfrever)
2010-02-02 18:55 Arfrever Frehtes Taifersar Arahesis (arfrever)
2010-01-15 14:46 Arfrever Frehtes Taifersar Arahesis (arfrever)
2010-01-14 19:23 Arfrever Frehtes Taifersar Arahesis (arfrever)
2010-01-11 16:07 Arfrever Frehtes Taifersar Arahesis (arfrever)
2010-01-10 17:03 Arfrever Frehtes Taifersar Arahesis (arfrever)
2009-12-23 23:43 Arfrever Frehtes Taifersar Arahesis (arfrever)
2009-11-22 16:45 Arfrever Frehtes Taifersar Arahesis (arfrever)
2009-11-22 13:48 Arfrever Frehtes Taifersar Arahesis (arfrever)
2009-11-15 22:00 Arfrever Frehtes Taifersar Arahesis (arfrever)
2009-11-15 14:25 Arfrever Frehtes Taifersar Arahesis (arfrever)
2009-10-11 13:34 Arfrever Frehtes Taifersar Arahesis (arfrever)
2009-10-02 23:09 Arfrever Frehtes Taifersar Arahesis (arfrever)
2009-10-02 17:32 Arfrever Frehtes Taifersar Arahesis (arfrever)
2009-10-02  2:02 Arfrever Frehtes Taifersar Arahesis (arfrever)
2009-09-18 17:50 Arfrever Frehtes Taifersar Arahesis (arfrever)
2009-09-11 19:55 Arfrever Frehtes Taifersar Arahesis (arfrever)
2009-09-09  4:16 Arfrever Frehtes Taifersar Arahesis (arfrever)
2009-09-05 17:30 Arfrever Frehtes Taifersar Arahesis (arfrever)
2009-08-31 23:58 Arfrever Frehtes Taifersar Arahesis (arfrever)
2009-08-31  0:07 Arfrever Frehtes Taifersar Arahesis (arfrever)
2009-08-29  2:15 Arfrever Frehtes Taifersar Arahesis (arfrever)
2009-08-28 16:08 Arfrever Frehtes Taifersar Arahesis (arfrever)
2009-08-15 23:32 Arfrever Frehtes Taifersar Arahesis (arfrever)
2009-08-15 21:50 Petteri Raty (betelgeuse)
2009-08-14 21:22 Arfrever Frehtes Taifersar Arahesis (arfrever)
2009-08-13 16:57 Arfrever Frehtes Taifersar Arahesis (arfrever)
2009-08-07  0:43 Arfrever Frehtes Taifersar Arahesis (arfrever)
2009-08-05 18:31 Arfrever Frehtes Taifersar Arahesis (arfrever)
2009-08-04 21:01 Arfrever Frehtes Taifersar Arahesis (arfrever)
2009-08-03 22:28 Arfrever Frehtes Taifersar Arahesis (arfrever)
2009-08-02 16:56 Arfrever Frehtes Taifersar Arahesis (arfrever)
2009-05-27 22:49 Petteri Raty (betelgeuse)
2008-10-30  5:21 Zac Medico (zmedico)
2008-10-27 12:23 Ali Polatel (hawking)
2008-10-27  0:17 Ali Polatel (hawking)
2008-10-26 21:54 Ali Polatel (hawking)
2008-10-26 21:21 Ali Polatel (hawking)
2008-10-26 17:46 Ali Polatel (hawking)
2008-10-26 17:34 Ali Polatel (hawking)
2008-10-26 17:26 Ali Polatel (hawking)
2008-10-26 17:11 Ali Polatel (hawking)
2008-09-01 14:11 Ali Polatel (hawking)
2008-08-29 19:28 Ali Polatel (hawking)
2008-08-01 22:22 Rob Cakebread (pythonhead)
2008-07-28 21:56 Rob Cakebread (pythonhead)
2008-05-30  9:58 Ali Polatel (hawking)
2008-05-29 22:03 Ali Polatel (hawking)
2008-05-29 21:19 Ali Polatel (hawking)
2008-05-29 20:01 Ali Polatel (hawking)
2008-05-29 18:36 Ali Polatel (hawking)
2008-05-29 15:24 Ali Polatel (hawking)
2008-05-29 14:10 Ali Polatel (hawking)
2008-03-28  7:11 Ali Polatel (hawking)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox