public inbox for gentoo-python@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-python] [PATCH] Support -A / --ABIs-patterns option in python_mod_optimize() and python_mod_cleanup()
@ 2011-12-29 13:08 Mike Gilbert
  2011-12-29 13:41 ` Michał Górny
  0 siblings, 1 reply; 6+ messages in thread
From: Mike Gilbert @ 2011-12-29 13:08 UTC (permalink / raw
  To: gentoo-python


[-- Attachment #1.1: Type: text/plain, Size: 600 bytes --]

I would like to apply the attached patch to python.eclass. This is a
port from Progress overlay.

This patch allows python_mod_optimize to be used in cases where a
different set of python modules is installed depending on the python abi.

For example, dev-python/feedparse-5.1 (not yet in the tree) installs the
_feedparser_sgmllib.py module only in python-3*.

The only difference from Arfrever's original changeset (Progress r1408)
is the "return_status" variable. For some reason, he has renamed this to
"exit_status".

Please provide any comments/questions/objections you may have.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: python-eclass-progress-r1408.patch --]
[-- Type: text/x-patch; name="python-eclass-progress-r1408.patch", Size: 6973 bytes --]

Support -A / --ABIs-patterns option in python_mod_optimize() and python_mod_cleanup().
Ported from Progress overlay.

Index: python.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
retrieving revision 1.143
diff -u -B -r1.143 python.eclass
--- python.eclass	19 Dec 2011 01:29:57 -0000	1.143
+++ python.eclass	29 Dec 2011 12:46:58 -0000
@@ -2735,7 +2735,7 @@
 }
 
 # @FUNCTION: python_mod_optimize
-# @USAGE: [--allow-evaluated-non-sitedir-paths] [-d directory] [-f] [-l] [-q] [-x regular_expression] [--] <file|directory> [files|directories]
+# @USAGE: [-A|--ABIs-patterns Python_ABIs] [--allow-evaluated-non-sitedir-paths] [-d directory] [-f] [-l] [-q] [-x regular_expression] [--] <file|directory> [files|directories]
 # @DESCRIPTION:
 # Byte-compile specified Python modules.
 # -d, -f, -l, -q and -x options passed to this function are passed to compileall.py.
@@ -2751,18 +2751,18 @@
 
 	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=() stderr stderr_line
+		local ABIs_patterns="*" allow_evaluated_non_sitedir_paths="0" dir dirs=() enabled_PYTHON_ABI enabled_PYTHON_ABIS 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
 				die "${FUNCNAME}(): python_pkg_setup() or python_execute_function() not called"
 			fi
-			iterated_PYTHON_ABIS="${PYTHON_ABIS}"
+			enabled_PYTHON_ABIS="${PYTHON_ABIS}"
 		else
 			if has "${EAPI:-0}" 0 1 2 3; then
-				iterated_PYTHON_ABIS="${PYTHON_ABI:=$(PYTHON --ABI)}"
+				enabled_PYTHON_ABIS="${PYTHON_ABI:=$(PYTHON --ABI)}"
 			else
-				iterated_PYTHON_ABIS="${PYTHON_ABI}"
+				enabled_PYTHON_ABIS="${PYTHON_ABI}"
 			fi
 		fi
 
@@ -2771,6 +2771,10 @@
 
 		while (($#)); do
 			case "$1" in
+				-A|--ABIs-patterns)
+					ABIs_patterns="$2"
+					shift
+					;;
 				--allow-evaluated-non-sitedir-paths)
 					allow_evaluated_non_sitedir_paths="1"
 					;;
@@ -2803,6 +2807,12 @@
 			die "${FUNCNAME}(): Missing files or directories"
 		fi
 
+		for enabled_PYTHON_ABI in ${enabled_PYTHON_ABIS}; do
+			if _python_check_python_abi_matching --patterns-list "${enabled_PYTHON_ABI}" "${ABIs_patterns}"; then
+				iterated_PYTHON_ABIS+="${iterated_PYTHON_ABIS:+ }${enabled_PYTHON_ABI}"
+			fi
+		done
+
 		while (($#)); do
 			if [[ "$1" =~ ^($|(\.|\.\.|/)($|/)) ]]; then
 				die "${FUNCNAME}(): Invalid argument '$1'"
@@ -2816,20 +2826,24 @@
 					if [[ "$1" != *\$* ]]; then
 						die "${FUNCNAME}(): '$1' has invalid syntax"
 					fi
-					if [[ "$1" == *.py ]]; then
-						evaluated_files+=("$1")
-					else
-						evaluated_dirs+=("$1")
+					if [[ -n "${iterated_PYTHON_ABIS}" ]]; then
+						if [[ "$1" == *.py ]]; then
+							evaluated_files+=("$1")
+						else
+							evaluated_dirs+=("$1")
+						fi
 					fi
 				else
-					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"
+					if [[ -n "${iterated_PYTHON_ABIS}" ]]; then
+						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
 				fi
 			else
@@ -3010,7 +3024,7 @@
 }
 
 # @FUNCTION: python_mod_cleanup
-# @USAGE: [--allow-evaluated-non-sitedir-paths] [--] <file|directory> [files|directories]
+# @USAGE: [-A|--ABIs-patterns Python_ABIs] [--allow-evaluated-non-sitedir-paths] [--] <file|directory> [files|directories]
 # @DESCRIPTION:
 # Delete orphaned byte-compiled Python modules corresponding to specified Python modules.
 #
@@ -3023,18 +3037,18 @@
 	_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
+	local ABIs_patterns="*" allow_evaluated_non_sitedir_paths="0" dir enabled_PYTHON_ABI enabled_PYTHON_ABIS iterated_PYTHON_ABIS PYTHON_ABI="${PYTHON_ABI}" root search_paths=() sitedir
 
 	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"
 		fi
-		iterated_PYTHON_ABIS="${PYTHON_ABIS}"
+		enabled_PYTHON_ABIS="${PYTHON_ABIS}"
 	else
 		if has "${EAPI:-0}" 0 1 2 3; then
-			iterated_PYTHON_ABIS="${PYTHON_ABI:-$(PYTHON --ABI)}"
+			enabled_PYTHON_ABIS="${PYTHON_ABI:-$(PYTHON --ABI)}"
 		else
-			iterated_PYTHON_ABIS="${PYTHON_ABI}"
+			enabled_PYTHON_ABIS="${PYTHON_ABI}"
 		fi
 	fi
 
@@ -3043,6 +3057,10 @@
 
 	while (($#)); do
 		case "$1" in
+			-A|--ABIs-patterns)
+				ABIs_patterns="$2"
+				shift
+				;;
 			--allow-evaluated-non-sitedir-paths)
 				allow_evaluated_non_sitedir_paths="1"
 				;;
@@ -3068,6 +3086,12 @@
 		die "${FUNCNAME}(): Missing files or directories"
 	fi
 
+	for enabled_PYTHON_ABI in ${enabled_PYTHON_ABIS}; do
+		if _python_check_python_abi_matching --patterns-list "${enabled_PYTHON_ABI}" "${ABIs_patterns}"; then
+			iterated_PYTHON_ABIS+="${iterated_PYTHON_ABIS:+ }${enabled_PYTHON_ABI}"
+		fi
+	done
+
 	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
@@ -3086,7 +3110,9 @@
 						eval "search_paths+=(\"\${root}$1\")"
 					done
 				else
-					search_paths+=("${root}$1")
+					if [[ -n "${iterated_PYTHON_ABIS}" ]]; then
+						search_paths+=("${root}$1")
+					fi
 				fi
 			else
 				for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 230 bytes --]

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

end of thread, other threads:[~2011-12-29 14:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-29 13:08 [gentoo-python] [PATCH] Support -A / --ABIs-patterns option in python_mod_optimize() and python_mod_cleanup() Mike Gilbert
2011-12-29 13:41 ` Michał Górny
2011-12-29 13:50   ` Mike Gilbert
2011-12-29 14:06     ` Michał Górny
2011-12-29 14:26       ` Mike Gilbert
2011-12-29 14:49         ` Mike Gilbert

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