public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: Arfrever Frehtes Taifersar Arahesis <Arfrever@gentoo.org>
To: Gentoo Development <gentoo-dev@lists.gentoo.org>
Subject: [gentoo-dev] Minor changes in python.eclass and distutils.eclass
Date: Mon, 5 Jul 2010 17:23:58 +0200	[thread overview]
Message-ID: <201007051724.02971.Arfrever@gentoo.org> (raw)


[-- Attachment #1.1: Type: Text/Plain, Size: 340 bytes --]

These minor changes in python.eclass and distutils.eclass have been already
reviewed on alias of Gentoo Python Project. It's recommended to be familiar
with internals of current code before trying to understand these minor changes.
Suggestions about indentation and quoting will be rejected.

-- 
Arfrever Frehtes Taifersar Arahesis

[-- Attachment #1.2: eclasses.patch --]
[-- Type: text/x-patch, Size: 48523 bytes --]

--- python.eclass
+++ python.eclass
@@ -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
--- distutils.eclass
+++ distutils.eclass
@@ -38,9 +38,13 @@
 # @DESCRIPTION:
 # Set this to use separate source directories for each enabled version of Python.
 
+# @ECLASS-VARIABLE: DISTUTILS_SETUP_FILES
+# @DESCRIPTION:
+# Paths to setup files.
+
 # @ECLASS-VARIABLE: DISTUTILS_GLOBAL_OPTIONS
 # @DESCRIPTION:
-# Global options passed to setup.py.
+# Global options passed to setup files.
 
 # @ECLASS-VARIABLE: DISTUTILS_SRC_TEST
 # @DESCRIPTION:
@@ -180,15 +184,21 @@
 		distutils_building() {
 			_distutils_hook pre
 
-			echo ${_BOLD}"$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build -b "$(_distutils_get_build_dir)" "$@"${_NORMAL}
-			"$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build -b "$(_distutils_get_build_dir)" "$@" || return "$?"
+			local setup_file
+			for setup_file in "${DISTUTILS_SETUP_FILES[@]-setup.py}"; do
+				echo ${_BOLD}"$(PYTHON)" "${setup_file}" "${DISTUTILS_GLOBAL_OPTIONS[@]}" build -b "$(_distutils_get_build_dir)" "$@"${_NORMAL}
+				"$(PYTHON)" "${setup_file}" "${DISTUTILS_GLOBAL_OPTIONS[@]}" build -b "$(_distutils_get_build_dir)" "$@" || return "$?"
+			done
 
 			_distutils_hook post
 		}
 		python_execute_function ${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES:+-s} distutils_building "$@"
 	else
-		echo ${_BOLD}"$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build "$@"${_NORMAL}
-		"$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build "$@" || die "Building failed"
+		local setup_file
+		for setup_file in "${DISTUTILS_SETUP_FILES[@]-setup.py}"; do
+			echo ${_BOLD}"$(PYTHON)" "${setup_file}" "${DISTUTILS_GLOBAL_OPTIONS[@]}" build "$@"${_NORMAL}
+			"$(PYTHON)" "${setup_file}" "${DISTUTILS_GLOBAL_OPTIONS[@]}" build "$@" || die "Building failed"
+		done
 	fi
 }
 
@@ -231,15 +241,21 @@
 			distutils_testing() {
 				_distutils_hook pre
 
-				echo ${_BOLD}PYTHONPATH="$(_distutils_get_PYTHONPATH)" "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" $([[ -z "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]] && echo build -b "$(_distutils_get_build_dir)") test "$@"${_NORMAL}
-				PYTHONPATH="$(_distutils_get_PYTHONPATH)" "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" $([[ -z "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]] && echo build -b "$(_distutils_get_build_dir)") test "$@" || return "$?"
+				local setup_file
+				for setup_file in "${DISTUTILS_SETUP_FILES[@]-setup.py}"; do
+					echo ${_BOLD}PYTHONPATH="$(_distutils_get_PYTHONPATH)" "$(PYTHON)" "${setup_file}" "${DISTUTILS_GLOBAL_OPTIONS[@]}" $([[ -z "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]] && echo build -b "$(_distutils_get_build_dir)") test "$@"${_NORMAL}
+					PYTHONPATH="$(_distutils_get_PYTHONPATH)" "$(PYTHON)" "${setup_file}" "${DISTUTILS_GLOBAL_OPTIONS[@]}" $([[ -z "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]] && echo build -b "$(_distutils_get_build_dir)") test "$@" || return "$?"
+				done
 
 				_distutils_hook post
 			}
 			python_execute_function ${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES:+-s} distutils_testing "$@"
 		else
-			echo ${_BOLD}PYTHONPATH="$(_distutils_get_PYTHONPATH)" "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" test "$@"${_NORMAL}
-			PYTHONPATH="$(_distutils_get_PYTHONPATH)" "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" test "$@" || die "Testing failed"
+			local setup_file
+			for setup_file in "${DISTUTILS_SETUP_FILES[@]-setup.py}"; do
+				echo ${_BOLD}PYTHONPATH="$(_distutils_get_PYTHONPATH)" "$(PYTHON)" "${setup_file}" "${DISTUTILS_GLOBAL_OPTIONS[@]}" test "$@"${_NORMAL}
+				PYTHONPATH="$(_distutils_get_PYTHONPATH)" "$(PYTHON)" "${setup_file}" "${DISTUTILS_GLOBAL_OPTIONS[@]}" test "$@" || die "Testing failed"
+			done
 		fi
 	elif [[ "${DISTUTILS_SRC_TEST}" == "nosetests" ]]; then
 		_distutils_src_test_hook nosetests
@@ -306,8 +322,11 @@
 		distutils_installation() {
 			_distutils_hook pre
 
-			echo ${_BOLD}"$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" $([[ -z "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]] && echo build -b "$(_distutils_get_build_dir)") install --root="${D}" --no-compile "$@"${_NORMAL}
-			"$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" $([[ -z "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]] && echo build -b "$(_distutils_get_build_dir)") install --root="${D}" --no-compile "$@" || return "$?"
+			local setup_file
+			for setup_file in "${DISTUTILS_SETUP_FILES[@]-setup.py}"; do
+				echo ${_BOLD}"$(PYTHON)" "${setup_file}" "${DISTUTILS_GLOBAL_OPTIONS[@]}" $([[ -z "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]] && echo build -b "$(_distutils_get_build_dir)") install --root="${D}" --no-compile "$@"${_NORMAL}
+				"$(PYTHON)" "${setup_file}" "${DISTUTILS_GLOBAL_OPTIONS[@]}" $([[ -z "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]] && echo build -b "$(_distutils_get_build_dir)") install --root="${D}" --no-compile "$@" || return "$?"
+			done
 
 			if [[ -z "${DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS}" && "${BASH_VERSINFO[0]}" -ge 4 ]]; then
 				rename_scripts_with_versioned_shebangs
@@ -325,8 +344,11 @@
 		# Mark the package to be rebuilt after a Python upgrade.
 		python_need_rebuild
 
-		echo ${_BOLD}"$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@"${_NORMAL}
-		"$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@" || die "Installation failed"
+		local setup_file
+		for setup_file in "${DISTUTILS_SETUP_FILES[@]-setup.py}"; do
+			echo ${_BOLD}"$(PYTHON)" "${setup_file}" "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@"${_NORMAL}
+			"$(PYTHON)" "${setup_file}" "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@" || die "Installation failed"
+		done
 	fi
 
 	if [[ -e "${ED}usr/local" ]]; then
@@ -416,40 +438,14 @@
 	fi
 }
 
-# @FUNCTION: distutils_python_version
-# @DESCRIPTION:
-# Deprecated wrapper function for deprecated python_version().
+# Scheduled for deletion on 2011-01-01.
 distutils_python_version() {
-	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
-
-	_python_set_color_variables
-
-	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
-
-	python_version
+	eerror "Use PYTHON() instead of python variable. Use python_get_*() instead of PYVER* variables."
+	die "${FUNCNAME}() is banned"
 }
 
-# @FUNCTION: distutils_python_tkinter
-# @DESCRIPTION:
-# Deprecated wrapper function for deprecated python_tkinter_exists().
+# Scheduled for deletion on 2011-01-01.
 distutils_python_tkinter() {
-	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
-
-	_python_set_color_variables
-
-	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
-
-	python_tkinter_exists
+	eerror "Use PYTHON_USE_WITH=\"xml\" and python_pkg_setup() instead of ${FUNCNAME}()."
+	die "${FUNCNAME}() is banned"
 }

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

             reply	other threads:[~2010-07-05 15:26 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-05 15:23 Arfrever Frehtes Taifersar Arahesis [this message]
2010-07-05 16:13 ` [gentoo-dev] Minor changes in python.eclass and distutils.eclass Samuli Suominen
2010-07-05 16:17   ` Arfrever Frehtes Taifersar Arahesis
2010-07-05 16:26     ` Samuli Suominen
2010-07-05 16:34       ` Arfrever Frehtes Taifersar Arahesis
2010-07-05 16:36         ` Tomáš Chvátal
2010-07-05 17:01           ` Arfrever Frehtes Taifersar Arahesis
2010-07-05 17:38             ` Harald van Dijk
2010-07-05 17:43               ` Harald van Dijk
2010-07-05 17:55               ` Pacho Ramos
2010-07-05 18:06                 ` Petteri Räty
2010-07-05 16:37         ` Ciaran McCreesh
2010-07-05 17:02           ` Arfrever Frehtes Taifersar Arahesis
2010-07-05 18:00         ` Mark Loeser
2010-07-05 18:29           ` Arfrever Frehtes Taifersar Arahesis
2010-07-05 19:18             ` Mark Loeser
2010-07-05 20:23               ` Arfrever Frehtes Taifersar Arahesis
2010-07-05 21:28                 ` Samuli Suominen
2010-07-05 21:38                   ` Arfrever Frehtes Taifersar Arahesis
2010-07-05 21:49                     ` Samuli Suominen
2010-07-05 22:07                       ` Arfrever Frehtes Taifersar Arahesis
2010-07-05 22:29                 ` Mike Frysinger
2010-07-05 23:31                   ` Arfrever Frehtes Taifersar Arahesis
2010-07-05 23:37                     ` Mike Frysinger
2010-07-14 22:36                       ` Arfrever Frehtes Taifersar Arahesis
2010-07-05 18:26 ` Petteri Räty
2010-07-05 19:59   ` Arfrever Frehtes Taifersar Arahesis
2010-07-05 20:18     ` Petteri Räty
2010-07-05 19:37 ` Alex Alexander
2010-07-05 22:50 ` Jorge Manuel B. S. Vicetto
2010-07-05 23:18   ` Jeroen Roovers
2010-07-06  6:33     ` Petteri Räty

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=201007051724.02971.Arfrever@gentoo.org \
    --to=arfrever@gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

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

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