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

Diff of /eclass/python.eclass

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

Revision 1.101 Revision 1.103
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.101 2010/07/17 23:02:14 arfrever Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.103 2010/10/03 00:38:13 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
163 if ! has "${EAPI:-0}" 0 1 2; then 163 if ! has "${EAPI:-0}" 0 1 2; then
164 eerror "Use PYTHON_DEPEND variable instead of NEED_PYTHON variable." 164 eerror "Use PYTHON_DEPEND variable instead of NEED_PYTHON variable."
165 die "NEED_PYTHON variable cannot be used in this EAPI" 165 die "NEED_PYTHON variable cannot be used in this EAPI"
166 fi 166 fi
167 167
168 if [[ "${NOCOLOR:-false}" =~ ^(false|no)$ ]]; then 168 ewarn
169 _RED=$'\e[1;31m' 169 ewarn "\"${EBUILD}\":"
170 _NORMAL=$'\e[0m'
171 else
172 _RED=
173 _NORMAL=
174 fi
175
176 echo
177 echo " ${_RED}*${_NORMAL} ${_RED}Deprecation Warning: NEED_PYTHON variable is deprecated and will be banned on 2010-10-01.${_NORMAL}" 170 ewarn "Deprecation Warning: NEED_PYTHON variable is deprecated and will be banned on 2010-10-01."
178 echo " ${_RED}*${_NORMAL} ${_RED}Use PYTHON_DEPEND variable instead of NEED_PYTHON variable.${_NORMAL}" 171 ewarn "Use PYTHON_DEPEND variable instead of NEED_PYTHON variable."
179 echo " ${_RED}*${_NORMAL} ${_RED}The ebuild needs to be fixed. Please report a bug, if it has not been already reported.${_NORMAL}" 172 ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported."
180 echo 173 ewarn
181 174
182 unset _BOLD _NORMAL 175 unset _BOLD _NORMAL
183 176
184 _PYTHON_ATOMS=(">=dev-lang/python-${NEED_PYTHON}") 177 _PYTHON_ATOMS=(">=dev-lang/python-${NEED_PYTHON}")
185 DEPEND+="${DEPEND:+ }${_PYTHON_ATOMS[@]}" 178 DEPEND+="${DEPEND:+ }${_PYTHON_ATOMS[@]}"
315 done 308 done
316 fi 309 fi
317 PYTHON_SANITY_CHECKS_EXECUTED="1" 310 PYTHON_SANITY_CHECKS_EXECUTED="1"
318} 311}
319 312
313# @ECLASS-VARIABLE: PYTHON_COLORS
314# @DESCRIPTION:
315# User-configurable colored output.
316PYTHON_COLORS="${PYTHON_COLORS:-0}"
317
320_python_set_color_variables() { 318_python_set_color_variables() {
321 if [[ "${NOCOLOR:-false}" =~ ^(false|no)$ ]]; then 319 if [[ "${PYTHON_COLORS}" != "0" && "${NOCOLOR:-false}" =~ ^(false|no)$ ]]; then
322 _BOLD=$'\e[1m' 320 _BOLD=$'\e[1m'
323 _RED=$'\e[1;31m' 321 _RED=$'\e[1;31m'
324 _GREEN=$'\e[1;32m' 322 _GREEN=$'\e[1;32m'
325 _BLUE=$'\e[1;34m' 323 _BLUE=$'\e[1;34m'
326 _CYAN=$'\e[1;36m' 324 _CYAN=$'\e[1;36m'
925 for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do 923 for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
926 _python_prepare_flags 924 _python_prepare_flags
927 925
928 if [[ "${quiet}" == "0" ]]; then 926 if [[ "${quiet}" == "0" ]]; then
929 if [[ -n "${action_message_template}" ]]; then 927 if [[ -n "${action_message_template}" ]]; then
930 action_message="$(eval echo -n "${action_message_template}")" 928 eval "action_message=\"${action_message_template}\""
931 else 929 else
932 action_message="${action} of ${CATEGORY}/${PF} with $(python_get_implementation) $(python_get_version)..." 930 action_message="${action} of ${CATEGORY}/${PF} with $(python_get_implementation) $(python_get_version)..."
933 fi 931 fi
934 echo " ${_GREEN}*${_NORMAL} ${_BLUE}${action_message}${_NORMAL}" 932 echo " ${_GREEN}*${_NORMAL} ${_BLUE}${action_message}${_NORMAL}"
935 fi 933 fi
959 957
960 _python_restore_flags 958 _python_restore_flags
961 959
962 if [[ "${return_code}" -ne 0 ]]; then 960 if [[ "${return_code}" -ne 0 ]]; then
963 if [[ -n "${failure_message_template}" ]]; then 961 if [[ -n "${failure_message_template}" ]]; then
964 failure_message="$(eval echo -n "${failure_message_template}")" 962 eval "failure_message=\"${failure_message_template}\""
965 else 963 else
966 failure_message="${action} failed with $(python_get_implementation) $(python_get_version) in ${function}() function" 964 failure_message="${action} failed with $(python_get_implementation) $(python_get_version) in ${function}() function"
967 fi 965 fi
968 966
969 if [[ "${nonfatal}" == "1" ]]; then 967 if [[ "${nonfatal}" == "1" ]]; then
970 if [[ "${quiet}" == "0" ]]; then 968 if [[ "${quiet}" == "0" ]]; then
971 ewarn "${_RED}${failure_message}${_NORMAL}" 969 ewarn "${failure_message}"
972 fi 970 fi
973 elif [[ "${final_ABI}" == "0" ]] && has "${PYTHON_ABI}" ${FAILURE_TOLERANT_PYTHON_ABIS}; then 971 elif [[ "${final_ABI}" == "0" ]] && has "${PYTHON_ABI}" ${FAILURE_TOLERANT_PYTHON_ABIS}; then
974 if [[ "${EBUILD_PHASE}" != "test" ]] || ! has test-fail-continue ${FEATURES}; then 972 if [[ "${EBUILD_PHASE}" != "test" ]] || ! has test-fail-continue ${FEATURES}; then
975 local enabled_PYTHON_ABIS= other_PYTHON_ABI 973 local enabled_PYTHON_ABIS= other_PYTHON_ABI
976 for other_PYTHON_ABI in ${PYTHON_ABIS}; do 974 for other_PYTHON_ABI in ${PYTHON_ABIS}; do
977 [[ "${other_PYTHON_ABI}" != "${PYTHON_ABI}" ]] && enabled_PYTHON_ABIS+="${enabled_PYTHON_ABIS:+ }${other_PYTHON_ABI}" 975 [[ "${other_PYTHON_ABI}" != "${PYTHON_ABI}" ]] && enabled_PYTHON_ABIS+="${enabled_PYTHON_ABIS:+ }${other_PYTHON_ABI}"
978 done 976 done
979 export PYTHON_ABIS="${enabled_PYTHON_ABIS}" 977 export PYTHON_ABIS="${enabled_PYTHON_ABIS}"
980 fi 978 fi
981 if [[ "${quiet}" == "0" ]]; then 979 if [[ "${quiet}" == "0" ]]; then
982 ewarn "${_RED}${failure_message}${_NORMAL}" 980 ewarn "${failure_message}"
983 fi 981 fi
984 if [[ -z "${PYTHON_ABIS}" ]]; then 982 if [[ -z "${PYTHON_ABIS}" ]]; then
985 die "${function}() function failed with all enabled Python ABIs" 983 die "${function}() function failed with all enabled Python ABIs"
986 fi 984 fi
987 else 985 else
1925 done 1923 done
1926 1924
1927 python_test_function() { 1925 python_test_function() {
1928 local evaluated_PYTHONPATH 1926 local evaluated_PYTHONPATH
1929 1927
1930 evaluated_PYTHONPATH="$(eval echo -n "${PYTHONPATH_template}")" 1928 eval "evaluated_PYTHONPATH=\"${PYTHONPATH_template}\""
1931 1929
1932 _python_test_hook pre 1930 _python_test_hook pre
1933 1931
1934 if [[ -n "${evaluated_PYTHONPATH}" ]]; then 1932 if [[ -n "${evaluated_PYTHONPATH}" ]]; then
1935 echo ${_BOLD}PYTHONPATH="${evaluated_PYTHONPATH}" nosetests --verbosity="${PYTHON_TEST_VERBOSITY}" "$@"${_NORMAL} 1933 echo ${_BOLD}PYTHONPATH="${evaluated_PYTHONPATH}" nosetests --verbosity="${PYTHON_TEST_VERBOSITY}" "$@"${_NORMAL}
1989 done 1987 done
1990 1988
1991 python_test_function() { 1989 python_test_function() {
1992 local evaluated_PYTHONPATH 1990 local evaluated_PYTHONPATH
1993 1991
1994 evaluated_PYTHONPATH="$(eval echo -n "${PYTHONPATH_template}")" 1992 eval "evaluated_PYTHONPATH=\"${PYTHONPATH_template}\""
1995 1993
1996 _python_test_hook pre 1994 _python_test_hook pre
1997 1995
1998 if [[ -n "${evaluated_PYTHONPATH}" ]]; then 1996 if [[ -n "${evaluated_PYTHONPATH}" ]]; then
1999 echo ${_BOLD}PYTHONPATH="${evaluated_PYTHONPATH}" py.test $([[ "${PYTHON_TEST_VERBOSITY}" -ge 2 ]] && echo -v) "$@"${_NORMAL} 1997 echo ${_BOLD}PYTHONPATH="${evaluated_PYTHONPATH}" py.test $([[ "${PYTHON_TEST_VERBOSITY}" -ge 2 ]] && echo -v) "$@"${_NORMAL}
2053 done 2051 done
2054 2052
2055 python_test_function() { 2053 python_test_function() {
2056 local evaluated_PYTHONPATH 2054 local evaluated_PYTHONPATH
2057 2055
2058 evaluated_PYTHONPATH="$(eval echo -n "${PYTHONPATH_template}")" 2056 eval "evaluated_PYTHONPATH=\"${PYTHONPATH_template}\""
2059 2057
2060 _python_test_hook pre 2058 _python_test_hook pre
2061 2059
2062 if [[ -n "${evaluated_PYTHONPATH}" ]]; then 2060 if [[ -n "${evaluated_PYTHONPATH}" ]]; then
2063 echo ${_BOLD}PYTHONPATH="${evaluated_PYTHONPATH}" trial $([[ "${PYTHON_TEST_VERBOSITY}" -ge 4 ]] && echo --spew) "$@"${_NORMAL} 2061 echo ${_BOLD}PYTHONPATH="${evaluated_PYTHONPATH}" trial $([[ "${PYTHON_TEST_VERBOSITY}" -ge 4 ]] && echo --spew) "$@"${_NORMAL}
2223 # Check if phase is pkg_postinst(). 2221 # Check if phase is pkg_postinst().
2224 [[ "${EBUILD_PHASE}" != "postinst" ]] && die "${FUNCNAME}() can be used only in pkg_postinst() phase" 2222 [[ "${EBUILD_PHASE}" != "postinst" ]] && die "${FUNCNAME}() can be used only in pkg_postinst() phase"
2225 2223
2226 if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then 2224 if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
2227 # PYTHON_ABI variable cannot be local in packages not supporting installation for multiple Python ABIs. 2225 # PYTHON_ABI variable cannot be local in packages not supporting installation for multiple Python ABIs.
2228 local dir file iterated_PYTHON_ABIS options=() other_dirs=() other_files=() previous_PYTHON_ABI="${PYTHON_ABI}" return_code root site_packages_absolute_dirs=() site_packages_dirs=() site_packages_absolute_files=() site_packages_files=() 2226 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=()
2229 2227
2230 if _python_package_supporting_installation_for_multiple_python_abis; then 2228 if _python_package_supporting_installation_for_multiple_python_abis; then
2231 if has "${EAPI:-0}" 0 1 2 3 && [[ -z "${PYTHON_ABIS}" ]]; then 2229 if has "${EAPI:-0}" 0 1 2 3 && [[ -z "${PYTHON_ABIS}" ]]; then
2232 die "${FUNCNAME}(): python_pkg_setup() or python_execute_function() not called" 2230 die "${FUNCNAME}(): python_pkg_setup() or python_execute_function() not called"
2233 fi 2231 fi
2243 # Strip trailing slash from EROOT. 2241 # Strip trailing slash from EROOT.
2244 root="${EROOT%/}" 2242 root="${EROOT%/}"
2245 2243
2246 while (($#)); do 2244 while (($#)); do
2247 case "$1" in 2245 case "$1" in
2246 --allow-evaluated-non-sitedir-paths)
2247 allow_evaluated_non_sitedir_paths="1"
2248 ;;
2248 -l|-f|-q) 2249 -l|-f|-q)
2249 options+=("$1") 2250 options+=("$1")
2250 ;; 2251 ;;
2251 -d|-x) 2252 -d|-x)
2252 options+=("$1" "$2") 2253 options+=("$1" "$2")
2264 ;; 2265 ;;
2265 esac 2266 esac
2266 shift 2267 shift
2267 done 2268 done
2268 2269
2270 if [[ "${allow_evaluated_non_sitedir_paths}" == "1" ]] && ! _python_package_supporting_installation_for_multiple_python_abis; then
2271 die "${FUNCNAME}(): '--allow-evaluated-non-sitedir-paths' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
2272 fi
2273
2269 if [[ "$#" -eq 0 ]]; then 2274 if [[ "$#" -eq 0 ]]; then
2270 _python_set_color_variables 2275 ewarn
2271
2272 echo
2273 echo " ${_RED}*${_NORMAL} ${_RED}Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be${_NORMAL}"
2274 echo " ${_RED}*${_NORMAL} ${_RED}disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules.${_NORMAL}"
2275 echo " ${_RED}*${_NORMAL} ${_RED}The ebuild needs to be fixed. Please report a bug, if it has not been already reported.${_NORMAL}"
2276 echo
2277
2278 einfo &> /dev/null
2279 einfo "Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be" &> /dev/null 2276 ewarn "Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be"
2280 einfo "disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules." &> /dev/null 2277 ewarn "disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules."
2281 einfo "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." &> /dev/null 2278 ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported."
2282 einfo &> /dev/null 2279 ewarn
2283 fi 2280 fi
2284 2281
2285 while (($#)); do 2282 while (($#)); do
2286 if [[ "$1" =~ ^($|(\.|\.\.|/)($|/)) ]]; then 2283 if [[ "$1" =~ ^($|(\.|\.\.|/)($|/)) ]]; then
2287 die "${FUNCNAME}(): Invalid argument '$1'" 2284 die "${FUNCNAME}(): Invalid argument '$1'"
2288 elif ! _python_implementation && [[ "$1" =~ ^/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then 2285 elif ! _python_implementation && [[ "$1" =~ ^/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then
2289 die "${FUNCNAME}(): Paths of directories / files in site-packages directories must be relative to site-packages directories" 2286 die "${FUNCNAME}(): Paths of directories / files in site-packages directories must be relative to site-packages directories"
2290 elif [[ "$1" =~ ^/ ]]; then 2287 elif [[ "$1" =~ ^/ ]]; then
2291 if _python_package_supporting_installation_for_multiple_python_abis; then 2288 if _python_package_supporting_installation_for_multiple_python_abis; then
2289 if [[ "${allow_evaluated_non_sitedir_paths}" != "1" ]]; then
2292 die "${FUNCNAME}(): Absolute paths cannot be used in ebuilds of packages supporting installation for multiple Python ABIs" 2290 die "${FUNCNAME}(): Absolute paths cannot be used in ebuilds of packages supporting installation for multiple Python ABIs"
2293 fi 2291 fi
2294 if [[ -d "${root}$1" ]]; then 2292 if [[ "$1" != *\$* ]]; then
2295 other_dirs+=("${root}$1") 2293 die "${FUNCNAME}(): '$1' has invalid syntax"
2296 elif [[ -f "${root}$1" ]]; then 2294 fi
2297 other_files+=("${root}$1") 2295 if [[ "$1" == *.py ]]; then
2298 elif [[ -e "${root}$1" ]]; then 2296 evaluated_files+=("$1")
2299 eerror "${FUNCNAME}(): '${root}$1' is not a regular file or a directory" 2297 else
2298 evaluated_dirs+=("$1")
2299 fi
2300 else 2300 else
2301 if [[ -d "${root}$1" ]]; then
2302 other_dirs+=("${root}$1")
2303 elif [[ -f "${root}$1" ]]; then
2304 other_files+=("${root}$1")
2305 elif [[ -e "${root}$1" ]]; then
2306 eerror "${FUNCNAME}(): '${root}$1' is not a regular file or a directory"
2307 else
2301 eerror "${FUNCNAME}(): '${root}$1' does not exist" 2308 eerror "${FUNCNAME}(): '${root}$1' does not exist"
2309 fi
2302 fi 2310 fi
2303 else 2311 else
2304 for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do 2312 for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
2305 if [[ -d "${root}$(python_get_sitedir)/$1" ]]; then 2313 if [[ -d "${root}$(python_get_sitedir)/$1" ]]; then
2306 site_packages_dirs+=("$1") 2314 site_packages_dirs+=("$1")
2320 2328
2321 # Set additional options. 2329 # Set additional options.
2322 options+=("-q") 2330 options+=("-q")
2323 2331
2324 for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do 2332 for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
2325 if ((${#site_packages_dirs[@]})) || ((${#site_packages_files[@]})); then 2333 if ((${#site_packages_dirs[@]})) || ((${#site_packages_files[@]})) || ((${#evaluated_dirs[@]})) || ((${#evaluated_files[@]})); then
2326 return_code="0" 2334 return_code="0"
2327 ebegin "Compilation and optimization of Python modules for $(python_get_implementation) $(python_get_version)" 2335 ebegin "Compilation and optimization of Python modules for $(python_get_implementation) $(python_get_version)"
2328 if ((${#site_packages_dirs[@]})); then 2336 if ((${#site_packages_dirs[@]})) || ((${#evaluated_dirs[@]})); then
2329 for dir in "${site_packages_dirs[@]}"; do 2337 for dir in "${site_packages_dirs[@]}"; do
2330 site_packages_absolute_dirs+=("${root}$(python_get_sitedir)/${dir}") 2338 dirs+=("${root}$(python_get_sitedir)/${dir}")
2331 done 2339 done
2340 for dir in "${evaluated_dirs[@]}"; do
2341 eval "dirs+=(\"\${root}${dir}\")"
2342 done
2332 "$(PYTHON)" "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${site_packages_absolute_dirs[@]}" || return_code="1" 2343 "$(PYTHON)" "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${dirs[@]}" || return_code="1"
2333 if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then 2344 if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
2334 "$(PYTHON)" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${site_packages_absolute_dirs[@]}" &> /dev/null || return_code="1" 2345 "$(PYTHON)" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${dirs[@]}" &> /dev/null || return_code="1"
2335 fi 2346 fi
2336 _python_clean_compiled_modules "${site_packages_absolute_dirs[@]}" 2347 _python_clean_compiled_modules "${dirs[@]}"
2337 fi 2348 fi
2338 if ((${#site_packages_files[@]})); then 2349 if ((${#site_packages_files[@]})) || ((${#evaluated_files[@]})); then
2339 for file in "${site_packages_files[@]}"; do 2350 for file in "${site_packages_files[@]}"; do
2340 site_packages_absolute_files+=("${root}$(python_get_sitedir)/${file}") 2351 files+=("${root}$(python_get_sitedir)/${file}")
2341 done 2352 done
2353 for file in "${evaluated_files[@]}"; do
2354 eval "files+=(\"\${root}${file}\")"
2355 done
2342 "$(PYTHON)" "${root}$(python_get_libdir)/py_compile.py" "${site_packages_absolute_files[@]}" || return_code="1" 2356 "$(PYTHON)" "${root}$(python_get_libdir)/py_compile.py" "${files[@]}" || return_code="1"
2343 if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then 2357 if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
2344 "$(PYTHON)" -O "${root}$(python_get_libdir)/py_compile.py" "${site_packages_absolute_files[@]}" &> /dev/null || return_code="1" 2358 "$(PYTHON)" -O "${root}$(python_get_libdir)/py_compile.py" "${files[@]}" &> /dev/null || return_code="1"
2345 fi 2359 fi
2346 _python_clean_compiled_modules "${site_packages_absolute_files[@]}" 2360 _python_clean_compiled_modules "${files[@]}"
2347 fi 2361 fi
2348 eend "${return_code}" 2362 eend "${return_code}"
2349 fi 2363 fi
2350 unset site_packages_absolute_dirs site_packages_absolute_files 2364 unset dirs files
2351 done 2365 done
2352 2366
2353 if _python_package_supporting_installation_for_multiple_python_abis; then 2367 if _python_package_supporting_installation_for_multiple_python_abis; then
2354 # Restore previous value of PYTHON_ABI. 2368 # Restore previous value of PYTHON_ABI.
2355 if [[ -n "${previous_PYTHON_ABI}" ]]; then 2369 if [[ -n "${previous_PYTHON_ABI}" ]]; then
2409 esac 2423 esac
2410 shift 2424 shift
2411 done 2425 done
2412 2426
2413 if [[ "$#" -eq 0 ]]; then 2427 if [[ "$#" -eq 0 ]]; then
2414 _python_set_color_variables 2428 ewarn
2415
2416 echo
2417 echo " ${_RED}*${_NORMAL} ${_RED}Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be${_NORMAL}"
2418 echo " ${_RED}*${_NORMAL} ${_RED}disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules.${_NORMAL}"
2419 echo " ${_RED}*${_NORMAL} ${_RED}The ebuild needs to be fixed. Please report a bug, if it has not been already reported.${_NORMAL}"
2420 echo
2421
2422 einfo &> /dev/null
2423 einfo "Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be" &> /dev/null 2429 ewarn "Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be"
2424 einfo "disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules." &> /dev/null 2430 ewarn "disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules."
2425 einfo "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." &> /dev/null 2431 ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported."
2426 einfo &> /dev/null 2432 ewarn
2427 fi 2433 fi
2428 2434
2429 while (($#)); do 2435 while (($#)); do
2430 if [[ "$1" =~ ^($|(\.|\.\.|/)($|/)) ]]; then 2436 if [[ "$1" =~ ^($|(\.|\.\.|/)($|/)) ]]; then
2431 die "${FUNCNAME}(): Invalid argument '$1'" 2437 die "${FUNCNAME}(): Invalid argument '$1'"
2475# This function can be used only in pkg_postrm() phase. 2481# This function can be used only in pkg_postrm() phase.
2476python_mod_cleanup() { 2482python_mod_cleanup() {
2477 _python_check_python_pkg_setup_execution 2483 _python_check_python_pkg_setup_execution
2478 _python_initialize_prefix_variables 2484 _python_initialize_prefix_variables
2479 2485
2480 local dir iterated_PYTHON_ABIS PYTHON_ABI="${PYTHON_ABI}" root search_paths=() sitedir 2486 local allow_evaluated_non_sitedir_paths="0" dir iterated_PYTHON_ABIS PYTHON_ABI="${PYTHON_ABI}" root search_paths=() sitedir
2481 2487
2482 # Check if phase is pkg_postrm(). 2488 # Check if phase is pkg_postrm().
2483 [[ "${EBUILD_PHASE}" != "postrm" ]] && die "${FUNCNAME}() can be used only in pkg_postrm() phase" 2489 [[ "${EBUILD_PHASE}" != "postrm" ]] && die "${FUNCNAME}() can be used only in pkg_postrm() phase"
2484 2490
2485 if _python_package_supporting_installation_for_multiple_python_abis; then 2491 if _python_package_supporting_installation_for_multiple_python_abis; then
2495 fi 2501 fi
2496 fi 2502 fi
2497 2503
2498 # Strip trailing slash from EROOT. 2504 # Strip trailing slash from EROOT.
2499 root="${EROOT%/}" 2505 root="${EROOT%/}"
2506
2507 while (($#)); do
2508 case "$1" in
2509 --allow-evaluated-non-sitedir-paths)
2510 allow_evaluated_non_sitedir_paths="1"
2511 ;;
2512 --)
2513 shift
2514 break
2515 ;;
2516 -*)
2517 die "${FUNCNAME}(): Unrecognized option '$1'"
2518 ;;
2519 *)
2520 break
2521 ;;
2522 esac
2523 shift
2524 done
2525
2526 if [[ "${allow_evaluated_non_sitedir_paths}" == "1" ]] && ! _python_package_supporting_installation_for_multiple_python_abis; then
2527 die "${FUNCNAME}(): '--allow-evaluated-non-sitedir-paths' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
2528 fi
2500 2529
2501 if [[ "$#" -gt 0 ]]; then 2530 if [[ "$#" -gt 0 ]]; then
2502 if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then 2531 if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
2503 while (($#)); do 2532 while (($#)); do
2504 if [[ "$1" =~ ^($|(\.|\.\.|/)($|/)) ]]; then 2533 if [[ "$1" =~ ^($|(\.|\.\.|/)($|/)) ]]; then
2505 die "${FUNCNAME}(): Invalid argument '$1'" 2534 die "${FUNCNAME}(): Invalid argument '$1'"
2506 elif ! _python_implementation && [[ "$1" =~ ^/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then 2535 elif ! _python_implementation && [[ "$1" =~ ^/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then
2507 die "${FUNCNAME}(): Paths of directories / files in site-packages directories must be relative to site-packages directories" 2536 die "${FUNCNAME}(): Paths of directories / files in site-packages directories must be relative to site-packages directories"
2508 elif [[ "$1" =~ ^/ ]]; then 2537 elif [[ "$1" =~ ^/ ]]; then
2509 if _python_package_supporting_installation_for_multiple_python_abis; then 2538 if _python_package_supporting_installation_for_multiple_python_abis; then
2539 if [[ "${allow_evaluated_non_sitedir_paths}" != "1" ]]; then
2510 die "${FUNCNAME}(): Absolute paths cannot be used in ebuilds of packages supporting installation for multiple Python ABIs" 2540 die "${FUNCNAME}(): Absolute paths cannot be used in ebuilds of packages supporting installation for multiple Python ABIs"
2541 fi
2542 if [[ "$1" != *\$* ]]; then
2543 die "${FUNCNAME}(): '$1' has invalid syntax"
2544 fi
2545 for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
2546 eval "search_paths+=(\"\${root}$1\")"
2547 done
2548 else
2549 search_paths+=("${root}$1")
2511 fi 2550 fi
2512 search_paths+=("${root}$1")
2513 else 2551 else
2514 for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do 2552 for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
2515 search_paths+=("${root}$(python_get_sitedir)/$1") 2553 search_paths+=("${root}$(python_get_sitedir)/$1")
2516 done 2554 done
2517 fi 2555 fi
2522 2560
2523 search_paths=("${@#/}") 2561 search_paths=("${@#/}")
2524 search_paths=("${search_paths[@]/#/${root}/}") 2562 search_paths=("${search_paths[@]/#/${root}/}")
2525 fi 2563 fi
2526 else 2564 else
2527 _python_set_color_variables 2565 ewarn
2528
2529 echo
2530 echo " ${_RED}*${_NORMAL} ${_RED}Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be${_NORMAL}"
2531 echo " ${_RED}*${_NORMAL} ${_RED}disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules.${_NORMAL}"
2532 echo " ${_RED}*${_NORMAL} ${_RED}The ebuild needs to be fixed. Please report a bug, if it has not been already reported.${_NORMAL}"
2533 echo
2534
2535 einfo &> /dev/null
2536 einfo "Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be" &> /dev/null 2566 ewarn "Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be"
2537 einfo "disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules." &> /dev/null 2567 ewarn "disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules."
2538 einfo "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." &> /dev/null 2568 ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported."
2539 einfo &> /dev/null 2569 ewarn
2540 2570
2541 for dir in "${root}"/usr/lib*; do 2571 for dir in "${root}"/usr/lib*; do
2542 if [[ -d "${dir}" && ! -L "${dir}" ]]; then 2572 if [[ -d "${dir}" && ! -L "${dir}" ]]; then
2543 for sitedir in "${dir}"/python*/site-packages; do 2573 for sitedir in "${dir}"/python*/site-packages; do
2544 if [[ -d "${sitedir}" ]]; then 2574 if [[ -d "${sitedir}" ]]; then
2596 2626
2597 _python_initialize_prefix_variables 2627 _python_initialize_prefix_variables
2598 _python_set_color_variables 2628 _python_set_color_variables
2599 2629
2600 if [[ "${FUNCNAME[1]}" != "python_mod_optimize" ]]; then 2630 if [[ "${FUNCNAME[1]}" != "python_mod_optimize" ]]; then
2601 echo 2631 ewarn
2602 echo " ${_RED}*${_NORMAL} ${_RED}Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-09-01.${_NORMAL}"
2603 echo " ${_RED}*${_NORMAL} ${_RED}Use python_mod_optimize() instead of ${FUNCNAME}().${_NORMAL}"
2604 echo " ${_RED}*${_NORMAL} ${_RED}The ebuild needs to be fixed. Please report a bug, if it has not been already reported.${_NORMAL}"
2605 echo
2606
2607 einfo &> /dev/null
2608 einfo "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-09-01." &> /dev/null 2632 ewarn "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-09-01."
2609 einfo "Use python_mod_optimize() instead of ${FUNCNAME}()." &> /dev/null 2633 ewarn "Use python_mod_optimize() instead of ${FUNCNAME}()."
2610 einfo "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." &> /dev/null 2634 ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported."
2611 einfo &> /dev/null 2635 ewarn
2612 fi 2636 fi
2613 2637
2614 local f myroot myfiles=() 2638 local f myroot myfiles=()
2615 2639
2616 # Check if phase is pkg_postinst() 2640 # Check if phase is pkg_postinst()

Legend:
Removed from v.1.101  
changed lines
  Added in v.1.103

  ViewVC Help
Powered by ViewVC 1.1.20