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

Diff of /eclass/python.eclass

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

Revision 1.102 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.102 2010/07/18 20:45:50 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
923 for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do 923 for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
924 _python_prepare_flags 924 _python_prepare_flags
925 925
926 if [[ "${quiet}" == "0" ]]; then 926 if [[ "${quiet}" == "0" ]]; then
927 if [[ -n "${action_message_template}" ]]; then 927 if [[ -n "${action_message_template}" ]]; then
928 action_message="$(eval echo -n "${action_message_template}")" 928 eval "action_message=\"${action_message_template}\""
929 else 929 else
930 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)..."
931 fi 931 fi
932 echo " ${_GREEN}*${_NORMAL} ${_BLUE}${action_message}${_NORMAL}" 932 echo " ${_GREEN}*${_NORMAL} ${_BLUE}${action_message}${_NORMAL}"
933 fi 933 fi
957 957
958 _python_restore_flags 958 _python_restore_flags
959 959
960 if [[ "${return_code}" -ne 0 ]]; then 960 if [[ "${return_code}" -ne 0 ]]; then
961 if [[ -n "${failure_message_template}" ]]; then 961 if [[ -n "${failure_message_template}" ]]; then
962 failure_message="$(eval echo -n "${failure_message_template}")" 962 eval "failure_message=\"${failure_message_template}\""
963 else 963 else
964 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"
965 fi 965 fi
966 966
967 if [[ "${nonfatal}" == "1" ]]; then 967 if [[ "${nonfatal}" == "1" ]]; then
1923 done 1923 done
1924 1924
1925 python_test_function() { 1925 python_test_function() {
1926 local evaluated_PYTHONPATH 1926 local evaluated_PYTHONPATH
1927 1927
1928 evaluated_PYTHONPATH="$(eval echo -n "${PYTHONPATH_template}")" 1928 eval "evaluated_PYTHONPATH=\"${PYTHONPATH_template}\""
1929 1929
1930 _python_test_hook pre 1930 _python_test_hook pre
1931 1931
1932 if [[ -n "${evaluated_PYTHONPATH}" ]]; then 1932 if [[ -n "${evaluated_PYTHONPATH}" ]]; then
1933 echo ${_BOLD}PYTHONPATH="${evaluated_PYTHONPATH}" nosetests --verbosity="${PYTHON_TEST_VERBOSITY}" "$@"${_NORMAL} 1933 echo ${_BOLD}PYTHONPATH="${evaluated_PYTHONPATH}" nosetests --verbosity="${PYTHON_TEST_VERBOSITY}" "$@"${_NORMAL}
1987 done 1987 done
1988 1988
1989 python_test_function() { 1989 python_test_function() {
1990 local evaluated_PYTHONPATH 1990 local evaluated_PYTHONPATH
1991 1991
1992 evaluated_PYTHONPATH="$(eval echo -n "${PYTHONPATH_template}")" 1992 eval "evaluated_PYTHONPATH=\"${PYTHONPATH_template}\""
1993 1993
1994 _python_test_hook pre 1994 _python_test_hook pre
1995 1995
1996 if [[ -n "${evaluated_PYTHONPATH}" ]]; then 1996 if [[ -n "${evaluated_PYTHONPATH}" ]]; then
1997 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}
2051 done 2051 done
2052 2052
2053 python_test_function() { 2053 python_test_function() {
2054 local evaluated_PYTHONPATH 2054 local evaluated_PYTHONPATH
2055 2055
2056 evaluated_PYTHONPATH="$(eval echo -n "${PYTHONPATH_template}")" 2056 eval "evaluated_PYTHONPATH=\"${PYTHONPATH_template}\""
2057 2057
2058 _python_test_hook pre 2058 _python_test_hook pre
2059 2059
2060 if [[ -n "${evaluated_PYTHONPATH}" ]]; then 2060 if [[ -n "${evaluated_PYTHONPATH}" ]]; then
2061 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}
2221 # Check if phase is pkg_postinst(). 2221 # Check if phase is pkg_postinst().
2222 [[ "${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"
2223 2223
2224 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
2225 # 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.
2226 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=()
2227 2227
2228 if _python_package_supporting_installation_for_multiple_python_abis; then 2228 if _python_package_supporting_installation_for_multiple_python_abis; then
2229 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
2230 die "${FUNCNAME}(): python_pkg_setup() or python_execute_function() not called" 2230 die "${FUNCNAME}(): python_pkg_setup() or python_execute_function() not called"
2231 fi 2231 fi
2241 # Strip trailing slash from EROOT. 2241 # Strip trailing slash from EROOT.
2242 root="${EROOT%/}" 2242 root="${EROOT%/}"
2243 2243
2244 while (($#)); do 2244 while (($#)); do
2245 case "$1" in 2245 case "$1" in
2246 --allow-evaluated-non-sitedir-paths)
2247 allow_evaluated_non_sitedir_paths="1"
2248 ;;
2246 -l|-f|-q) 2249 -l|-f|-q)
2247 options+=("$1") 2250 options+=("$1")
2248 ;; 2251 ;;
2249 -d|-x) 2252 -d|-x)
2250 options+=("$1" "$2") 2253 options+=("$1" "$2")
2262 ;; 2265 ;;
2263 esac 2266 esac
2264 shift 2267 shift
2265 done 2268 done
2266 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
2267 if [[ "$#" -eq 0 ]]; then 2274 if [[ "$#" -eq 0 ]]; then
2268 ewarn 2275 ewarn
2269 ewarn "Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be" 2276 ewarn "Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be"
2270 ewarn "disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules." 2277 ewarn "disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules."
2271 ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." 2278 ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported."
2277 die "${FUNCNAME}(): Invalid argument '$1'" 2284 die "${FUNCNAME}(): Invalid argument '$1'"
2278 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
2279 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"
2280 elif [[ "$1" =~ ^/ ]]; then 2287 elif [[ "$1" =~ ^/ ]]; then
2281 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
2282 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"
2283 fi 2291 fi
2284 if [[ -d "${root}$1" ]]; then 2292 if [[ "$1" != *\$* ]]; then
2285 other_dirs+=("${root}$1") 2293 die "${FUNCNAME}(): '$1' has invalid syntax"
2286 elif [[ -f "${root}$1" ]]; then 2294 fi
2287 other_files+=("${root}$1") 2295 if [[ "$1" == *.py ]]; then
2288 elif [[ -e "${root}$1" ]]; then 2296 evaluated_files+=("$1")
2289 eerror "${FUNCNAME}(): '${root}$1' is not a regular file or a directory" 2297 else
2298 evaluated_dirs+=("$1")
2299 fi
2290 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
2291 eerror "${FUNCNAME}(): '${root}$1' does not exist" 2308 eerror "${FUNCNAME}(): '${root}$1' does not exist"
2309 fi
2292 fi 2310 fi
2293 else 2311 else
2294 for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do 2312 for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
2295 if [[ -d "${root}$(python_get_sitedir)/$1" ]]; then 2313 if [[ -d "${root}$(python_get_sitedir)/$1" ]]; then
2296 site_packages_dirs+=("$1") 2314 site_packages_dirs+=("$1")
2310 2328
2311 # Set additional options. 2329 # Set additional options.
2312 options+=("-q") 2330 options+=("-q")
2313 2331
2314 for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do 2332 for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
2315 if ((${#site_packages_dirs[@]})) || ((${#site_packages_files[@]})); then 2333 if ((${#site_packages_dirs[@]})) || ((${#site_packages_files[@]})) || ((${#evaluated_dirs[@]})) || ((${#evaluated_files[@]})); then
2316 return_code="0" 2334 return_code="0"
2317 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)"
2318 if ((${#site_packages_dirs[@]})); then 2336 if ((${#site_packages_dirs[@]})) || ((${#evaluated_dirs[@]})); then
2319 for dir in "${site_packages_dirs[@]}"; do 2337 for dir in "${site_packages_dirs[@]}"; do
2320 site_packages_absolute_dirs+=("${root}$(python_get_sitedir)/${dir}") 2338 dirs+=("${root}$(python_get_sitedir)/${dir}")
2321 done 2339 done
2340 for dir in "${evaluated_dirs[@]}"; do
2341 eval "dirs+=(\"\${root}${dir}\")"
2342 done
2322 "$(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"
2323 if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then 2344 if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
2324 "$(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"
2325 fi 2346 fi
2326 _python_clean_compiled_modules "${site_packages_absolute_dirs[@]}" 2347 _python_clean_compiled_modules "${dirs[@]}"
2327 fi 2348 fi
2328 if ((${#site_packages_files[@]})); then 2349 if ((${#site_packages_files[@]})) || ((${#evaluated_files[@]})); then
2329 for file in "${site_packages_files[@]}"; do 2350 for file in "${site_packages_files[@]}"; do
2330 site_packages_absolute_files+=("${root}$(python_get_sitedir)/${file}") 2351 files+=("${root}$(python_get_sitedir)/${file}")
2331 done 2352 done
2353 for file in "${evaluated_files[@]}"; do
2354 eval "files+=(\"\${root}${file}\")"
2355 done
2332 "$(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"
2333 if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then 2357 if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
2334 "$(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"
2335 fi 2359 fi
2336 _python_clean_compiled_modules "${site_packages_absolute_files[@]}" 2360 _python_clean_compiled_modules "${files[@]}"
2337 fi 2361 fi
2338 eend "${return_code}" 2362 eend "${return_code}"
2339 fi 2363 fi
2340 unset site_packages_absolute_dirs site_packages_absolute_files 2364 unset dirs files
2341 done 2365 done
2342 2366
2343 if _python_package_supporting_installation_for_multiple_python_abis; then 2367 if _python_package_supporting_installation_for_multiple_python_abis; then
2344 # Restore previous value of PYTHON_ABI. 2368 # Restore previous value of PYTHON_ABI.
2345 if [[ -n "${previous_PYTHON_ABI}" ]]; then 2369 if [[ -n "${previous_PYTHON_ABI}" ]]; then
2457# This function can be used only in pkg_postrm() phase. 2481# This function can be used only in pkg_postrm() phase.
2458python_mod_cleanup() { 2482python_mod_cleanup() {
2459 _python_check_python_pkg_setup_execution 2483 _python_check_python_pkg_setup_execution
2460 _python_initialize_prefix_variables 2484 _python_initialize_prefix_variables
2461 2485
2462 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
2463 2487
2464 # Check if phase is pkg_postrm(). 2488 # Check if phase is pkg_postrm().
2465 [[ "${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"
2466 2490
2467 if _python_package_supporting_installation_for_multiple_python_abis; then 2491 if _python_package_supporting_installation_for_multiple_python_abis; then
2477 fi 2501 fi
2478 fi 2502 fi
2479 2503
2480 # Strip trailing slash from EROOT. 2504 # Strip trailing slash from EROOT.
2481 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
2482 2529
2483 if [[ "$#" -gt 0 ]]; then 2530 if [[ "$#" -gt 0 ]]; then
2484 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
2485 while (($#)); do 2532 while (($#)); do
2486 if [[ "$1" =~ ^($|(\.|\.\.|/)($|/)) ]]; then 2533 if [[ "$1" =~ ^($|(\.|\.\.|/)($|/)) ]]; then
2487 die "${FUNCNAME}(): Invalid argument '$1'" 2534 die "${FUNCNAME}(): Invalid argument '$1'"
2488 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
2489 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"
2490 elif [[ "$1" =~ ^/ ]]; then 2537 elif [[ "$1" =~ ^/ ]]; then
2491 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
2492 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")
2493 fi 2550 fi
2494 search_paths+=("${root}$1")
2495 else 2551 else
2496 for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do 2552 for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
2497 search_paths+=("${root}$(python_get_sitedir)/$1") 2553 search_paths+=("${root}$(python_get_sitedir)/$1")
2498 done 2554 done
2499 fi 2555 fi

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

  ViewVC Help
Powered by ViewVC 1.1.20