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

Diff of /eclass/python.eclass

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

Revision 1.123 Revision 1.124
1# Copyright 1999-2011 Gentoo Foundation 1# Copyright 1999-2011 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.123 2011/07/08 07:44:52 djc Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.124 2011/07/08 07:46:53 djc 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
998 iterated_PYTHON_ABIS="${PYTHON_ABIS}" 998 iterated_PYTHON_ABIS="${PYTHON_ABIS}"
999 fi 999 fi
1000 for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do 1000 for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
1001 if [[ "${EBUILD_PHASE}" == "test" ]] && _python_check_python_abi_matching --patterns-list "${PYTHON_ABI}" "${PYTHON_TESTS_RESTRICTED_ABIS}"; then 1001 if [[ "${EBUILD_PHASE}" == "test" ]] && _python_check_python_abi_matching --patterns-list "${PYTHON_ABI}" "${PYTHON_TESTS_RESTRICTED_ABIS}"; then
1002 if [[ "${quiet}" == "0" ]]; then 1002 if [[ "${quiet}" == "0" ]]; then
1003 echo " ${_GREEN}*${_NORMAL} ${_BLUE}Testing of ${CATEGORY}/${PF} with $(python_get_implementation) $(python_get_version) skipped${_NORMAL}" 1003 echo " ${_GREEN}*${_NORMAL} ${_BLUE}Testing of ${CATEGORY}/${PF} with $(python_get_implementation_and_version) skipped${_NORMAL}"
1004 fi 1004 fi
1005 continue 1005 continue
1006 fi 1006 fi
1007 1007
1008 _python_prepare_flags 1008 _python_prepare_flags
1009 1009
1010 if [[ "${quiet}" == "0" ]]; then 1010 if [[ "${quiet}" == "0" ]]; then
1011 if [[ -n "${action_message_template}" ]]; then 1011 if [[ -n "${action_message_template}" ]]; then
1012 eval "action_message=\"${action_message_template}\"" 1012 eval "action_message=\"${action_message_template}\""
1013 else 1013 else
1014 action_message="${action} of ${CATEGORY}/${PF} with $(python_get_implementation) $(python_get_version)..." 1014 action_message="${action} of ${CATEGORY}/${PF} with $(python_get_implementation_and_version)..."
1015 fi 1015 fi
1016 echo " ${_GREEN}*${_NORMAL} ${_BLUE}${action_message}${_NORMAL}" 1016 echo " ${_GREEN}*${_NORMAL} ${_BLUE}${action_message}${_NORMAL}"
1017 fi 1017 fi
1018 1018
1019 if [[ "${separate_build_dirs}" == "1" ]]; then 1019 if [[ "${separate_build_dirs}" == "1" ]]; then
1043 1043
1044 if [[ "${return_code}" -ne 0 ]]; then 1044 if [[ "${return_code}" -ne 0 ]]; then
1045 if [[ -n "${failure_message_template}" ]]; then 1045 if [[ -n "${failure_message_template}" ]]; then
1046 eval "failure_message=\"${failure_message_template}\"" 1046 eval "failure_message=\"${failure_message_template}\""
1047 else 1047 else
1048 failure_message="${action} failed with $(python_get_implementation) $(python_get_version) in ${function}() function" 1048 failure_message="${action} failed with $(python_get_implementation_and_version) in ${function}() function"
1049 fi 1049 fi
1050 1050
1051 if [[ "${nonfatal}" == "1" ]]; then 1051 if [[ "${nonfatal}" == "1" ]]; then
1052 if [[ "${quiet}" == "0" ]]; then 1052 if [[ "${quiet}" == "0" ]]; then
1053 ewarn "${failure_message}" 1053 ewarn "${failure_message}"
2141} 2141}
2142 2142
2143# @FUNCTION: python_get_version 2143# @FUNCTION: python_get_version
2144# @USAGE: [-f|--final-ABI] [-l|--language] [--full] [--major] [--minor] [--micro] 2144# @USAGE: [-f|--final-ABI] [-l|--language] [--full] [--major] [--minor] [--micro]
2145# @DESCRIPTION: 2145# @DESCRIPTION:
2146# Print Python version. 2146# Print version of Python implementation.
2147# --full, --major, --minor and --micro options cannot be specified simultaneously. 2147# --full, --major, --minor and --micro options cannot be specified simultaneously.
2148# If --full, --major, --minor and --micro options are not specified, then "${major_version}.${minor_version}" is printed. 2148# If --full, --major, --minor and --micro options are not specified, then "${major_version}.${minor_version}" is printed.
2149# If --language option is specified, then Python language version is printed. 2149# If --language option is specified, then version of Python language is printed.
2150# --language and --full options cannot be specified simultaneously. 2150# --language and --full options cannot be specified simultaneously.
2151# --language and --micro options cannot be specified simultaneously. 2151# --language and --micro options cannot be specified simultaneously.
2152# If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used. 2152# If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
2153python_get_version() { 2153python_get_version() {
2154 _python_check_python_pkg_setup_execution 2154 _python_check_python_pkg_setup_execution
2241 if [[ "${final_ABI}" == "1" ]]; then 2241 if [[ "${final_ABI}" == "1" ]]; then
2242 "$(PYTHON -f)" -c "${python_command}" 2242 "$(PYTHON -f)" -c "${python_command}"
2243 else 2243 else
2244 "$(PYTHON ${PYTHON_ABI})" -c "${python_command}" 2244 "$(PYTHON ${PYTHON_ABI})" -c "${python_command}"
2245 fi 2245 fi
2246 fi
2247}
2248
2249# @FUNCTION: python_get_implementation_and_version
2250# @USAGE: [-f|--final-ABI]
2251# @DESCRIPTION:
2252# Print name and version of Python implementation.
2253# If version of Python implementation is not bound to version of Python language, then
2254# version of Python language is additionally printed.
2255# If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
2256python_get_implementation_and_version() {
2257 _python_check_python_pkg_setup_execution
2258
2259 local final_ABI="0" PYTHON_ABI="${PYTHON_ABI}"
2260
2261 while (($#)); do
2262 case "$1" in
2263 -f|--final-ABI)
2264 final_ABI="1"
2265 ;;
2266 -*)
2267 die "${FUNCNAME}(): Unrecognized option '$1'"
2268 ;;
2269 *)
2270 die "${FUNCNAME}(): Invalid usage"
2271 ;;
2272 esac
2273 shift
2274 done
2275
2276 if [[ "${final_ABI}" == "1" ]]; then
2277 if ! _python_package_supporting_installation_for_multiple_python_abis; then
2278 die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
2279 fi
2280 PYTHON_ABI="$(PYTHON -f --ABI)"
2281 else
2282 if _python_package_supporting_installation_for_multiple_python_abis; then
2283 if ! _python_abi-specific_local_scope; then
2284 die "${FUNCNAME}() should be used in ABI-specific local scope"
2285 fi
2286 else
2287 PYTHON_ABI="${PYTHON_ABI:-$(PYTHON --ABI)}"
2288 fi
2289 fi
2290
2291 if [[ "${PYTHON_ABI}" =~ ^[[:digit:]]+\.[[:digit:]]+-[[:alnum:]]+-[[:digit:]]+\.[[:digit:]]+$ ]]; then
2292 echo "$(_python_get_implementation "${PYTHON_ABI}") ${PYTHON_ABI##*-} (Python ${PYTHON_ABI%%-*})"
2293 else
2294 echo "$(_python_get_implementation "${PYTHON_ABI}") ${PYTHON_ABI%%-*}"
2246 fi 2295 fi
2247} 2296}
2248 2297
2249# ================================================================================================ 2298# ================================================================================================
2250# ================================ FUNCTIONS FOR RUNNING OF TESTS ================================ 2299# ================================ FUNCTIONS FOR RUNNING OF TESTS ================================
2702 2751
2703 for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do 2752 for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
2704 if ((${#site_packages_dirs[@]})) || ((${#site_packages_files[@]})) || ((${#evaluated_dirs[@]})) || ((${#evaluated_files[@]})); then 2753 if ((${#site_packages_dirs[@]})) || ((${#site_packages_files[@]})) || ((${#evaluated_dirs[@]})) || ((${#evaluated_files[@]})); then
2705 return_code="0" 2754 return_code="0"
2706 stderr="" 2755 stderr=""
2707 ebegin "Compilation and optimization of Python modules for $(python_get_implementation) $(python_get_version)" 2756 ebegin "Compilation and optimization of Python modules for $(python_get_implementation_and_version)"
2708 if ((${#site_packages_dirs[@]})) || ((${#evaluated_dirs[@]})); then 2757 if ((${#site_packages_dirs[@]})) || ((${#evaluated_dirs[@]})); then
2709 for dir in "${site_packages_dirs[@]}"; do 2758 for dir in "${site_packages_dirs[@]}"; do
2710 dirs+=("${root}$(python_get_sitedir)/${dir}") 2759 dirs+=("${root}$(python_get_sitedir)/${dir}")
2711 done 2760 done
2712 for dir in "${evaluated_dirs[@]}"; do 2761 for dir in "${evaluated_dirs[@]}"; do
2731 fi 2780 fi
2732 _python_clean_compiled_modules "${files[@]}" 2781 _python_clean_compiled_modules "${files[@]}"
2733 fi 2782 fi
2734 eend "${return_code}" 2783 eend "${return_code}"
2735 if [[ -n "${stderr}" ]]; then 2784 if [[ -n "${stderr}" ]]; then
2736 eerror "Syntax errors / warnings in Python modules for $(python_get_implementation) $(python_get_version):" &> /dev/null 2785 eerror "Syntax errors / warnings in Python modules for $(python_get_implementation_and_version):" &> /dev/null
2737 while read stderr_line; do 2786 while read stderr_line; do
2738 eerror " ${stderr_line}" 2787 eerror " ${stderr_line}"
2739 done <<< "${stderr}" 2788 done <<< "${stderr}"
2740 fi 2789 fi
2741 fi 2790 fi
2752 fi 2801 fi
2753 2802
2754 if ((${#other_dirs[@]})) || ((${#other_files[@]})); then 2803 if ((${#other_dirs[@]})) || ((${#other_files[@]})); then
2755 return_code="0" 2804 return_code="0"
2756 stderr="" 2805 stderr=""
2757 ebegin "Compilation and optimization of Python modules placed outside of site-packages directories for $(python_get_implementation) $(python_get_version)" 2806 ebegin "Compilation and optimization of Python modules placed outside of site-packages directories for $(python_get_implementation_and_version)"
2758 if ((${#other_dirs[@]})); then 2807 if ((${#other_dirs[@]})); then
2759 stderr+="${stderr:+$'\n'}$("$(PYTHON ${PYTHON_ABI})" "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" 2>&1)" || return_code="1" 2808 stderr+="${stderr:+$'\n'}$("$(PYTHON ${PYTHON_ABI})" "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" 2>&1)" || return_code="1"
2760 if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then 2809 if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
2761 "$(PYTHON ${PYTHON_ABI})" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" &> /dev/null || return_code="1" 2810 "$(PYTHON ${PYTHON_ABI})" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" &> /dev/null || return_code="1"
2762 fi 2811 fi
2769 fi 2818 fi
2770 _python_clean_compiled_modules "${other_files[@]}" 2819 _python_clean_compiled_modules "${other_files[@]}"
2771 fi 2820 fi
2772 eend "${return_code}" 2821 eend "${return_code}"
2773 if [[ -n "${stderr}" ]]; then 2822 if [[ -n "${stderr}" ]]; then
2774 eerror "Syntax errors / warnings in Python modules placed outside of site-packages directories for $(python_get_implementation) $(python_get_version):" &> /dev/null 2823 eerror "Syntax errors / warnings in Python modules placed outside of site-packages directories for $(python_get_implementation_and_version):" &> /dev/null
2775 while read stderr_line; do 2824 while read stderr_line; do
2776 eerror " ${stderr_line}" 2825 eerror " ${stderr_line}"
2777 done <<< "${stderr}" 2826 done <<< "${stderr}"
2778 fi 2827 fi
2779 fi 2828 fi

Legend:
Removed from v.1.123  
changed lines
  Added in v.1.124

  ViewVC Help
Powered by ViewVC 1.1.20