From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1RgFik-0005c6-W6 for garchives@archives.gentoo.org; Thu, 29 Dec 2011 13:08:35 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 1885E21C0BA; Thu, 29 Dec 2011 13:08:32 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 67D4721C0BA for ; Thu, 29 Dec 2011 13:08:31 +0000 (UTC) Received: from [192.168.0.4] (d14-69-47-19.try.wideopenwest.com [69.14.19.47]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: floppym) by smtp.gentoo.org (Postfix) with ESMTPSA id 710FF1B401B for ; Thu, 29 Dec 2011 13:08:30 +0000 (UTC) Message-ID: <4EFC664A.10105@gentoo.org> Date: Thu, 29 Dec 2011 08:08:26 -0500 From: Mike Gilbert User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20111116 Thunderbird/8.0 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Discussions centering around the Python ecosystem in Gentoo Linux X-BeenThere: gentoo-python@gentoo.org X-BeenThere: gentoo-python@lists.gentoo.org MIME-Version: 1.0 To: gentoo-python@lists.gentoo.org Subject: [gentoo-python] [PATCH] Support -A / --ABIs-patterns option in python_mod_optimize() and python_mod_cleanup() X-Enigmail-Version: 1.3.3 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enigD9C0330DF12B0FDFC843EE1C" X-Archives-Salt: dd28633a-2416-46b9-8c94-235c26a3b561 X-Archives-Hash: 93f200471f38a4bec367a8ca94ef298f This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigD9C0330DF12B0FDFC843EE1C Content-Type: multipart/mixed; boundary="------------030306030706070103000804" This is a multi-part message in MIME format. --------------030306030706070103000804 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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. --------------030306030706070103000804 Content-Type: text/x-patch; name="python-eclass-progress-r1408.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="python-eclass-progress-r1408.patch" Support -A / --ABIs-patterns option in python_mod_optimize() and python_m= od_cleanup(). Ported from Progress overlay. Index: python.eclass =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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 @@ } =20 # @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-sitedi= r-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 co= mpileall.py. @@ -2751,18 +2751,18 @@ =20 if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_= for_multiple_python_abis || _python_implementation || [[ "${CATEGORY}/${P= N}" =3D=3D "sys-apps/portage" ]]; then # PYTHON_ABI variable cannot be local in packages not supporting insta= llation for multiple Python ABIs. - local allow_evaluated_non_sitedir_paths=3D"0" dir dirs=3D() evaluated_= dirs=3D() evaluated_files=3D() file files=3D() iterated_PYTHON_ABIS optio= ns=3D() other_dirs=3D() other_files=3D() previous_PYTHON_ABI=3D"${PYTHON_= ABI}" return_code root site_packages_dirs=3D() site_packages_files=3D() s= tderr stderr_line + local ABIs_patterns=3D"*" allow_evaluated_non_sitedir_paths=3D"0" dir = dirs=3D() enabled_PYTHON_ABI enabled_PYTHON_ABIS evaluated_dirs=3D() eval= uated_files=3D() file files=3D() iterated_PYTHON_ABIS options=3D() other_= dirs=3D() other_files=3D() previous_PYTHON_ABI=3D"${PYTHON_ABI}" return_c= ode root site_packages_dirs=3D() site_packages_files=3D() stderr stderr_l= ine =20 if _python_package_supporting_installation_for_multiple_python_abis; t= hen 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=3D"${PYTHON_ABIS}" + enabled_PYTHON_ABIS=3D"${PYTHON_ABIS}" else if has "${EAPI:-0}" 0 1 2 3; then - iterated_PYTHON_ABIS=3D"${PYTHON_ABI:=3D$(PYTHON --ABI)}" + enabled_PYTHON_ABIS=3D"${PYTHON_ABI:=3D$(PYTHON --ABI)}" else - iterated_PYTHON_ABIS=3D"${PYTHON_ABI}" + enabled_PYTHON_ABIS=3D"${PYTHON_ABI}" fi fi =20 @@ -2771,6 +2771,10 @@ =20 while (($#)); do case "$1" in + -A|--ABIs-patterns) + ABIs_patterns=3D"$2" + shift + ;; --allow-evaluated-non-sitedir-paths) allow_evaluated_non_sitedir_paths=3D"1" ;; @@ -2803,6 +2807,12 @@ die "${FUNCNAME}(): Missing files or directories" fi =20 + for enabled_PYTHON_ABI in ${enabled_PYTHON_ABIS}; do + if _python_check_python_abi_matching --patterns-list "${enabled_PYTHO= N_ABI}" "${ABIs_patterns}"; then + iterated_PYTHON_ABIS+=3D"${iterated_PYTHON_ABIS:+ }${enabled_PYTHON_= ABI}" + fi + done + while (($#)); do if [[ "$1" =3D~ ^($|(\.|\.\.|/)($|/)) ]]; then die "${FUNCNAME}(): Invalid argument '$1'" @@ -2816,20 +2826,24 @@ if [[ "$1" !=3D *\$* ]]; then die "${FUNCNAME}(): '$1' has invalid syntax" fi - if [[ "$1" =3D=3D *.py ]]; then - evaluated_files+=3D("$1") - else - evaluated_dirs+=3D("$1") + if [[ -n "${iterated_PYTHON_ABIS}" ]]; then + if [[ "$1" =3D=3D *.py ]]; then + evaluated_files+=3D("$1") + else + evaluated_dirs+=3D("$1") + fi fi else - if [[ -d "${root}$1" ]]; then - other_dirs+=3D("${root}$1") - elif [[ -f "${root}$1" ]]; then - other_files+=3D("${root}$1") - elif [[ -e "${root}$1" ]]; then - eerror "${FUNCNAME}(): '${root}$1' is not a regular file or a dire= ctory" - else - eerror "${FUNCNAME}(): '${root}$1' does not exist" + if [[ -n "${iterated_PYTHON_ABIS}" ]]; then + if [[ -d "${root}$1" ]]; then + other_dirs+=3D("${root}$1") + elif [[ -f "${root}$1" ]]; then + other_files+=3D("${root}$1") + elif [[ -e "${root}$1" ]]; then + eerror "${FUNCNAME}(): '${root}$1' is not a regular file or a dir= ectory" + else + eerror "${FUNCNAME}(): '${root}$1' does not exist" + fi fi fi else @@ -3010,7 +3024,7 @@ } =20 # @FUNCTION: python_mod_cleanup -# @USAGE: [--allow-evaluated-non-sitedir-paths] [--] [f= iles|directories] +# @USAGE: [-A|--ABIs-patterns Python_ABIs] [--allow-evaluated-non-sitedi= r-paths] [--] [files|directories] # @DESCRIPTION: # Delete orphaned byte-compiled Python modules corresponding to specifie= d Python modules. # @@ -3023,18 +3037,18 @@ _python_check_python_pkg_setup_execution _python_initialize_prefix_variables =20 - local allow_evaluated_non_sitedir_paths=3D"0" dir iterated_PYTHON_ABIS = PYTHON_ABI=3D"${PYTHON_ABI}" root search_paths=3D() sitedir + local ABIs_patterns=3D"*" allow_evaluated_non_sitedir_paths=3D"0" dir e= nabled_PYTHON_ABI enabled_PYTHON_ABIS iterated_PYTHON_ABIS PYTHON_ABI=3D"= ${PYTHON_ABI}" root search_paths=3D() sitedir =20 if _python_package_supporting_installation_for_multiple_python_abis; th= en if has "${EAPI:-0}" 0 1 2 3 && [[ -z "${PYTHON_ABIS}" ]]; then die "${FUNCNAME}(): python_pkg_setup() or python_execute_function() n= ot called" fi - iterated_PYTHON_ABIS=3D"${PYTHON_ABIS}" + enabled_PYTHON_ABIS=3D"${PYTHON_ABIS}" else if has "${EAPI:-0}" 0 1 2 3; then - iterated_PYTHON_ABIS=3D"${PYTHON_ABI:-$(PYTHON --ABI)}" + enabled_PYTHON_ABIS=3D"${PYTHON_ABI:-$(PYTHON --ABI)}" else - iterated_PYTHON_ABIS=3D"${PYTHON_ABI}" + enabled_PYTHON_ABIS=3D"${PYTHON_ABI}" fi fi =20 @@ -3043,6 +3057,10 @@ =20 while (($#)); do case "$1" in + -A|--ABIs-patterns) + ABIs_patterns=3D"$2" + shift + ;; --allow-evaluated-non-sitedir-paths) allow_evaluated_non_sitedir_paths=3D"1" ;; @@ -3068,6 +3086,12 @@ die "${FUNCNAME}(): Missing files or directories" fi =20 + 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+=3D"${iterated_PYTHON_ABIS:+ }${enabled_PYTHON_A= BI}" + fi + done + if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_= for_multiple_python_abis || _python_implementation || [[ "${CATEGORY}/${P= N}" =3D=3D "sys-apps/portage" ]]; then while (($#)); do if [[ "$1" =3D~ ^($|(\.|\.\.|/)($|/)) ]]; then @@ -3086,7 +3110,9 @@ eval "search_paths+=3D(\"\${root}$1\")" done else - search_paths+=3D("${root}$1") + if [[ -n "${iterated_PYTHON_ABIS}" ]]; then + search_paths+=3D("${root}$1") + fi fi else for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do --------------030306030706070103000804-- --------------enigD9C0330DF12B0FDFC843EE1C Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (GNU/Linux) iF4EAREIAAYFAk78ZkoACgkQC77qH+pIQ6R0MgEAvzaPBBvx1EZCANKEt7X6BAnY 1OIN/cNbT1SNZBcXqb0A/3ZZCSE3yfMNij4F8IYS+lISiyvYK3JRmh1yE7K2cisB =cuVZ -----END PGP SIGNATURE----- --------------enigD9C0330DF12B0FDFC843EE1C--