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

Diff of /eclass/python.eclass

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

Revision 1.156 Revision 1.158
1# Copyright 1999-2012 Gentoo Foundation 1# Copyright 1999-2012 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.156 2012/08/16 07:46:15 patrick Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.158 2012/09/27 15:41:56 floppym 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
21 21
22# Avoid processing this eclass more than once. 22# Avoid processing this eclass more than once.
23if [[ -z "${_PYTHON_ECLASS_INHERITED}" ]]; then 23if [[ -z "${_PYTHON_ECLASS_INHERITED}" ]]; then
24_PYTHON_ECLASS_INHERITED="1" 24_PYTHON_ECLASS_INHERITED="1"
25 25
26if ! has "${EAPI:-0}" 0 1 2 3 4; then 26if ! has "${EAPI:-0}" 0 1 2 3 4 5; then
27 die "API of python.eclass in EAPI=\"${EAPI}\" not established" 27 die "API of python.eclass in EAPI=\"${EAPI}\" not established"
28fi 28fi
29 29
30_CPYTHON2_GLOBALLY_SUPPORTED_ABIS=(2.4 2.5 2.6 2.7) 30_CPYTHON2_GLOBALLY_SUPPORTED_ABIS=(2.4 2.5 2.6 2.7)
31_CPYTHON3_GLOBALLY_SUPPORTED_ABIS=(3.1 3.2) 31_CPYTHON3_GLOBALLY_SUPPORTED_ABIS=(3.1 3.2)
111 return 1 111 return 1
112 fi 112 fi
113} 113}
114 114
115_python_package_supporting_installation_for_multiple_python_abis() { 115_python_package_supporting_installation_for_multiple_python_abis() {
116 if has "${EAPI:-0}" 0 1 2 3 4; then
117 if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 116 [[ -n "${SUPPORT_PYTHON_ABIS}" ]]
118 return 0
119 else
120 return 1
121 fi
122 else
123 die "${FUNCNAME}(): Support for EAPI=\"${EAPI}\" not implemented"
124 fi
125} 117}
126 118
127# @ECLASS-VARIABLE: PYTHON_DEPEND 119# @ECLASS-VARIABLE: PYTHON_DEPEND
128# @DESCRIPTION: 120# @DESCRIPTION:
129# Specification of dependency on dev-lang/python. 121# Specification of dependency on dev-lang/python.
750 if [[ -n "${PYTHON_EXPORT_PHASE_FUNCTIONS}" ]]; then 742 if [[ -n "${PYTHON_EXPORT_PHASE_FUNCTIONS}" ]]; then
751 EXPORT_FUNCTIONS src_prepare src_configure src_compile src_test src_install 743 EXPORT_FUNCTIONS src_prepare src_configure src_compile src_test src_install
752 fi 744 fi
753fi 745fi
754 746
755if has "${EAPI:-0}" 0 1 2 3 4; then
756 unset PYTHON_ABIS 747unset PYTHON_ABIS
757fi
758 748
759_python_calculate_PYTHON_ABIS() { 749_python_calculate_PYTHON_ABIS() {
760 if ! _python_package_supporting_installation_for_multiple_python_abis; then 750 if ! _python_package_supporting_installation_for_multiple_python_abis; then
761 die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs" 751 die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
762 fi 752 fi
2711 fi 2701 fi
2712 2702
2713 export PYTHONDONTWRITEBYTECODE="1" 2703 export PYTHONDONTWRITEBYTECODE="1"
2714} 2704}
2715 2705
2706_python_vecho() {
2707 [[ -z ${PORTAGE_VERBOSE} ]] || echo "$@"
2708}
2709
2716_python_clean_compiled_modules() { 2710_python_clean_compiled_modules() {
2717 _python_initialize_prefix_variables 2711 _python_initialize_prefix_variables
2718 _python_set_color_variables 2712 _python_set_color_variables
2719 2713
2720 [[ "${FUNCNAME[1]}" =~ ^(python_mod_optimize|python_mod_cleanup)$ ]] || die "${FUNCNAME}(): Invalid usage" 2714 [[ "${FUNCNAME[1]}" =~ ^(python_mod_optimize|python_mod_cleanup)$ ]] || die "${FUNCNAME}(): Invalid usage"
2733 2727
2734 if [[ "${EBUILD_PHASE}" == "postrm" ]]; then 2728 if [[ "${EBUILD_PHASE}" == "postrm" ]]; then
2735 # Delete empty child directories. 2729 # Delete empty child directories.
2736 find "${path}" -type d | sort -r | while read -r dir; do 2730 find "${path}" -type d | sort -r | while read -r dir; do
2737 if rmdir "${dir}" 2> /dev/null; then 2731 if rmdir "${dir}" 2> /dev/null; then
2738 echo "${_CYAN}<<< ${dir}${_NORMAL}" 2732 _python_vecho "<<< ${dir}"
2739 fi 2733 fi
2740 done 2734 done
2741 fi 2735 fi
2742 elif [[ "${path}" == *.py ]]; then 2736 elif [[ "${path}" == *.py ]]; then
2743 base_module_name="${path##*/}" 2737 base_module_name="${path##*/}"
2766 if [[ "${EBUILD_PHASE}" == "postinst" ]]; then 2760 if [[ "${EBUILD_PHASE}" == "postinst" ]]; then
2767 [[ -f "${py_file}" && "${compiled_file}" -nt "${py_file}" ]] && continue 2761 [[ -f "${py_file}" && "${compiled_file}" -nt "${py_file}" ]] && continue
2768 else 2762 else
2769 [[ -f "${py_file}" ]] && continue 2763 [[ -f "${py_file}" ]] && continue
2770 fi 2764 fi
2765 _python_vecho "<<< ${compiled_file%[co]}[co]"
2771 rm -f "${compiled_file%[co]}"[co] 2766 rm -f "${compiled_file%[co]}"[co]
2772 elif [[ "${compiled_file}" == *\$py.class ]]; then 2767 elif [[ "${compiled_file}" == *\$py.class ]]; then
2773 if [[ "${dir}" == "__pycache__" ]]; then 2768 if [[ "${dir}" == "__pycache__" ]]; then
2774 base_module_name="${compiled_file##*/}" 2769 base_module_name="${compiled_file##*/}"
2775 base_module_name="${base_module_name%\$py.class}" 2770 base_module_name="${base_module_name%\$py.class}"
2780 if [[ "${EBUILD_PHASE}" == "postinst" ]]; then 2775 if [[ "${EBUILD_PHASE}" == "postinst" ]]; then
2781 [[ -f "${py_file}" && "${compiled_file}" -nt "${py_file}" ]] && continue 2776 [[ -f "${py_file}" && "${compiled_file}" -nt "${py_file}" ]] && continue
2782 else 2777 else
2783 [[ -f "${py_file}" ]] && continue 2778 [[ -f "${py_file}" ]] && continue
2784 fi 2779 fi
2780 _python_vecho "<<< ${compiled_file}"
2785 rm -f "${compiled_file}" 2781 rm -f "${compiled_file}"
2786 else 2782 else
2787 die "${FUNCNAME}(): Unrecognized file type: '${compiled_file}'" 2783 die "${FUNCNAME}(): Unrecognized file type: '${compiled_file}'"
2788 fi 2784 fi
2789 2785
2790 # Delete empty parent directories. 2786 # Delete empty parent directories.
2791 dir="${compiled_file%/*}" 2787 dir="${compiled_file%/*}"
2792 while [[ "${dir}" != "${root}" ]]; do 2788 while [[ "${dir}" != "${root}" ]]; do
2793 if ! rmdir "${dir}" 2> /dev/null; then 2789 if rmdir "${dir}" 2> /dev/null; then
2790 _python_vecho "<<< ${dir}"
2791 else
2794 break 2792 break
2795 fi 2793 fi
2796 dir="${dir%/*}" 2794 dir="${dir%/*}"
2797 done 2795 done
2798 done 2796 done

Legend:
Removed from v.1.156  
changed lines
  Added in v.1.158

  ViewVC Help
Powered by ViewVC 1.1.20