/[gentoo-x86]/eclass/python.eclass
Gentoo

Diff of /eclass/python.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.97 Revision 1.99
1# Copyright 1999-2010 Gentoo Foundation 1# Copyright 1999-2010 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.97 2010/05/17 18:01:59 arfrever Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.99 2010/05/25 19:49:54 arfrever Exp $
4 4
5# @ECLASS: python.eclass 5# @ECLASS: python.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# Gentoo Python Project <python@gentoo.org> 7# Gentoo Python Project <python@gentoo.org>
8# @BLURB: Eclass for Python packages 8# @BLURB: Eclass for Python packages
327python_pkg_setup() { 327python_pkg_setup() {
328 # Check if phase is pkg_setup(). 328 # Check if phase is pkg_setup().
329 [[ "${EBUILD_PHASE}" != "setup" ]] && die "${FUNCNAME}() can be used only in pkg_setup() phase" 329 [[ "${EBUILD_PHASE}" != "setup" ]] && die "${FUNCNAME}() can be used only in pkg_setup() phase"
330 330
331 if _python_package_supporting_installation_for_multiple_python_abis; then 331 if _python_package_supporting_installation_for_multiple_python_abis; then
332 validate_PYTHON_ABIS 332 _python_calculate_PYTHON_ABIS
333 export EPYTHON="$(PYTHON -f)" 333 export EPYTHON="$(PYTHON -f)"
334 else 334 else
335 PYTHON_ABI="$(PYTHON --ABI)" 335 PYTHON_ABI="${PYTHON_ABI:-$(PYTHON --ABI)}"
336 fi 336 fi
337 337
338 if ! has "${EAPI:-0}" 0 1 && [[ -n "${PYTHON_USE_WITH}" || -n "${PYTHON_USE_WITH_OR}" ]]; then 338 if ! has "${EAPI:-0}" 0 1 && [[ -n "${PYTHON_USE_WITH}" || -n "${PYTHON_USE_WITH_OR}" ]]; then
339 if [[ "${PYTHON_USE_WITH_OPT}" ]]; then 339 if [[ "${PYTHON_USE_WITH_OPT}" ]]; then
340 if [[ "${PYTHON_USE_WITH_OPT}" == !* ]]; then 340 if [[ "${PYTHON_USE_WITH_OPT}" == !* ]]; then
499 for file in "${files[@]}"; do 499 for file in "${files[@]}"; do
500 if [[ "${quiet}" == "0" ]]; then 500 if [[ "${quiet}" == "0" ]]; then
501 ewarn " ${file}" 501 ewarn " ${file}"
502 fi 502 fi
503 rm -f "${file}" 503 rm -f "${file}"
504
505 # Delete empty __pycache__ directories.
506 if [[ "${file%/*}" == *"/__pycache__" ]]; then
507 rmdir "${file%/*}" 2> /dev/null
508 fi
504 done 509 done
505 fi 510 fi
506 511
507 python_clean_sitedirs() { 512 python_clean_sitedirs() {
513 if [[ -d "${ED}$(python_get_sitedir)" ]]; then
508 find "${ED}$(python_get_sitedir)" "(" -name "*.c" -o -name "*.h" -o -name "*.la" ")" -type f -print0 | xargs -0 rm -f 514 find "${ED}$(python_get_sitedir)" "(" -name "*.c" -o -name "*.h" -o -name "*.la" ")" -type f -print0 | xargs -0 rm -f
515 fi
509 } 516 }
510 if _python_package_supporting_installation_for_multiple_python_abis; then 517 if _python_package_supporting_installation_for_multiple_python_abis; then
511 python_execute_function -q python_clean_sitedirs 518 python_execute_function -q python_clean_sitedirs
512 else 519 else
513 python_clean_sitedirs 520 python_clean_sitedirs
554 fi 561 fi
555fi 562fi
556 563
557unset PYTHON_ABIS 564unset PYTHON_ABIS
558 565
559# @FUNCTION: validate_PYTHON_ABIS 566_python_calculate_PYTHON_ABIS() {
560# @DESCRIPTION:
561# Ensure that PYTHON_ABIS variable has valid value.
562# This function usually should not be directly called in ebuilds.
563validate_PYTHON_ABIS() {
564 if ! _python_package_supporting_installation_for_multiple_python_abis; then 567 if ! _python_package_supporting_installation_for_multiple_python_abis; then
565 die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs" 568 die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
566 fi 569 fi
567 570
568 _python_initial_sanity_checks 571 _python_initial_sanity_checks
815 [[ "${EBUILD_PHASE}" == "postinst" ]] && action="Postinstallation" 818 [[ "${EBUILD_PHASE}" == "postinst" ]] && action="Postinstallation"
816 [[ "${EBUILD_PHASE}" == "prerm" ]] && action="Preuninstallation" 819 [[ "${EBUILD_PHASE}" == "prerm" ]] && action="Preuninstallation"
817 [[ "${EBUILD_PHASE}" == "postrm" ]] && action="Postuninstallation" 820 [[ "${EBUILD_PHASE}" == "postrm" ]] && action="Postuninstallation"
818 fi 821 fi
819 822
820 validate_PYTHON_ABIS 823 _python_calculate_PYTHON_ABIS
821 if [[ "${final_ABI}" == "1" ]]; then 824 if [[ "${final_ABI}" == "1" ]]; then
822 iterated_PYTHON_ABIS="$(PYTHON -f --ABI)" 825 iterated_PYTHON_ABIS="$(PYTHON -f --ABI)"
823 else 826 else
824 iterated_PYTHON_ABIS="${PYTHON_ABIS}" 827 iterated_PYTHON_ABIS="${PYTHON_ABIS}"
825 fi 828 fi
934 dirs=("${S%/}") 937 dirs=("${S%/}")
935 else 938 else
936 dirs=("$@") 939 dirs=("$@")
937 fi 940 fi
938 941
939 validate_PYTHON_ABIS 942 _python_calculate_PYTHON_ABIS
940 for PYTHON_ABI in ${PYTHON_ABIS}; do 943 for PYTHON_ABI in ${PYTHON_ABIS}; do
941 for dir in "${dirs[@]}"; do 944 for dir in "${dirs[@]}"; do
942 cp -pr "${dir}" "${dir}-${PYTHON_ABI}" > /dev/null || die "Copying of sources failed" 945 cp -pr "${dir}" "${dir}-${PYTHON_ABI}" > /dev/null || die "Copying of sources failed"
943 done 946 done
944 done 947 done
986 989
987 if [[ "$#" -eq 0 ]]; then 990 if [[ "$#" -eq 0 ]]; then
988 die "${FUNCNAME}(): Missing arguments" 991 die "${FUNCNAME}(): Missing arguments"
989 fi 992 fi
990 993
991 validate_PYTHON_ABIS 994 _python_calculate_PYTHON_ABIS
992 for PYTHON_ABI in "${_CPYTHON2_SUPPORTED_ABIS[@]}"; do 995 for PYTHON_ABI in "${_CPYTHON2_SUPPORTED_ABIS[@]}"; do
993 if has "${PYTHON_ABI}" ${PYTHON_ABIS}; then 996 if has "${PYTHON_ABI}" ${PYTHON_ABIS}; then
994 python2_enabled="1" 997 python2_enabled="1"
995 fi 998 fi
996 done 999 done
1161python_set_active_version() { 1164python_set_active_version() {
1162 if _python_package_supporting_installation_for_multiple_python_abis; then 1165 if _python_package_supporting_installation_for_multiple_python_abis; then
1163 die "${FUNCNAME}() cannot be used in ebuilds of packages supporting installation for multiple Python ABIs" 1166 die "${FUNCNAME}() cannot be used in ebuilds of packages supporting installation for multiple Python ABIs"
1164 fi 1167 fi
1165 1168
1166 if [[ -n "${PYTHON_PKG_SETUP_EXECUTED}" ]]; then
1167 die "${FUNCNAME}() should be called before python_pkg_setup()"
1168 fi
1169
1170 if [[ "$#" -ne 1 ]]; then 1169 if [[ "$#" -ne 1 ]]; then
1171 die "${FUNCNAME}() requires 1 argument" 1170 die "${FUNCNAME}() requires 1 argument"
1172 fi 1171 fi
1173 1172
1174 _python_initial_sanity_checks 1173 _python_initial_sanity_checks
1296 if [[ "$#" -eq 0 ]]; then 1295 if [[ "$#" -eq 0 ]]; then
1297 if [[ "${final_ABI}" == "1" ]]; then 1296 if [[ "${final_ABI}" == "1" ]]; then
1298 if ! _python_package_supporting_installation_for_multiple_python_abis; then 1297 if ! _python_package_supporting_installation_for_multiple_python_abis; then
1299 die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs" 1298 die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
1300 fi 1299 fi
1301 validate_PYTHON_ABIS 1300 _python_calculate_PYTHON_ABIS
1302 PYTHON_ABI="${PYTHON_ABIS##* }" 1301 PYTHON_ABI="${PYTHON_ABIS##* }"
1303 elif [[ "${python2}" == "1" ]]; then 1302 elif [[ "${python2}" == "1" ]]; then
1304 PYTHON_ABI="$(eselect python show --python2 --ABI)" 1303 PYTHON_ABI="$(eselect python show --python2 --ABI)"
1305 if [[ -z "${PYTHON_ABI}" ]]; then 1304 if [[ -z "${PYTHON_ABI}" ]]; then
1306 die "${FUNCNAME}(): Active version of Python 2 not set" 1305 die "${FUNCNAME}(): Active version of Python 2 not set"
1315 die "${FUNCNAME}(): Internal error in \`eselect python show --python3\`" 1314 die "${FUNCNAME}(): Internal error in \`eselect python show --python3\`"
1316 fi 1315 fi
1317 elif ! _python_package_supporting_installation_for_multiple_python_abis; then 1316 elif ! _python_package_supporting_installation_for_multiple_python_abis; then
1318 PYTHON_ABI="$("${EPREFIX}/usr/bin/python" -c "${_PYTHON_ABI_EXTRACTION_COMMAND}")" 1317 PYTHON_ABI="$("${EPREFIX}/usr/bin/python" -c "${_PYTHON_ABI_EXTRACTION_COMMAND}")"
1319 if [[ -z "${PYTHON_ABI}" ]]; then 1318 if [[ -z "${PYTHON_ABI}" ]]; then
1320 die "${FUNCNAME}(): Main active version of Python not set" 1319 die "${FUNCNAME}(): Failure of extraction of locally active version of Python"
1321 fi 1320 fi
1322 elif [[ -z "${PYTHON_ABI}" ]]; then 1321 elif [[ -z "${PYTHON_ABI}" ]]; then
1323 die "${FUNCNAME}(): Invalid usage: ${FUNCNAME}() should be used in ABI-specific local scope" 1322 die "${FUNCNAME}(): Invalid usage: ${FUNCNAME}() should be used in ABI-specific local scope"
1324 fi 1323 fi
1325 elif [[ "$#" -eq 1 ]]; then 1324 elif [[ "$#" -eq 1 ]]; then
1943 dir="${compiled_file%/*}" 1942 dir="${compiled_file%/*}"
1944 dir="${dir##*/}" 1943 dir="${dir##*/}"
1945 if [[ "${compiled_file}" == *.py[co] ]]; then 1944 if [[ "${compiled_file}" == *.py[co] ]]; then
1946 if [[ "${dir}" == "__pycache__" ]]; then 1945 if [[ "${dir}" == "__pycache__" ]]; then
1947 base_module_name="${compiled_file##*/}" 1946 base_module_name="${compiled_file##*/}"
1948 base_module_name="${base_module_name%%.*py[co]}" 1947 base_module_name="${base_module_name%.*py[co]}"
1948 base_module_name="${base_module_name%.*}"
1949 py_file="${compiled_file%__pycache__/*}${base_module_name}.py" 1949 py_file="${compiled_file%__pycache__/*}${base_module_name}.py"
1950 else 1950 else
1951 py_file="${compiled_file%[co]}" 1951 py_file="${compiled_file%[co]}"
1952 fi 1952 fi
1953 if [[ "${EBUILD_PHASE}" == "postinst" ]]; then 1953 if [[ "${EBUILD_PHASE}" == "postinst" ]]; then
2022 fi 2022 fi
2023 2023
2024 # Strip trailing slash from EROOT. 2024 # Strip trailing slash from EROOT.
2025 root="${EROOT%/}" 2025 root="${EROOT%/}"
2026 2026
2027 # Respect EROOT and options passed to compileall.py.
2028 while (($#)); do 2027 while (($#)); do
2029 case "$1" in 2028 case "$1" in
2030 -l|-f|-q) 2029 -l|-f|-q)
2031 options+=("$1") 2030 options+=("$1")
2032 ;; 2031 ;;
2036 ;; 2035 ;;
2037 -*) 2036 -*)
2038 ewarn "${FUNCNAME}(): Ignoring option '$1'" 2037 ewarn "${FUNCNAME}(): Ignoring option '$1'"
2039 ;; 2038 ;;
2040 *) 2039 *)
2041 if ! _python_implementation && [[ "$1" =~ ^/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then
2042 die "${FUNCNAME}(): Paths of directories / files in site-packages directories must be relative to site-packages directories"
2043 elif [[ "$1" =~ ^/ ]]; then
2044 if _python_package_supporting_installation_for_multiple_python_abis; then
2045 die "${FUNCNAME}(): Absolute paths cannot be used in ebuilds of packages supporting installation for multiple Python ABIs"
2046 fi
2047 if [[ -d "${root}$1" ]]; then
2048 other_dirs+=("${root}$1")
2049 elif [[ -f "${root}$1" ]]; then
2050 other_files+=("${root}$1")
2051 elif [[ -e "${root}$1" ]]; then
2052 ewarn "'${root}$1' is not a file or a directory!"
2053 else
2054 ewarn "'${root}$1' does not exist!"
2055 fi
2056 else
2057 for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
2058 if [[ -d "${root}$(python_get_sitedir)/$1" ]]; then
2059 site_packages_dirs+=("$1")
2060 break 2040 break
2061 elif [[ -f "${root}$(python_get_sitedir)/$1" ]]; then
2062 site_packages_files+=("$1")
2063 break
2064 elif [[ -e "${root}$(python_get_sitedir)/$1" ]]; then
2065 ewarn "'$1' is not a file or a directory!"
2066 else
2067 ewarn "'$1' does not exist!"
2068 fi
2069 done
2070 fi
2071 ;; 2041 ;;
2072 esac 2042 esac
2043 shift
2044 done
2045
2046 if [[ "$#" -eq 0 ]]; then
2047 _python_set_color_variables
2048
2049 echo
2050 echo " ${_RED}*${_NORMAL} ${_RED}Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be${_NORMAL}"
2051 echo " ${_RED}*${_NORMAL} ${_RED}disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules.${_NORMAL}"
2052 echo " ${_RED}*${_NORMAL} ${_RED}The ebuild needs to be fixed. Please report a bug, if it has not been already reported.${_NORMAL}"
2053 echo
2054
2055 einfo &> /dev/null
2056 einfo "Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be" &> /dev/null
2057 einfo "disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules." &> /dev/null
2058 einfo "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." &> /dev/null
2059 einfo &> /dev/null
2060 fi
2061
2062 while (($#)); do
2063 if ! _python_implementation && [[ "$1" =~ ^/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then
2064 die "${FUNCNAME}(): Paths of directories / files in site-packages directories must be relative to site-packages directories"
2065 elif [[ "$1" =~ ^/ ]]; then
2066 if _python_package_supporting_installation_for_multiple_python_abis; then
2067 die "${FUNCNAME}(): Absolute paths cannot be used in ebuilds of packages supporting installation for multiple Python ABIs"
2068 fi
2069 if [[ -d "${root}$1" ]]; then
2070 other_dirs+=("${root}$1")
2071 elif [[ -f "${root}$1" ]]; then
2072 other_files+=("${root}$1")
2073 elif [[ -e "${root}$1" ]]; then
2074 eerror "'${root}$1' is not a file or a directory!"
2075 else
2076 eerror "'${root}$1' does not exist!"
2077 fi
2078 else
2079 for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
2080 if [[ -d "${root}$(python_get_sitedir)/$1" ]]; then
2081 site_packages_dirs+=("$1")
2082 break
2083 elif [[ -f "${root}$(python_get_sitedir)/$1" ]]; then
2084 site_packages_files+=("$1")
2085 break
2086 elif [[ -e "${root}$(python_get_sitedir)/$1" ]]; then
2087 eerror "'$1' is not a file or a directory!"
2088 else
2089 eerror "'$1' does not exist!"
2090 fi
2091 done
2092 fi
2073 shift 2093 shift
2074 done 2094 done
2075 2095
2076 # Set additional options. 2096 # Set additional options.
2077 options+=("-q") 2097 options+=("-q")
2117 if ((${#other_dirs[@]})) || ((${#other_files[@]})); then 2137 if ((${#other_dirs[@]})) || ((${#other_files[@]})); then
2118 return_code="0" 2138 return_code="0"
2119 ebegin "Compilation and optimization of Python modules placed outside of site-packages directories for $(python_get_implementation) $(python_get_version)" 2139 ebegin "Compilation and optimization of Python modules placed outside of site-packages directories for $(python_get_implementation) $(python_get_version)"
2120 if ((${#other_dirs[@]})); then 2140 if ((${#other_dirs[@]})); then
2121 "$(PYTHON ${PYTHON_ABI})" "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" || return_code="1" 2141 "$(PYTHON ${PYTHON_ABI})" "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" || return_code="1"
2122 if [[ "$(_python_get_implementation "${PYTHON_ABI-$(PYTHON --ABI)}")" != "Jython" ]]; then 2142 if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
2123 "$(PYTHON ${PYTHON_ABI})" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" &> /dev/null || return_code="1" 2143 "$(PYTHON ${PYTHON_ABI})" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" &> /dev/null || return_code="1"
2124 fi 2144 fi
2125 _python_clean_compiled_modules "${other_dirs[@]}" 2145 _python_clean_compiled_modules "${other_dirs[@]}"
2126 fi 2146 fi
2127 if ((${#other_files[@]})); then 2147 if ((${#other_files[@]})); then
2128 "$(PYTHON ${PYTHON_ABI})" "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" || return_code="1" 2148 "$(PYTHON ${PYTHON_ABI})" "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" || return_code="1"
2129 if [[ "$(_python_get_implementation "${PYTHON_ABI-$(PYTHON --ABI)}")" != "Jython" ]]; then 2149 if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
2130 "$(PYTHON ${PYTHON_ABI})" -O "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" &> /dev/null || return_code="1" 2150 "$(PYTHON ${PYTHON_ABI})" -O "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" &> /dev/null || return_code="1"
2131 fi 2151 fi
2132 _python_clean_compiled_modules "${other_dirs[@]}" 2152 _python_clean_compiled_modules "${other_dirs[@]}"
2133 fi 2153 fi
2134 eend "${return_code}" 2154 eend "${return_code}"
2135 fi 2155 fi
2136 else 2156 else
2157 # Deprecated part of python_mod_optimize()
2158
2137 local myroot mydirs=() myfiles=() myopts=() return_code="0" 2159 local myroot mydirs=() myfiles=() myopts=() return_code="0"
2138 2160
2139 # strip trailing slash 2161 # strip trailing slash
2140 myroot="${EROOT%/}" 2162 myroot="${EROOT%/}"
2141 2163
2151 ;; 2173 ;;
2152 -*) 2174 -*)
2153 ewarn "${FUNCNAME}(): Ignoring option '$1'" 2175 ewarn "${FUNCNAME}(): Ignoring option '$1'"
2154 ;; 2176 ;;
2155 *) 2177 *)
2156 if [[ -d "${myroot}/${1#/}" ]]; then 2178 break
2157 mydirs+=("${myroot}/${1#/}")
2158 elif [[ -f "${myroot}/${1#/}" ]]; then
2159 # Files are passed to python_mod_compile which is EROOT-aware
2160 myfiles+=("$1")
2161 elif [[ -e "${myroot}/${1#/}" ]]; then
2162 ewarn "${myroot}/${1#/} is not a file or directory!"
2163 else
2164 ewarn "${myroot}/${1#/} does not exist!"
2165 fi
2166 ;; 2179 ;;
2167 esac 2180 esac
2168 shift 2181 shift
2169 done 2182 done
2170 2183
2184 if [[ "$#" -eq 0 ]]; then
2185 _python_set_color_variables
2186
2187 echo
2188 echo " ${_RED}*${_NORMAL} ${_RED}Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be${_NORMAL}"
2189 echo " ${_RED}*${_NORMAL} ${_RED}disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules.${_NORMAL}"
2190 echo " ${_RED}*${_NORMAL} ${_RED}The ebuild needs to be fixed. Please report a bug, if it has not been already reported.${_NORMAL}"
2191 echo
2192
2193 einfo &> /dev/null
2194 einfo "Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be" &> /dev/null
2195 einfo "disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules." &> /dev/null
2196 einfo "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." &> /dev/null
2197 einfo &> /dev/null
2198 fi
2199
2200 while (($#)); do
2201 if [[ -d "${myroot}/${1#/}" ]]; then
2202 mydirs+=("${myroot}/${1#/}")
2203 elif [[ -f "${myroot}/${1#/}" ]]; then
2204 # Files are passed to python_mod_compile which is EROOT-aware
2205 myfiles+=("$1")
2206 elif [[ -e "${myroot}/${1#/}" ]]; then
2207 eerror "${myroot}/${1#/} is not a file or directory!"
2208 else
2209 eerror "${myroot}/${1#/} does not exist!"
2210 fi
2211 shift
2212 done
2213
2171 # set additional opts 2214 # set additional opts
2172 myopts+=(-q) 2215 myopts+=(-q)
2173 2216
2174 PYTHON_ABI="$(PYTHON --ABI)" 2217 PYTHON_ABI="${PYTHON_ABI:-$(PYTHON --ABI)}"
2175 2218
2176 ebegin "Compilation and optimization of Python modules for $(python_get_implementation) $(python_get_version)" 2219 ebegin "Compilation and optimization of Python modules for $(python_get_implementation) $(python_get_version)"
2177 if ((${#mydirs[@]})); then 2220 if ((${#mydirs[@]})); then
2178 "$(PYTHON ${PYTHON_ABI})" "${myroot}$(python_get_libdir)/compileall.py" "${myopts[@]}" "${mydirs[@]}" || return_code="1" 2221 "$(PYTHON ${PYTHON_ABI})" "${myroot}$(python_get_libdir)/compileall.py" "${myopts[@]}" "${mydirs[@]}" || return_code="1"
2179 "$(PYTHON ${PYTHON_ABI})" -O "${myroot}$(python_get_libdir)/compileall.py" "${myopts[@]}" "${mydirs[@]}" &> /dev/null || return_code="1" 2222 "$(PYTHON ${PYTHON_ABI})" -O "${myroot}$(python_get_libdir)/compileall.py" "${myopts[@]}" "${mydirs[@]}" &> /dev/null || return_code="1"
2217 fi 2260 fi
2218 2261
2219 # Strip trailing slash from EROOT. 2262 # Strip trailing slash from EROOT.
2220 root="${EROOT%/}" 2263 root="${EROOT%/}"
2221 2264
2222 if (($#)); then 2265 if [[ "$#" -gt 0 ]]; then
2223 if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then 2266 if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
2224 while (($#)); do 2267 while (($#)); do
2225 if ! _python_implementation && [[ "$1" =~ ^/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then 2268 if ! _python_implementation && [[ "$1" =~ ^/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then
2226 die "${FUNCNAME}(): Paths of directories / files in site-packages directories must be relative to site-packages directories" 2269 die "${FUNCNAME}(): Paths of directories / files in site-packages directories must be relative to site-packages directories"
2227 elif [[ "$1" =~ ^/ ]]; then 2270 elif [[ "$1" =~ ^/ ]]; then
2235 done 2278 done
2236 fi 2279 fi
2237 shift 2280 shift
2238 done 2281 done
2239 else 2282 else
2283 # Deprecated part of python_mod_cleanup()
2284
2240 search_paths=("${@#/}") 2285 search_paths=("${@#/}")
2241 search_paths=("${search_paths[@]/#/${root}/}") 2286 search_paths=("${search_paths[@]/#/${root}/}")
2242 fi 2287 fi
2243 else 2288 else
2289 _python_set_color_variables
2290
2291 echo
2292 echo " ${_RED}*${_NORMAL} ${_RED}Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be${_NORMAL}"
2293 echo " ${_RED}*${_NORMAL} ${_RED}disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules.${_NORMAL}"
2294 echo " ${_RED}*${_NORMAL} ${_RED}The ebuild needs to be fixed. Please report a bug, if it has not been already reported.${_NORMAL}"
2295 echo
2296
2297 einfo &> /dev/null
2298 einfo "Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be" &> /dev/null
2299 einfo "disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules." &> /dev/null
2300 einfo "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." &> /dev/null
2301 einfo &> /dev/null
2302
2244 for dir in "${root}"/usr/lib*; do 2303 for dir in "${root}"/usr/lib*; do
2245 if [[ -d "${dir}" && ! -L "${dir}" ]]; then 2304 if [[ -d "${dir}" && ! -L "${dir}" ]]; then
2246 for sitedir in "${dir}"/python*/site-packages; do 2305 for sitedir in "${dir}"/python*/site-packages; do
2247 if [[ -d "${sitedir}" ]]; then 2306 if [[ -d "${sitedir}" ]]; then
2248 search_paths+=("${sitedir}") 2307 search_paths+=("${sitedir}")
2327 echo " ${_RED}*${_NORMAL} ${_RED}Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01.${_NORMAL}" 2386 echo " ${_RED}*${_NORMAL} ${_RED}Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01.${_NORMAL}"
2328 echo " ${_RED}*${_NORMAL} ${_RED}Use USE dependencies and/or has_version() instead of ${FUNCNAME}().${_NORMAL}" 2387 echo " ${_RED}*${_NORMAL} ${_RED}Use USE dependencies and/or has_version() instead of ${FUNCNAME}().${_NORMAL}"
2329 echo " ${_RED}*${_NORMAL} ${_RED}The ebuild needs to be fixed. Please report a bug, if it has not been already reported.${_NORMAL}" 2388 echo " ${_RED}*${_NORMAL} ${_RED}The ebuild needs to be fixed. Please report a bug, if it has not been already reported.${_NORMAL}"
2330 echo 2389 echo
2331 2390
2332 einfo &> /dev/null 2391 eerror &> /dev/null
2333 einfo "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01." &> /dev/null 2392 eerror "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01." &> /dev/null
2334 einfo "Use USE dependencies and/or has_version() instead of ${FUNCNAME}()." &> /dev/null 2393 eerror "Use USE dependencies and/or has_version() instead of ${FUNCNAME}()." &> /dev/null
2335 einfo "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." &> /dev/null 2394 eerror "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." &> /dev/null
2336 einfo &> /dev/null 2395 eerror &> /dev/null
2337 2396
2338 if [[ "$#" -ne 1 ]]; then 2397 if [[ "$#" -ne 1 ]]; then
2339 die "${FUNCNAME}() requires 1 argument" 2398 die "${FUNCNAME}() requires 1 argument"
2340 fi 2399 fi
2341 "$(PYTHON ${PYTHON_ABI})" -c "import $1" &> /dev/null 2400 "$(PYTHON ${PYTHON_ABI})" -c "import $1" &> /dev/null
2358 echo " ${_RED}*${_NORMAL} ${_RED}Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01.${_NORMAL}" 2417 echo " ${_RED}*${_NORMAL} ${_RED}Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01.${_NORMAL}"
2359 echo " ${_RED}*${_NORMAL} ${_RED}Use PYTHON_USE_WITH=\"xml\" and python_pkg_setup() instead of ${FUNCNAME}().${_NORMAL}" 2418 echo " ${_RED}*${_NORMAL} ${_RED}Use PYTHON_USE_WITH=\"xml\" and python_pkg_setup() instead of ${FUNCNAME}().${_NORMAL}"
2360 echo " ${_RED}*${_NORMAL} ${_RED}The ebuild needs to be fixed. Please report a bug, if it has not been already reported.${_NORMAL}" 2419 echo " ${_RED}*${_NORMAL} ${_RED}The ebuild needs to be fixed. Please report a bug, if it has not been already reported.${_NORMAL}"
2361 echo 2420 echo
2362 2421
2363 einfo &> /dev/null 2422 eerror &> /dev/null
2364 einfo "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01." &> /dev/null 2423 eerror "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01." &> /dev/null
2365 einfo "Use PYTHON_USE_WITH=\"xml\" and python_pkg_setup() instead of ${FUNCNAME}()." &> /dev/null 2424 eerror "Use PYTHON_USE_WITH=\"xml\" and python_pkg_setup() instead of ${FUNCNAME}()." &> /dev/null
2366 einfo "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." &> /dev/null 2425 eerror "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." &> /dev/null
2367 einfo &> /dev/null 2426 eerror &> /dev/null
2368 fi 2427 fi
2369 2428
2370 if ! "$(PYTHON ${PYTHON_ABI})" -c "from sys import version_info 2429 if ! "$(PYTHON ${PYTHON_ABI})" -c "from sys import version_info
2371if version_info[0] == 3: 2430if version_info[0] == 3:
2372 import tkinter 2431 import tkinter
2393 eerror "Use python_mod_optimize() instead of ${FUNCNAME}()." 2452 eerror "Use python_mod_optimize() instead of ${FUNCNAME}()."
2394 die "${FUNCNAME}() cannot be used in this EAPI" 2453 die "${FUNCNAME}() cannot be used in this EAPI"
2395 fi 2454 fi
2396 2455
2397 _python_initialize_prefix_variables 2456 _python_initialize_prefix_variables
2457 _python_set_color_variables
2458
2459 if [[ "${FUNCNAME[1]}" != "python_mod_optimize" ]]; then
2460 echo
2461 echo " ${_RED}*${_NORMAL} ${_RED}Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-09-01.${_NORMAL}"
2462 echo " ${_RED}*${_NORMAL} ${_RED}Use python_mod_optimize() instead of ${FUNCNAME}().${_NORMAL}"
2463 echo " ${_RED}*${_NORMAL} ${_RED}The ebuild needs to be fixed. Please report a bug, if it has not been already reported.${_NORMAL}"
2464 echo
2465
2466 einfo &> /dev/null
2467 einfo "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-09-01." &> /dev/null
2468 einfo "Use python_mod_optimize() instead of ${FUNCNAME}()." &> /dev/null
2469 einfo "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." &> /dev/null
2470 einfo &> /dev/null
2471 fi
2398 2472
2399 local f myroot myfiles=() 2473 local f myroot myfiles=()
2400 2474
2401 # Check if phase is pkg_postinst() 2475 # Check if phase is pkg_postinst()
2402 [[ "${EBUILD_PHASE}" != "postinst" ]] && die "${FUNCNAME}() can be used only in pkg_postinst() phase" 2476 [[ "${EBUILD_PHASE}" != "postinst" ]] && die "${FUNCNAME}() can be used only in pkg_postinst() phase"

Legend:
Removed from v.1.97  
changed lines
  Added in v.1.99

  ViewVC Help
Powered by ViewVC 1.1.20