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

Diff of /eclass/python.eclass

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

Revision 1.61 Revision 1.62
1# Copyright 1999-2009 Gentoo Foundation 1# Copyright 1999-2009 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.61 2009/08/07 00:43:16 arfrever Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.62 2009/08/13 16:57:01 arfrever Exp $
4 4
5# @ECLASS: python.eclass 5# @ECLASS: python.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# python@gentoo.org 7# python@gentoo.org
8# 8#
614 else 614 else
615 ewarn "'${root}/$1' doesn't exist!" 615 ewarn "'${root}/$1' doesn't exist!"
616 fi 616 fi
617 else 617 else
618 for PYTHON_ABI in ${PYTHON_ABIS}; do 618 for PYTHON_ABI in ${PYTHON_ABIS}; do
619 if [[ -d "${root}/$(python_get_sitedir)/$1" ]]; then 619 if [[ -d "${root}$(python_get_sitedir)/$1" ]]; then
620 site_packages_dirs+=("$1") 620 site_packages_dirs+=("$1")
621 break 621 break
622 elif [[ -f "${root}/$(python_get_sitedir)/$1" ]]; then 622 elif [[ -f "${root}$(python_get_sitedir)/$1" ]]; then
623 site_packages_files+=("$1") 623 site_packages_files+=("$1")
624 break 624 break
625 elif [[ -e "${root}/$(python_get_sitedir)/$1" ]]; then 625 elif [[ -e "${root}$(python_get_sitedir)/$1" ]]; then
626 ewarn "'$1' is not a file or a directory!" 626 ewarn "'$1' is not a file or a directory!"
627 else 627 else
628 ewarn "'$1' doesn't exist!" 628 ewarn "'$1' doesn't exist!"
629 fi 629 fi
630 done 630 done
641 if ((${#site_packages_dirs[@]})) || ((${#site_packages_files[@]})); then 641 if ((${#site_packages_dirs[@]})) || ((${#site_packages_files[@]})); then
642 return_code="0" 642 return_code="0"
643 ebegin "Compilation and optimization of Python modules for Python ${PYTHON_ABI}" 643 ebegin "Compilation and optimization of Python modules for Python ${PYTHON_ABI}"
644 if ((${#site_packages_dirs[@]})); then 644 if ((${#site_packages_dirs[@]})); then
645 for dir in "${site_packages_dirs[@]}"; do 645 for dir in "${site_packages_dirs[@]}"; do
646 site_packages_absolute_dirs+=("${root}/$(python_get_sitedir)/${dir}") 646 site_packages_absolute_dirs+=("${root}$(python_get_sitedir)/${dir}")
647 done 647 done
648 "$(PYTHON)" "${root}/$(python_get_libdir)/compileall.py" "${options[@]}" "${site_packages_absolute_dirs[@]}" || return_code="1" 648 "$(PYTHON)" "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${site_packages_absolute_dirs[@]}" || return_code="1"
649 "$(PYTHON)" -O "${root}/$(python_get_libdir)/compileall.py" "${options[@]}" "${site_packages_absolute_dirs[@]}" 2> /dev/null || return_code="1" 649 "$(PYTHON)" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${site_packages_absolute_dirs[@]}" 2> /dev/null || return_code="1"
650 fi 650 fi
651 if ((${#site_packages_files[@]})); then 651 if ((${#site_packages_files[@]})); then
652 for file in "${site_packages_files[@]}"; do 652 for file in "${site_packages_files[@]}"; do
653 site_packages_absolute_files+=("${root}/$(python_get_sitedir)/${file}") 653 site_packages_absolute_files+=("${root}$(python_get_sitedir)/${file}")
654 done 654 done
655 "$(PYTHON)" "${root}/$(python_get_libdir)/py_compile.py" "${site_packages_absolute_files[@]}" || return_code="1" 655 "$(PYTHON)" "${root}$(python_get_libdir)/py_compile.py" "${site_packages_absolute_files[@]}" || return_code="1"
656 "$(PYTHON)" -O "${root}/$(python_get_libdir)/py_compile.py" "${site_packages_absolute_files[@]}" 2> /dev/null || return_code="1" 656 "$(PYTHON)" -O "${root}$(python_get_libdir)/py_compile.py" "${site_packages_absolute_files[@]}" 2> /dev/null || return_code="1"
657 fi 657 fi
658 eend "${return_code}" 658 eend "${return_code}"
659 fi 659 fi
660 unset site_packages_absolute_dirs site_packages_absolute_files 660 unset site_packages_absolute_dirs site_packages_absolute_files
661 done 661 done
665 665
666 if ((${#other_dirs[@]})) || ((${#other_files[@]})); then 666 if ((${#other_dirs[@]})) || ((${#other_files[@]})); then
667 return_code="0" 667 return_code="0"
668 ebegin "Compilation and optimization of Python modules placed outside of site-packages directories for Python ${PYVER}..." 668 ebegin "Compilation and optimization of Python modules placed outside of site-packages directories for Python ${PYVER}..."
669 if ((${#other_dirs[@]})); then 669 if ((${#other_dirs[@]})); then
670 python${PYVER} "${root}/$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" || return_code="1" 670 python${PYVER} "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" || return_code="1"
671 python${PYVER} -O "${root}/$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" 2> /dev/null || return_code="1" 671 python${PYVER} -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" 2> /dev/null || return_code="1"
672 fi 672 fi
673 if ((${#other_files[@]})); then 673 if ((${#other_files[@]})); then
674 python${PYVER} "${root}/$(python_get_libdir)/py_compile.py" "${other_files[@]}" || return_code="1" 674 python${PYVER} "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" || return_code="1"
675 python${PYVER} -O "${root}/$(python_get_libdir)/py_compile.py" "${other_files[@]}" 2> /dev/null || return_code="1" 675 python${PYVER} -O "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" 2> /dev/null || return_code="1"
676 fi 676 fi
677 eend "${return_code}" 677 eend "${return_code}"
678 fi 678 fi
679 else 679 else
680 local myroot mydirs=() myfiles=() myopts=() 680 local myroot mydirs=() myfiles=() myopts=()
766 die "${FUNCNAME} doesn't support absolute paths of directories/files in site-packages directories" 766 die "${FUNCNAME} doesn't support absolute paths of directories/files in site-packages directories"
767 elif [[ "$1" =~ ^/ ]]; then 767 elif [[ "$1" =~ ^/ ]]; then
768 SEARCH_PATH+=("${root}/${1#/}") 768 SEARCH_PATH+=("${root}/${1#/}")
769 else 769 else
770 for PYTHON_ABI in ${PYTHON_ABIS}; do 770 for PYTHON_ABI in ${PYTHON_ABIS}; do
771 SEARCH_PATH+=("${root}/$(python_get_sitedir)/$1") 771 SEARCH_PATH+=("${root}$(python_get_sitedir)/$1")
772 done 772 done
773 fi 773 fi
774 shift 774 shift
775 done 775 done
776 else 776 else
780 else 780 else
781 SEARCH_PATH=("${root}"/usr/lib*/python*/site-packages) 781 SEARCH_PATH=("${root}"/usr/lib*/python*/site-packages)
782 fi 782 fi
783 783
784 for path in "${SEARCH_PATH[@]}"; do 784 for path in "${SEARCH_PATH[@]}"; do
785 [[ ! -d "${path}" ]] && continue
785 einfo "Cleaning orphaned Python bytecode from ${path} .." 786 einfo "Cleaning orphaned Python bytecode from ${path} .."
786 find "${path}" -name '*.py[co]' -print0 | while read -rd ''; do 787 find "${path}" -name '*.py[co]' -print0 | while read -rd ''; do
787 src_py="${REPLY%[co]}" 788 src_py="${REPLY%[co]}"
788 [[ -f "${src_py}" ]] && continue 789 [[ -f "${src_py}" || (! -f "${src_py}c" && ! -f "${src_py}o") ]] && continue
789 einfo "Purging ${src_py}[co]" 790 einfo "Purging ${src_py}[co]"
790 rm -f "${src_py}"[co] 791 rm -f "${src_py}"[co]
791 done 792 done
792 793
793 # Attempt to remove directories that may be empty. 794 # Attempt to remove directories that may be empty.
794 find "${path}" -type d | sort -r | while read -r dir; do 795 find "${path}" -type d | sort -r | while read -r dir; do
795 rmdir "${dir}" 2>/dev/null 796 rmdir "${dir}" 2>/dev/null && einfo "Removing empty directory ${dir}"
796 done 797 done
797 done 798 done
798} 799}

Legend:
Removed from v.1.61  
changed lines
  Added in v.1.62

  ViewVC Help
Powered by ViewVC 1.1.20