diff options
author | Arfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org> | 2010-01-11 16:07:23 +0000 |
---|---|---|
committer | Arfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org> | 2010-01-11 16:07:23 +0000 |
commit | 4fbd05558ec1077001f6de8bbeda70b820ff72f5 (patch) | |
tree | 751db7b98ffdb9d2713f65131a67be37f02b0ae6 /eclass/python.eclass | |
parent | Various fixes to make it useable actually. (diff) | |
download | gentoo-2-4fbd05558ec1077001f6de8bbeda70b820ff72f5.tar.gz gentoo-2-4fbd05558ec1077001f6de8bbeda70b820ff72f5.tar.bz2 gentoo-2-4fbd05558ec1077001f6de8bbeda70b820ff72f5.zip |
Disable has_version() checks for Python implementations (bug #300579).
Improve some messages.
Diffstat (limited to 'eclass/python.eclass')
-rw-r--r-- | eclass/python.eclass | 78 |
1 files changed, 44 insertions, 34 deletions
diff --git a/eclass/python.eclass b/eclass/python.eclass index 0e41aece5510..889f0191829d 100644 --- a/eclass/python.eclass +++ b/eclass/python.eclass @@ -1,6 +1,6 @@ # Copyright 1999-2010 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.83 2010/01/10 17:03:08 arfrever Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.84 2010/01/11 16:07:23 arfrever Exp $ # @ECLASS: python.eclass # @MAINTAINER: @@ -186,6 +186,14 @@ PYTHON() { fi } +_python_implementation() { + if [[ "${CATEGORY}/${PN}" == "dev-lang/python" ]]; then + return 0 + else + return 1 + fi +} + # @FUNCTION: python_set_active_version # @USAGE: <Python_ABI|2|3> # @DESCRIPTION: @@ -196,18 +204,18 @@ python_set_active_version() { fi if [[ "$1" =~ ^[[:digit:]]+\.[[:digit:]]+$ ]]; then - if ! has_version "dev-lang/python:$1"; then - die "${FUNCNAME}(): 'dev-lang/python:$1' isn't installed" + if ! _python_implementation && ! has_version "dev-lang/python:$1"; then + die "${FUNCNAME}(): 'dev-lang/python:$1' is not installed" fi export EPYTHON="$(PYTHON "$1")" elif [[ "$1" == "2" ]]; then - if ! has_version "=dev-lang/python-2*"; then - die "${FUNCNAME}(): '=dev-lang/python-2*' isn't installed" + if ! _python_implementation && ! has_version "=dev-lang/python-2*"; then + die "${FUNCNAME}(): '=dev-lang/python-2*' is not installed" fi export EPYTHON="$(PYTHON -2)" elif [[ "$1" == "3" ]]; then - if ! has_version "=dev-lang/python-3*"; then - die "${FUNCNAME}(): '=dev-lang/python-3*' isn't installed" + if ! _python_implementation && ! has_version "=dev-lang/python-3*"; then + die "${FUNCNAME}(): '=dev-lang/python-3*' is not installed" fi export EPYTHON="$(PYTHON -3)" else @@ -215,7 +223,7 @@ python_set_active_version() { fi # PYTHON_ABI variable is intended to be used only in ebuilds/eclasses, - # so it doesn't need to be exported to subprocesses. + # so it does not need to be exported to subprocesses. PYTHON_ABI="${EPYTHON#python}" PYTHON_ABI="${PYTHON_ABI%%-*}" } @@ -281,14 +289,14 @@ validate_PYTHON_ABIS() { done if [[ -z "${PYTHON_ABIS//[${IFS}]/}" ]]; then - die "USE_PYTHON variable doesn't enable any version of Python supported by ${CATEGORY}/${PF}" + die "USE_PYTHON variable does not enable any version of Python supported by ${CATEGORY}/${PF}" fi if [[ "${python2_enabled}" == "0" ]]; then - ewarn "USE_PYTHON variable doesn't enable any version of Python 2. This configuration is unsupported." + ewarn "USE_PYTHON variable does not enable any version of Python 2. This configuration is unsupported." fi if [[ "${python3_enabled}" == "0" ]]; then - ewarn "USE_PYTHON variable doesn't enable any version of Python 3. This configuration is unsupported." + ewarn "USE_PYTHON variable does not enable any version of Python 3. This configuration is unsupported." fi else local python_version python2_version= python3_version= support_python_major_version @@ -297,7 +305,7 @@ validate_PYTHON_ABIS() { if has_version "=dev-lang/python-2*"; then if [[ "$(readlink /usr/bin/python2)" != "python2."* ]]; then - die "'/usr/bin/python2' isn't valid symlink" + die "'/usr/bin/python2' is not valid symlink" fi python2_version="$(/usr/bin/python2 -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')" @@ -314,7 +322,7 @@ validate_PYTHON_ABIS() { if [[ "${support_python_major_version}" == "1" ]]; then for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do if [[ "${python2_version}" == ${restricted_ABI} ]]; then - die "Active version of Python 2 isn't supported by ${CATEGORY}/${PF}" + die "Active version of Python 2 is not supported by ${CATEGORY}/${PF}" fi done else @@ -324,7 +332,7 @@ validate_PYTHON_ABIS() { if has_version "=dev-lang/python-3*"; then if [[ "$(readlink /usr/bin/python3)" != "python3."* ]]; then - die "'/usr/bin/python3' isn't valid symlink" + die "'/usr/bin/python3' is not valid symlink" fi python3_version="$(/usr/bin/python3 -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')" @@ -341,7 +349,7 @@ validate_PYTHON_ABIS() { if [[ "${support_python_major_version}" == "1" ]]; then for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do if [[ "${python3_version}" == ${restricted_ABI} ]]; then - die "Active version of Python 3 isn't supported by ${CATEGORY}/${PF}" + die "Active version of Python 3 is not supported by ${CATEGORY}/${PF}" fi done else @@ -366,12 +374,12 @@ validate_PYTHON_ABIS() { fi fi - if [[ "$(declare -p PYTHON_ABIS_SANITY_CHECKS 2> /dev/null)" != "declare -- PYTHON_ABIS_SANITY_CHECKS="* ]]; then + if ! _python_implementation && [[ "$(declare -p PYTHON_ABIS_SANITY_CHECKS 2> /dev/null)" != "declare -- PYTHON_ABIS_SANITY_CHECKS="* ]]; then local PYTHON_ABI for PYTHON_ABI in ${PYTHON_ABIS}; do # Ensure that appropriate version of Python is installed. if ! has_version "dev-lang/python:${PYTHON_ABI}"; then - die "dev-lang/python:${PYTHON_ABI} isn't installed" + die "dev-lang/python:${PYTHON_ABI} is not installed" fi # Ensure that EPYTHON variable is respected. @@ -382,7 +390,7 @@ validate_PYTHON_ABIS() { eerror "EPYTHON: '$(PYTHON)'" eerror "PYTHON_ABI: '${PYTHON_ABI}'" eerror "Version of enabled Python: '$(EPYTHON="$(PYTHON)" python -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')'" - die "'python' doesn't respect EPYTHON variable" + die "'python' does not respect EPYTHON variable" fi done PYTHON_ABIS_SANITY_CHECKS="1" @@ -445,7 +453,7 @@ python_set_build_dir_symlink() { [[ -z "${PYTHON_ABI}" ]] && die "PYTHON_ABI variable not set" [[ -z "${dir}" ]] && dir="build" - # Don't delete preexistent directories. + # Do not delete preexistent directories. rm -f "${dir}" || die "Deletion of '${dir}' failed" ln -s "${dir}-${PYTHON_ABI}" "${dir}" || die "Creation of '${dir}' directory symlink failed" } @@ -509,7 +517,7 @@ python_execute_function() { shift if [[ -z "$(type -t "${function}")" ]]; then - die "${FUNCNAME}(): '${function}' function isn't defined" + die "${FUNCNAME}(): '${function}' function is not defined" fi else if [[ "$#" -ne "0" ]]; then @@ -640,7 +648,7 @@ python_execute_function() { fi fi - # Ensure that directory stack hasn't been decreased. + # Ensure that directory stack has not been decreased. if [[ "$(dirs -p | wc -l)" -lt "${previous_directory_stack_length}" ]]; then die "Directory stack decreased illegally" fi @@ -650,7 +658,7 @@ python_execute_function() { popd > /dev/null || die "popd failed" done - # Ensure that the bottom part of directory stack hasn't been changed. Restore + # Ensure that the bottom part of directory stack has not been changed. Restore # previous directory (from before running of the specified function) before # comparison of directory stacks to avoid mismatch of directory stacks after # potential using of 'cd' to change current directory. Restoration of previous @@ -714,7 +722,7 @@ python_convert_shebangs() { for argument in "$@"; do if [[ ! -e "${argument}" ]]; then - die "${FUNCNAME}(): '${argument}' doesn't exist" + die "${FUNCNAME}(): '${argument}' does not exist" elif [[ -f "${argument}" ]]; then files+=("${argument}") elif [[ -d "${argument}" ]]; then @@ -725,10 +733,10 @@ python_convert_shebangs() { files+=($(find "${argument}" -type f)) fi else - die "${FUNCNAME}(): '${argument}' isn't a regular file" + die "${FUNCNAME}(): '${argument}' is not a regular file" fi else - die "${FUNCNAME}(): '${argument}' isn't a regular file or a directory" + die "${FUNCNAME}(): '${argument}' is not a regular file or a directory" fi done @@ -1010,7 +1018,7 @@ fi # @FUNCTION: python_disable_pyc # @DESCRIPTION: # Tell Python not to automatically recompile modules to .pyc/.pyo -# even if the timestamps/version stamps don't match. This is done +# even if the timestamps/version stamps do not match. This is done # to protect sandbox. python_disable_pyc() { export PYTHONDONTWRITEBYTECODE="1" @@ -1027,6 +1035,8 @@ python_enable_pyc() { # @FUNCTION: python_need_rebuild # @DESCRIPTION: Run without arguments, specifies that the package should be # rebuilt after a python upgrade. +# Do not use this function in ebuilds of packages supporting installation +# for multiple versions of Python. python_need_rebuild() { export PYTHON_NEED_REBUILD="$(PYTHON -A --ABI)" } @@ -1165,8 +1175,8 @@ python_mod_optimize() { ewarn "${FUNCNAME}: Ignoring compile option $1" ;; *) - if [[ "$1" =~ ^/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then - die "${FUNCNAME} doesn't support absolute paths of directories/files in site-packages directories" + if ! _python_implementation && [[ "$1" =~ ^/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then + die "${FUNCNAME} does not support absolute paths of directories/files in site-packages directories" elif [[ "$1" =~ ^/ ]]; then if [[ -d "${root}/$1" ]]; then other_dirs+=("${root}/$1") @@ -1175,7 +1185,7 @@ python_mod_optimize() { elif [[ -e "${root}/$1" ]]; then ewarn "'${root}/$1' is not a file or a directory!" else - ewarn "'${root}/$1' doesn't exist!" + ewarn "'${root}/$1' does not exist!" fi else for PYTHON_ABI in ${PYTHON_ABIS-${PYTHON_ABI-$(PYTHON -A --ABI)}}; do @@ -1188,7 +1198,7 @@ python_mod_optimize() { elif [[ -e "${root}$(python_get_sitedir)/$1" ]]; then ewarn "'$1' is not a file or a directory!" else - ewarn "'$1' doesn't exist!" + ewarn "'$1' does not exist!" fi done fi @@ -1223,7 +1233,7 @@ python_mod_optimize() { unset site_packages_absolute_dirs site_packages_absolute_files done - # Don't use PYTHON_ABI in next calls to python_get_libdir(). + # Do not use PYTHON_ABI in next calls to python_get_libdir(). unset PYTHON_ABI if ((${#other_dirs[@]})) || ((${#other_files[@]})); then @@ -1267,7 +1277,7 @@ python_mod_optimize() { elif [[ -e "${myroot}/$1" ]]; then ewarn "${myroot}/$1 is not a file or directory!" else - ewarn "${myroot}/$1 doesn't exist!" + ewarn "${myroot}/$1 does not exist!" fi ;; esac @@ -1314,8 +1324,8 @@ python_mod_cleanup() { if (($#)); then if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then while (($#)); do - if [[ "$1" =~ ^/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then - die "${FUNCNAME} doesn't support absolute paths of directories/files in site-packages directories" + if ! _python_implementation && [[ "$1" =~ ^/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then + die "${FUNCNAME} does not support absolute paths of directories/files in site-packages directories" elif [[ "$1" =~ ^/ ]]; then SEARCH_PATH+=("${root}/${1#/}") else |