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

Diff of /eclass/python.eclass

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

Revision 1.145 Revision 1.146
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.145 2012/01/21 19:48:20 floppym Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.146 2012/01/30 20:18:38 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
9# @DESCRIPTION: 9# @DESCRIPTION:
10# The python eclass contains miscellaneous, useful functions for Python packages. 10# The python eclass contains miscellaneous, useful functions for Python packages.
11 11
12# Must call inherit before EXPORT_FUNCTIONS to avoid QA warning. 12# Must call inherit before EXPORT_FUNCTIONS to avoid QA warning.
13if [[ -z "${_PYTHON_ECLASS_INHERITED}" ]]; then 13if [[ -z "${_PYTHON_ECLASS_INHERITED}" ]]; then
14 inherit multilib 14 inherit eutils multilib
15fi 15fi
16 16
17# Export pkg_setup every time to avoid issues with eclass inheritance order. 17# Export pkg_setup every time to avoid issues with eclass inheritance order.
18if ! has "${EAPI:-0}" 0 1 2 3 || { has "${EAPI:-0}" 2 3 && [[ -n "${PYTHON_USE_WITH}" || -n "${PYTHON_USE_WITH_OR}" ]]; }; then 18if ! has "${EAPI:-0}" 0 1 2 3 || { has "${EAPI:-0}" 2 3 && [[ -n "${PYTHON_USE_WITH}" || -n "${PYTHON_USE_WITH_OR}" ]]; }; then
19 EXPORT_FUNCTIONS pkg_setup 19 EXPORT_FUNCTIONS pkg_setup
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
558 done 560 done
561
562 if [[ "${shebangs_converted}" == "0" ]]; then
563 eqawarn "${FUNCNAME}(): Python scripts not found"
564 fi
559} 565}
560 566
561# @FUNCTION: python_clean_py-compile_files 567# @FUNCTION: python_clean_py-compile_files
562# @USAGE: [-q|--quiet] 568# @USAGE: [-q|--quiet]
563# @DESCRIPTION: 569# @DESCRIPTION:

Legend:
Removed from v.1.145  
changed lines
  Added in v.1.146

  ViewVC Help
Powered by ViewVC 1.1.20