--- python.eclass +++ python.eclass @@ -2350,15 +2350,10 @@ } # @FUNCTION: python_mod_optimize -# @USAGE: [options] [directory|file] +# @USAGE: [--allow-evaluated-non-sitedir-paths] [-d directory] [-f] [-l] [-q] [-x regular_expression] [--] [files|directories] # @DESCRIPTION: -# If no arguments supplied, it will recompile not recursively all modules -# under sys.path (eg. /usr/lib/python2.6, /usr/lib/python2.6/site-packages). -# -# If supplied with arguments, it will recompile all modules recursively -# in the supplied directory. -# -# Options passed to this function are passed to compileall.py. +# Byte-compile specified Python modules. +# -d, -f, -l, -q and -x options passed to this function are passed to compileall.py. # # This function can be used only in pkg_postinst() phase. python_mod_optimize() { @@ -2419,11 +2414,7 @@ fi if [[ "$#" -eq 0 ]]; then - ewarn - ewarn "Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be" - ewarn "disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules." - ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." - ewarn + die "${FUNCNAME}(): Missing files or directories" fi while (($#)); do @@ -2578,11 +2569,7 @@ done if [[ "$#" -eq 0 ]]; then - ewarn - ewarn "Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be" - ewarn "disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules." - ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." - ewarn + die "${FUNCNAME}(): Missing files or directories" fi while (($#)); do @@ -2623,14 +2610,9 @@ } # @FUNCTION: python_mod_cleanup -# @USAGE: [directory|file] +# @USAGE: [--allow-evaluated-non-sitedir-paths] [--] [files|directories] # @DESCRIPTION: -# Run with optional arguments, where arguments are Python modules. If none given, -# it will look in /usr/lib/python[0-9].[0-9]. -# -# It will recursively scan all compiled Python modules in the directories and -# determine if they are orphaned (i.e. their corresponding .py files are missing.) -# If they are, then it will remove their corresponding .pyc and .pyo files. +# Delete orphaned byte-compiled Python modules corresponding to specified Python modules. # # This function can be used only in pkg_postrm() phase. python_mod_cleanup() { @@ -2681,67 +2663,48 @@ die "${FUNCNAME}(): '--allow-evaluated-non-sitedir-paths' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs" fi - if [[ "$#" -gt 0 ]]; then - 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 - die "${FUNCNAME}(): Invalid argument '$1'" - elif ! _python_implementation && [[ "$1" =~ ^/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then - die "${FUNCNAME}(): Paths of directories / files in site-packages directories must be relative to site-packages directories" - elif [[ "$1" =~ ^/ ]]; then - if _python_package_supporting_installation_for_multiple_python_abis; then - if [[ "${allow_evaluated_non_sitedir_paths}" != "1" ]]; then - die "${FUNCNAME}(): Absolute paths cannot be used in ebuilds of packages supporting installation for multiple Python ABIs" - fi - if [[ "$1" != *\$* ]]; then - die "${FUNCNAME}(): '$1' has invalid syntax" - fi - for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do - eval "search_paths+=(\"\${root}$1\")" - done - else - search_paths+=("${root}$1") + if [[ "$#" -eq 0 ]]; then + die "${FUNCNAME}(): Missing files or directories" + fi + + 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 + die "${FUNCNAME}(): Invalid argument '$1'" + elif ! _python_implementation && [[ "$1" =~ ^/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then + die "${FUNCNAME}(): Paths of directories / files in site-packages directories must be relative to site-packages directories" + elif [[ "$1" =~ ^/ ]]; then + if _python_package_supporting_installation_for_multiple_python_abis; then + if [[ "${allow_evaluated_non_sitedir_paths}" != "1" ]]; then + die "${FUNCNAME}(): Absolute paths cannot be used in ebuilds of packages supporting installation for multiple Python ABIs" + fi + if [[ "$1" != *\$* ]]; then + die "${FUNCNAME}(): '$1' has invalid syntax" fi - else for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do - search_paths+=("${root}$(python_get_sitedir)/$1") + eval "search_paths+=(\"\${root}$1\")" done + else + search_paths+=("${root}$1") fi - shift - done - else - # Deprecated part of python_mod_cleanup() - # ewarn - # ewarn "Deprecation Warning: Usage of ${FUNCNAME}() in packages not supporting installation" - # ewarn "for multiple Python ABIs in EAPI <=2 is deprecated and will be disallowed on 2011-06-01." - # ewarn "Use EAPI >=3 and call ${FUNCNAME}() with paths having appropriate syntax." - # ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." - # ewarn - - search_paths=("${@#/}") - search_paths=("${search_paths[@]/#/${root}/}") - fi - else - ewarn - ewarn "Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be" - ewarn "disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules." - ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." - ewarn - - 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_paths+=("${sitedir}") - fi + else + for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do + search_paths+=("${root}$(python_get_sitedir)/$1") done fi + shift done - for sitedir in "${root}"/usr/share/jython-*/Lib/site-packages; do - if [[ -d "${sitedir}" ]]; then - search_paths+=("${sitedir}") - fi - done + else + # Deprecated part of python_mod_cleanup() + # ewarn + # ewarn "Deprecation Warning: Usage of ${FUNCNAME}() in packages not supporting installation" + # ewarn "for multiple Python ABIs in EAPI <=2 is deprecated and will be disallowed on 2011-06-01." + # ewarn "Use EAPI >=3 and call ${FUNCNAME}() with paths having appropriate syntax." + # ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." + # ewarn + + search_paths=("${@#/}") + search_paths=("${search_paths[@]/#/${root}/}") fi _python_clean_compiled_modules "${search_paths[@]}"