/[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.157
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.157 2012/08/16 23:57:32 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
2711 fi 2711 fi
2712 2712
2713 export PYTHONDONTWRITEBYTECODE="1" 2713 export PYTHONDONTWRITEBYTECODE="1"
2714} 2714}
2715 2715
2716_python_vecho() {
2717 [[ -z ${PORTAGE_VERBOSE} ]] || echo "$@"
2718}
2719
2716_python_clean_compiled_modules() { 2720_python_clean_compiled_modules() {
2717 _python_initialize_prefix_variables 2721 _python_initialize_prefix_variables
2718 _python_set_color_variables 2722 _python_set_color_variables
2719 2723
2720 [[ "${FUNCNAME[1]}" =~ ^(python_mod_optimize|python_mod_cleanup)$ ]] || die "${FUNCNAME}(): Invalid usage" 2724 [[ "${FUNCNAME[1]}" =~ ^(python_mod_optimize|python_mod_cleanup)$ ]] || die "${FUNCNAME}(): Invalid usage"
2733 2737
2734 if [[ "${EBUILD_PHASE}" == "postrm" ]]; then 2738 if [[ "${EBUILD_PHASE}" == "postrm" ]]; then
2735 # Delete empty child directories. 2739 # Delete empty child directories.
2736 find "${path}" -type d | sort -r | while read -r dir; do 2740 find "${path}" -type d | sort -r | while read -r dir; do
2737 if rmdir "${dir}" 2> /dev/null; then 2741 if rmdir "${dir}" 2> /dev/null; then
2738 echo "${_CYAN}<<< ${dir}${_NORMAL}" 2742 _python_vecho "<<< ${dir}"
2739 fi 2743 fi
2740 done 2744 done
2741 fi 2745 fi
2742 elif [[ "${path}" == *.py ]]; then 2746 elif [[ "${path}" == *.py ]]; then
2743 base_module_name="${path##*/}" 2747 base_module_name="${path##*/}"
2766 if [[ "${EBUILD_PHASE}" == "postinst" ]]; then 2770 if [[ "${EBUILD_PHASE}" == "postinst" ]]; then
2767 [[ -f "${py_file}" && "${compiled_file}" -nt "${py_file}" ]] && continue 2771 [[ -f "${py_file}" && "${compiled_file}" -nt "${py_file}" ]] && continue
2768 else 2772 else
2769 [[ -f "${py_file}" ]] && continue 2773 [[ -f "${py_file}" ]] && continue
2770 fi 2774 fi
2775 _python_vecho "<<< ${compiled_file%[co]}[co]"
2771 rm -f "${compiled_file%[co]}"[co] 2776 rm -f "${compiled_file%[co]}"[co]
2772 elif [[ "${compiled_file}" == *\$py.class ]]; then 2777 elif [[ "${compiled_file}" == *\$py.class ]]; then
2773 if [[ "${dir}" == "__pycache__" ]]; then 2778 if [[ "${dir}" == "__pycache__" ]]; then
2774 base_module_name="${compiled_file##*/}" 2779 base_module_name="${compiled_file##*/}"
2775 base_module_name="${base_module_name%\$py.class}" 2780 base_module_name="${base_module_name%\$py.class}"
2780 if [[ "${EBUILD_PHASE}" == "postinst" ]]; then 2785 if [[ "${EBUILD_PHASE}" == "postinst" ]]; then
2781 [[ -f "${py_file}" && "${compiled_file}" -nt "${py_file}" ]] && continue 2786 [[ -f "${py_file}" && "${compiled_file}" -nt "${py_file}" ]] && continue
2782 else 2787 else
2783 [[ -f "${py_file}" ]] && continue 2788 [[ -f "${py_file}" ]] && continue
2784 fi 2789 fi
2790 _python_vecho "<<< ${compiled_file}"
2785 rm -f "${compiled_file}" 2791 rm -f "${compiled_file}"
2786 else 2792 else
2787 die "${FUNCNAME}(): Unrecognized file type: '${compiled_file}'" 2793 die "${FUNCNAME}(): Unrecognized file type: '${compiled_file}'"
2788 fi 2794 fi
2789 2795
2790 # Delete empty parent directories. 2796 # Delete empty parent directories.
2791 dir="${compiled_file%/*}" 2797 dir="${compiled_file%/*}"
2792 while [[ "${dir}" != "${root}" ]]; do 2798 while [[ "${dir}" != "${root}" ]]; do
2793 if ! rmdir "${dir}" 2> /dev/null; then 2799 if rmdir "${dir}" 2> /dev/null; then
2800 _python_vecho "<<< ${dir}"
2801 else
2794 break 2802 break
2795 fi 2803 fi
2796 dir="${dir%/*}" 2804 dir="${dir%/*}"
2797 done 2805 done
2798 done 2806 done

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

  ViewVC Help
Powered by ViewVC 1.1.20