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 1N9g3C-0001jx-88 for garchives@archives.gentoo.org; Sun, 15 Nov 2009 14:25:58 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 2A41AE0AEE; Sun, 15 Nov 2009 14:25:57 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id DE8A7E0AEE for ; Sun, 15 Nov 2009 14:25:56 +0000 (UTC) Received: from stork.gentoo.org (stork.gentoo.org [64.127.104.133]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTP id 796C465F76 for ; Sun, 15 Nov 2009 14:25:56 +0000 (UTC) Received: from arfrever by stork.gentoo.org with local (Exim 4.69) (envelope-from ) id 1N9g39-0004wP-Tr for gentoo-commits@lists.gentoo.org; Sun, 15 Nov 2009 14:25:55 +0000 From: "Arfrever Frehtes Taifersar Arahesis (arfrever)" To: gentoo-commits@lists.gentoo.org Reply-To: gentoo-dev@lists.gentoo.org, arfrever@gentoo.org Subject: [gentoo-commits] gentoo-x86 commit in eclass: python.eclass X-VCS-Repository: gentoo-x86 X-VCS-Files: python.eclass X-VCS-Directories: eclass X-VCS-Committer: arfrever X-VCS-Committer-Name: Arfrever Frehtes Taifersar Arahesis Content-Type: text/plain; charset=utf8 Message-Id: Sender: Arfrever Frehtes Taifersar Arahesis Date: Sun, 15 Nov 2009 14:25:55 +0000 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: e9b60a44-0e17-47f0-ba00-91ae30241876 X-Archives-Hash: f8d33d21d58959703c291787a9898346 arfrever 09/11/15 14:25:55 Modified: python.eclass Log: Make PYTHON() support multilib systems. Improve output of python_conver= t_shebangs(). Support passing of regular files to python_mod_cleanup(). I= mprove output of python_mod_cleanup(). Revision Changes Path 1.78 eclass/python.eclass file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.ecla= ss?rev=3D1.78&view=3Dmarkup plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.ecla= ss?rev=3D1.78&content-type=3Dtext/plain diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.ecla= ss?r1=3D1.77&r2=3D1.78 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.77 retrieving revision 1.78 diff -u -r1.77 -r1.78 --- python.eclass 11 Oct 2009 13:34:23 -0000 1.77 +++ python.eclass 15 Nov 2009 14:25:55 -0000 1.78 @@ -1,6 +1,6 @@ # Copyright 1999-2009 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.77 2009/10/1= 1 13:34:23 arfrever Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.78 2009/11/1= 5 14:25:55 arfrever Exp $ =20 # @ECLASS: python.eclass # @MAINTAINER: @@ -106,6 +106,10 @@ else echo -n "python${slot}" fi + + if [[ "${ABI}" !=3D "${DEFAULT_ABI}" ]]; then + echo -n "-${ABI}" + fi } =20 unset PYTHON_ABIS @@ -130,7 +134,7 @@ =20 # USE_${ABI_TYPE^^} and RESTRICT_${ABI_TYPE^^}_ABIS variables hopefully= will be included in EAPI >=3D 4. if [[ "$(declare -p PYTHON_ABIS 2> /dev/null)" !=3D "declare -x PYTHON_= ABIS=3D"* ]] && has "${EAPI:-0}" 0 1 2 3; then - local ABI python2_supported_versions python3_supported_versions restri= cted_ABI support_ABI supported_PYTHON_ABIS=3D + local PYTHON_ABI python2_supported_versions python3_supported_versions= restricted_ABI support_ABI supported_PYTHON_ABIS=3D PYTHON_ABI_SUPPORTED_VALUES=3D"2.4 2.5 2.6 2.7 3.0 3.1 3.2" python2_supported_versions=3D"2.4 2.5 2.6 2.7" python3_supported_versions=3D"3.0 3.1 3.2" @@ -142,26 +146,26 @@ die "USE_PYTHON variable is empty" fi =20 - for ABI in ${USE_PYTHON}; do - if ! has "${ABI}" ${PYTHON_ABI_SUPPORTED_VALUES}; then - die "USE_PYTHON variable contains invalid value '${ABI}'" + for PYTHON_ABI in ${USE_PYTHON}; do + if ! has "${PYTHON_ABI}" ${PYTHON_ABI_SUPPORTED_VALUES}; then + die "USE_PYTHON variable contains invalid value '${PYTHON_ABI}'" fi =20 - if has "${ABI}" ${python2_supported_versions}; then + if has "${PYTHON_ABI}" ${python2_supported_versions}; then python2_enabled=3D"1" fi - if has "${ABI}" ${python3_supported_versions}; then + if has "${PYTHON_ABI}" ${python3_supported_versions}; then python3_enabled=3D"1" fi =20 support_ABI=3D"1" for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do - if [[ "${ABI}" =3D=3D ${restricted_ABI} ]]; then + if [[ "${PYTHON_ABI}" =3D=3D ${restricted_ABI} ]]; then support_ABI=3D"0" break fi done - [[ "${support_ABI}" =3D=3D "1" ]] && supported_PYTHON_ABIS+=3D" ${AB= I}" + [[ "${support_ABI}" =3D=3D "1" ]] && supported_PYTHON_ABIS+=3D" ${PY= THON_ABI}" done export PYTHON_ABIS=3D"${supported_PYTHON_ABIS# }" =20 @@ -187,10 +191,10 @@ =20 python2_version=3D"$(/usr/bin/python2 -c 'from sys import version_in= fo; print(".".join([str(x) for x in version_info[:2]]))')" =20 - for ABI in ${python2_supported_versions}; do + for PYTHON_ABI in ${python2_supported_versions}; do support_python_major_version=3D"1" for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do - if [[ "${ABI}" =3D=3D ${restricted_ABI} ]]; then + if [[ "${PYTHON_ABI}" =3D=3D ${restricted_ABI} ]]; then support_python_major_version=3D"0" fi done @@ -214,10 +218,10 @@ =20 python3_version=3D"$(/usr/bin/python3 -c 'from sys import version_in= fo; print(".".join([str(x) for x in version_info[:2]]))')" =20 - for ABI in ${python3_supported_versions}; do + for PYTHON_ABI in ${python3_supported_versions}; do support_python_major_version=3D"1" for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do - if [[ "${ABI}" =3D=3D ${restricted_ABI} ]]; then + if [[ "${PYTHON_ABI}" =3D=3D ${restricted_ABI} ]]; then support_python_major_version=3D"0" fi done @@ -485,9 +489,9 @@ fi elif has "${PYTHON_ABI}" ${FAILURE_TOLERANT_PYTHON_ABIS}; then if [[ "${EBUILD_PHASE}" !=3D "test" ]] || ! has test-fail-continue $= {FEATURES}; then - local ABI enabled_PYTHON_ABIS=3D - for ABI in ${PYTHON_ABIS}; do - [[ "${ABI}" !=3D "${PYTHON_ABI}" ]] && enabled_PYTHON_ABIS+=3D" ${= ABI}" + local enabled_PYTHON_ABIS=3D other_PYTHON_ABI + for other_PYTHON_ABI in ${PYTHON_ABIS}; do + [[ "${other_PYTHON_ABI}" !=3D "${PYTHON_ABI}" ]] && enabled_PYTHON= _ABIS+=3D" ${other_PYTHON_ABI}" done export PYTHON_ABIS=3D"${enabled_PYTHON_ABIS# }" fi @@ -595,6 +599,7 @@ done =20 for file in "${files[@]}"; do + file=3D"${file#./}" [[ "${only_executables}" =3D=3D "1" && ! -x "${file}" ]] && continue =20 if [[ "$(head -n1 "${file}")" =3D~ ^'#!'.*python ]]; then @@ -722,8 +727,6 @@ unset PYTHONDONTWRITEBYTECODE } =20 -python_disable_pyc - # @FUNCTION: python_need_rebuild # @DESCRIPTION: Run without arguments, specifies that the package should= be # rebuilt after a python upgrade. @@ -938,7 +941,7 @@ =20 if ((${#other_dirs[@]})) || ((${#other_files[@]})); then return_code=3D"0" - ebegin "Compilation and optimization of Python modules placed outside= of site-packages directories for Python ${PYVER}..." + ebegin "Compilation and optimization of Python modules placed outside= of site-packages directories for Python ${PYVER}" if ((${#other_dirs[@]})); then python${PYVER} "${root}$(python_get_libdir)/compileall.py" "${option= s[@]}" "${other_dirs[@]}" || return_code=3D"1" python${PYVER} -O "${root}$(python_get_libdir)/compileall.py" "${opt= ions[@]}" "${other_dirs[@]}" &> /dev/null || return_code=3D"1" @@ -994,7 +997,7 @@ # set additional opts myopts+=3D(-q) =20 - ebegin "Byte compiling python modules for python-${PYVER} .." + ebegin "Compilation and optimization of Python modules for Python ${PY= VER}" if ((${#mydirs[@]})); then python${PYVER} \ "${myroot}"/usr/$(get_libdir)/python${PYVER}/compileall.py \ @@ -1024,7 +1027,7 @@ # # This function should only be run in pkg_postrm(). python_mod_cleanup() { - local PYTHON_ABI SEARCH_PATH=3D() root src_py + local path py_file PYTHON_ABI SEARCH_PATH=3D() root =20 # Check if phase is pkg_postrm(). [[ ${EBUILD_PHASE} !=3D "postrm" ]] && die "${FUNCNAME} should only be = run in pkg_postrm()" @@ -1051,22 +1054,45 @@ SEARCH_PATH=3D("${SEARCH_PATH[@]/#/${root}/}") fi else - SEARCH_PATH=3D("${root}"/usr/lib*/python*/site-packages) + local dir sitedir + for dir in "${root}"/usr/lib*; do + if [[ -d "${dir}" && ! -L "${dir}" ]]; then + for sitedir in "${dir}"/python*/site-packages; do + if [[ -d "${sitedir}" ]]; then + SEARCH_PATH+=3D("${sitedir}") + fi + done + fi + done + fi + + local BLUE CYAN NORMAL + if [[ "${NOCOLOR:-false}" =3D~ ^(false|no)$ ]]; then + BLUE=3D$'\e[34m' + CYAN=3D$'\e[36m' + NORMAL=3D$'\e[0m' + else + BLUE=3D + CYAN=3D + NORMAL=3D fi =20 for path in "${SEARCH_PATH[@]}"; do - [[ ! -d "${path}" ]] && continue - einfo "Cleaning orphaned Python bytecode from ${path} .." - find "${path}" -name '*.py[co]' -print0 | while read -rd ''; do - src_py=3D"${REPLY%[co]}" - [[ -f "${src_py}" || (! -f "${src_py}c" && ! -f "${src_py}o") ]] && c= ontinue - einfo "Purging ${src_py}[co]" - rm -f "${src_py}"[co] - done + if [[ -d "${path}" ]]; then + find "${path}" -name '*.py[co]' -print0 | while read -rd ''; do + py_file=3D"${REPLY%[co]}" + [[ -f "${py_file}" || (! -f "${py_file}c" && ! -f "${py_file}o") ]] = && continue + einfo "${BLUE}<<< ${py_file}[co]${NORMAL}" + rm -f "${py_file}"[co] + done =20 - # Attempt to remove directories that may be empty. - find "${path}" -type d | sort -r | while read -r dir; do - rmdir "${dir}" 2>/dev/null && einfo "Removing empty directory ${dir}" - done + # Attempt to delete directories, which may be empty. + find "${path}" -type d | sort -r | while read -r dir; do + rmdir "${dir}" 2>/dev/null && einfo "${CYAN}<<< ${dir}${NORMAL}" + done + elif [[ "${path}" =3D=3D *.py && ! -f "${path}" && (-f "${path}c" || -= f "${path}o") ]]; then + einfo "${BLUE}<<< ${path}[co]${NORMAL}" + rm -f "${path}"[co] + fi done }