diff options
author | Arfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org> | 2009-12-24 04:21:39 +0000 |
---|---|---|
committer | Arfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org> | 2009-12-24 04:21:39 +0000 |
commit | d2d35c15da9e3a1cd6836ddb6b9af69c4e3f3a0a (patch) | |
tree | 3042db7803594f62387d9a7b05fc4067559efdb7 /eclass | |
parent | Manually call python_generate_wrapper_scripts(). (diff) | |
download | gentoo-2-d2d35c15da9e3a1cd6836ddb6b9af69c4e3f3a0a.tar.gz gentoo-2-d2d35c15da9e3a1cd6836ddb6b9af69c4e3f3a0a.tar.bz2 gentoo-2-d2d35c15da9e3a1cd6836ddb6b9af69c4e3f3a0a.zip |
Disallow using of ${python}, distutils_python_version() and distutils_python_tkinter() in EAPI >=3. Add renaming of Python scripts containing versioned shebangs and generation of wrapper scripts.
Diffstat (limited to 'eclass')
-rw-r--r-- | eclass/distutils.eclass | 53 |
1 files changed, 51 insertions, 2 deletions
diff --git a/eclass/distutils.eclass b/eclass/distutils.eclass index d54c0494f346..c555bd06cc7d 100644 --- a/eclass/distutils.eclass +++ b/eclass/distutils.eclass @@ -1,6 +1,6 @@ # Copyright 1999-2009 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/distutils.eclass,v 1.67 2009/11/28 18:39:27 arfrever Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/distutils.eclass,v 1.68 2009/12/24 04:21:39 arfrever Exp $ # @ECLASS: distutils.eclass # @MAINTAINER: @@ -28,7 +28,12 @@ if [[ -z "${DISTUTILS_DISABLE_PYTHON_DEPENDENCY}" ]]; then DEPEND="virtual/python" RDEPEND="${DEPEND}" fi -python="python" + +if has "${EAPI:-0}" 0 1 2; then + python="python" +else + python="die" +fi # @ECLASS-VARIABLE: DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES # @DESCRIPTION: @@ -38,6 +43,11 @@ python="python" # @DESCRIPTION: # Global options passed to setup.py. +# @ECLASS-VARIABLE: DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS +# @DESCRIPTION: +# Set this to disable renaming of Python scripts containing versioned shebangs +# and generation of wrapper scripts. + # @ECLASS-VARIABLE: DOCS # @DESCRIPTION: # Additional DOCS @@ -153,6 +163,24 @@ distutils_src_install() { python_need_rebuild if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then + if [[ -z "${DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS}" && "${BASH_VERSINFO[0]}" -ge "4" ]]; then + declare -A wrapper_scripts=() + + rename_scripts_with_versioned_shebangs() { + if [[ -d "${D}usr/bin" ]]; then + cd "${D}usr/bin" + + local file + for file in *; do + if [[ -f "${file}" && ! "${file}" =~ [[:digit:]]+\.[[:digit:]]+$ && "$(head -n1 "${file}")" =~ ^'#!'.*python[[:digit:]]+\.[[:digit:]]+ ]]; then + mv "${file}" "${file}-${PYTHON_ABI}" || die "Renaming of '${file}' failed" + wrapper_scripts+=(["${D}usr/bin/${file}"]=) + fi + done + fi + } + fi + if [[ -n "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]]; then installation() { _distutils_hook pre @@ -167,6 +195,10 @@ distutils_src_install() { echo "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@" "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@" || return "$?" + if [[ -z "${DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS}" && "${BASH_VERSINFO[0]}" -ge "4" ]]; then + rename_scripts_with_versioned_shebangs + fi + _distutils_hook post } python_execute_function -s installation "$@" @@ -184,10 +216,19 @@ distutils_src_install() { echo "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build -b "build-${PYTHON_ABI}" install --root="${D}" --no-compile "$@" "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build -b "build-${PYTHON_ABI}" install --root="${D}" --no-compile "$@" || return "$?" + if [[ -z "${DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS}" && "${BASH_VERSINFO[0]}" -ge "4" ]]; then + rename_scripts_with_versioned_shebangs + fi + _distutils_hook post } python_execute_function installation "$@" fi + + if [[ -z "${DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS}" && "${#wrapper_scripts[@]}" -ne "0" && "${BASH_VERSINFO[0]}" -ge "4" ]]; then + python_generate_wrapper_scripts "${!wrapper_scripts[@]}" + fi + unset wrapper_scripts else # need this for python-2.5 + setuptools in cases where # a package uses distutils but does not install anything @@ -283,6 +324,10 @@ distutils_pkg_postrm() { # Calls python_version, so that you can use something like # e.g. insinto ${ROOT}/usr/include/python${PYVER} distutils_python_version() { + if ! has "${EAPI:-0}" 0 1 2; then + die "${FUNCNAME}() cannot be used in this EAPI" + fi + python_version } @@ -290,5 +335,9 @@ distutils_python_version() { # @DESCRIPTION: # Checks for if tkinter support is compiled into python distutils_python_tkinter() { + if ! has "${EAPI:-0}" 0 1 2; then + die "${FUNCNAME}() cannot be used in this EAPI" + fi + python_tkinter_exists } |