From: Mike Gilbert <floppym@gentoo.org>
To: gentoo-python@lists.gentoo.org
Subject: [gentoo-python] [PATCH] Support -A / --ABIs-patterns option in python_mod_optimize() and python_mod_cleanup()
Date: Thu, 29 Dec 2011 08:08:26 -0500 [thread overview]
Message-ID: <4EFC664A.10105@gentoo.org> (raw)
[-- 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 --]
next reply other threads:[~2011-12-29 13:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-29 13:08 Mike Gilbert [this message]
2011-12-29 13:41 ` [gentoo-python] [PATCH] Support -A / --ABIs-patterns option in python_mod_optimize() and python_mod_cleanup() 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
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=4EFC664A.10105@gentoo.org \
--to=floppym@gentoo.org \
--cc=gentoo-python@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