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

Diff of /eclass/python.eclass

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

Revision 1.144 Revision 1.152
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.144 2012/01/01 05:02:27 floppym Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.152 2012/03/07 04:13:27 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
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)
32_JYTHON_GLOBALLY_SUPPORTED_ABIS=(2.5-jython) 32_JYTHON_GLOBALLY_SUPPORTED_ABIS=(2.5-jython)
33_PYPY_GLOBALLY_SUPPORTED_ABIS=(2.7-pypy-1.7) 33_PYPY_GLOBALLY_SUPPORTED_ABIS=(2.7-pypy-1.7 2.7-pypy-1.8)
34_PYTHON_GLOBALLY_SUPPORTED_ABIS=(${_CPYTHON2_GLOBALLY_SUPPORTED_ABIS[@]} ${_CPYTHON3_GLOBALLY_SUPPORTED_ABIS[@]} ${_JYTHON_GLOBALLY_SUPPORTED_ABIS[@]} ${_PYPY_GLOBALLY_SUPPORTED_ABIS[@]}) 34_PYTHON_GLOBALLY_SUPPORTED_ABIS=(${_CPYTHON2_GLOBALLY_SUPPORTED_ABIS[@]} ${_CPYTHON3_GLOBALLY_SUPPORTED_ABIS[@]} ${_JYTHON_GLOBALLY_SUPPORTED_ABIS[@]} ${_PYPY_GLOBALLY_SUPPORTED_ABIS[@]})
35 35
36# ================================================================================================ 36# ================================================================================================
37# ===================================== HANDLING OF METADATA ===================================== 37# ===================================== HANDLING OF METADATA =====================================
38# ================================================================================================ 38# ================================================================================================
482# @DESCRIPTION: 482# @DESCRIPTION:
483# Convert shebangs in specified files. Directories can be specified only with --recursive option. 483# Convert shebangs in specified files. Directories can be specified only with --recursive option.
484python_convert_shebangs() { 484python_convert_shebangs() {
485 _python_check_python_pkg_setup_execution 485 _python_check_python_pkg_setup_execution
486 486
487 local argument file files=() only_executables="0" python_interpreter quiet="0" recursive="0" 487 local argument file files=() only_executables="0" python_interpreter quiet="0" recursive="0" shebangs_converted="0"
488 488
489 while (($#)); do 489 while (($#)); do
490 case "$1" in 490 case "$1" in
491 -r|--recursive) 491 -r|--recursive)
492 recursive="1" 492 recursive="1"
547 [[ "${only_executables}" == "1" && ! -x "${file}" ]] && continue 547 [[ "${only_executables}" == "1" && ! -x "${file}" ]] && continue
548 548
549 if [[ "$(head -n1 "${file}")" =~ ${_PYTHON_SHEBANG_BASE_PART_REGEX} ]]; then 549 if [[ "$(head -n1 "${file}")" =~ ${_PYTHON_SHEBANG_BASE_PART_REGEX} ]]; then
550 [[ "$(sed -ne "2p" "${file}")" =~ ^"# Gentoo '".*"' wrapper script generated by python_generate_wrapper_scripts()"$ ]] && continue 550 [[ "$(sed -ne "2p" "${file}")" =~ ^"# Gentoo '".*"' wrapper script generated by python_generate_wrapper_scripts()"$ ]] && continue
551 551
552 shebangs_converted="1"
553
552 if [[ "${quiet}" == "0" ]]; then 554 if [[ "${quiet}" == "0" ]]; then
553 einfo "Converting shebang in '${file}'" 555 einfo "Converting shebang in '${file}'"
554 fi 556 fi
555 557
556 sed -e "1s:^#![[:space:]]*\([^[:space:]]*/usr/bin/env[[:space:]]\)\?[[:space:]]*\([^[:space:]]*/\)\?\(jython\|pypy-c\|python\)\([[:digit:]]\+\(\.[[:digit:]]\+\)\?\)\?\(\$\|[[:space:]].*\):#!\1\2${python_interpreter}\6:" -i "${file}" || die "Conversion of shebang in '${file}' failed" 558 sed -e "1s:^#![[:space:]]*\([^[:space:]]*/usr/bin/env[[:space:]]\)\?[[:space:]]*\([^[:space:]]*/\)\?\(jython\|pypy-c\|python\)\([[:digit:]]\+\(\.[[:digit:]]\+\)\?\)\?\(\$\|[[:space:]].*\):#!\1\2${python_interpreter}\6:" -i "${file}" || die "Conversion of shebang in '${file}' failed"
557 fi 559 fi
560 done
561
562 if [[ "${shebangs_converted}" == "0" ]]; then
563 ewarn "${FUNCNAME}(): Python scripts not found"
564 fi
565}
566
567# @FUNCTION: python_clean_py-compile_files
568# @USAGE: [-q|--quiet]
569# @DESCRIPTION:
570# Clean py-compile files to disable byte-compilation.
571python_clean_py-compile_files() {
572 _python_check_python_pkg_setup_execution
573
574 local file files=() quiet="0"
575
576 while (($#)); do
577 case "$1" in
578 -q|--quiet)
579 quiet="1"
580 ;;
581 -*)
582 die "${FUNCNAME}(): Unrecognized option '$1'"
583 ;;
584 *)
585 die "${FUNCNAME}(): Invalid usage"
586 ;;
587 esac
588 shift
589 done
590
591 while read -d $'\0' -r file; do
592 files+=("${file#./}")
593 done < <(find -name py-compile -type f -print0)
594
595 for file in "${files[@]}"; do
596 if [[ "${quiet}" == "0" ]]; then
597 einfo "Cleaning '${file}' file"
598 fi
599 echo "#!/bin/sh" > "${file}"
558 done 600 done
559} 601}
560 602
561# @FUNCTION: python_clean_installation_image 603# @FUNCTION: python_clean_installation_image
562# @USAGE: [-q|--quiet] 604# @USAGE: [-q|--quiet]
800 die "Active version of CPython 3 is not supported by ${CATEGORY}/${PF}" 842 die "Active version of CPython 3 is not supported by ${CATEGORY}/${PF}"
801 fi 843 fi
802 else 844 else
803 python3_version="" 845 python3_version=""
804 fi 846 fi
847 fi
848
849 if [[ -z "${python2_version}" && -z "${python3_version}" ]]; then
850 eerror "${CATEGORY}/${PF} requires at least one of the following packages:"
851 for PYTHON_ABI in "${_CPYTHON2_GLOBALLY_SUPPORTED_ABIS[@]}" "${_CPYTHON3_GLOBALLY_SUPPORTED_ABIS[@]}"; do
852 if ! _python_check_python_abi_matching --patterns-list "${PYTHON_ABI}" "${RESTRICT_PYTHON_ABIS}"; then
853 eerror " dev-lang/python:${PYTHON_ABI}"
854 fi
855 done
856 die "No supported version of CPython installed"
805 fi 857 fi
806 858
807 if [[ -n "${python2_version}" && "${python_version}" == "2."* && "${python_version}" != "${python2_version}" ]]; then 859 if [[ -n "${python2_version}" && "${python_version}" == "2."* && "${python_version}" != "${python2_version}" ]]; then
808 eerror "Python wrapper is configured incorrectly or '${EPREFIX}/usr/bin/python2' symlink" 860 eerror "Python wrapper is configured incorrectly or '${EPREFIX}/usr/bin/python2' symlink"
809 eerror "is set incorrectly. Use \`eselect python\` to fix configuration." 861 eerror "is set incorrectly. Use \`eselect python\` to fix configuration."
967 python_default_function() { 1019 python_default_function() {
968 emake "$@" 1020 emake "$@"
969 } 1021 }
970 elif [[ "${EBUILD_PHASE}" == "test" ]]; then 1022 elif [[ "${EBUILD_PHASE}" == "test" ]]; then
971 python_default_function() { 1023 python_default_function() {
1024 # Stolen from portage's _eapi0_src_test()
1025 local emake_cmd="${MAKE:-make} ${MAKEOPTS} ${EXTRA_EMAKE}"
972 if emake -j1 -n check &> /dev/null; then 1026 if ${emake_cmd} -j1 -n check &> /dev/null; then
973 emake -j1 check "$@" 1027 ${emake_cmd} -j1 check "$@"
974 elif emake -j1 -n test &> /dev/null; then 1028 elif ${emake_cmd} -j1 -n test &> /dev/null; then
975 emake -j1 test "$@" 1029 ${emake_cmd} -j1 test "$@"
976 fi 1030 fi
977 } 1031 }
978 elif [[ "${EBUILD_PHASE}" == "install" ]]; then 1032 elif [[ "${EBUILD_PHASE}" == "install" ]]; then
979 python_default_function() { 1033 python_default_function() {
980 emake DESTDIR="${D}" install "$@" 1034 emake DESTDIR="${D}" install "$@"

Legend:
Removed from v.1.144  
changed lines
  Added in v.1.152

  ViewVC Help
Powered by ViewVC 1.1.20