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] [--] [files|directories] +# @USAGE: [-A|--ABIs-patterns Python_ABIs] [--allow-evaluated-non-sitedir-paths] [-d directory] [-f] [-l] [-q] [-x regular_expression] [--] [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] [--] [files|directories] +# @USAGE: [-A|--ABIs-patterns Python_ABIs] [--allow-evaluated-non-sitedir-paths] [--] [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