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

Diff of /eclass/python.eclass

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

Revision 1.75 Revision 1.76
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.75 2009/10/02 17:32:23 arfrever Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.76 2009/10/02 23:09:08 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# @BLURB: A utility eclass that should be inherited by anything that deals with Python or Python modules. 8# @BLURB: A utility eclass that should be inherited by anything that deals with Python or Python modules.
108 fi 108 fi
109} 109}
110 110
111# @FUNCTION: validate_PYTHON_ABIS 111# @FUNCTION: validate_PYTHON_ABIS
112# @DESCRIPTION: 112# @DESCRIPTION:
113# Make sure PYTHON_ABIS variable has valid value. 113# Ensure that PYTHON_ABIS variable has valid value.
114validate_PYTHON_ABIS() { 114validate_PYTHON_ABIS() {
115 # Ensure that some functions cannot be accidentally successfully used in EAPI <= 2 without setting SUPPORT_PYTHON_ABIS variable. 115 # Ensure that some functions cannot be accidentally successfully used in EAPI <= 2 without setting SUPPORT_PYTHON_ABIS variable.
116 if has "${EAPI:-0}" 0 1 2 && [[ -z "${SUPPORT_PYTHON_ABIS}" ]]; then 116 if has "${EAPI:-0}" 0 1 2 && [[ -z "${SUPPORT_PYTHON_ABIS}" ]]; then
117 die "${FUNCNAME}() cannot be used in this EAPI without setting SUPPORT_PYTHON_ABIS variable" 117 die "${FUNCNAME}() cannot be used in this EAPI without setting SUPPORT_PYTHON_ABIS variable"
118 fi 118 fi
171 fi 171 fi
172 if [[ "${python3_enabled}" == "0" ]]; then 172 if [[ "${python3_enabled}" == "0" ]]; then
173 ewarn "USE_PYTHON variable doesn't enable any version of Python 3. This configuration is unsupported." 173 ewarn "USE_PYTHON variable doesn't enable any version of Python 3. This configuration is unsupported."
174 fi 174 fi
175 else 175 else
176 local python2_version= python3_version= support_python_major_version 176 local python_version python2_version= python3_version= support_python_major_version
177
178 python_version="$(/usr/bin/python -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')"
177 179
178 if has_version "=dev-lang/python-2*"; then 180 if has_version "=dev-lang/python-2*"; then
179 if [[ "$(readlink /usr/bin/python2)" != "python2."* ]]; then 181 if [[ "$(readlink /usr/bin/python2)" != "python2."* ]]; then
180 die "'/usr/bin/python2' isn't valid symlink" 182 die "'/usr/bin/python2' isn't valid symlink"
181 fi 183 fi
227 else 229 else
228 python3_version="" 230 python3_version=""
229 fi 231 fi
230 fi 232 fi
231 233
234 if ! has "${python_version}" "${python2_version}" "${python3_version}"; then
235 eerror "Python wrapper is configured incorrectly or /usr/bin/python2 or /usr/bin/python3 symlink"
236 eerror "is set incorrectly. Use \`eselect python\` to fix configuration."
237 die "Incorrect configuration of Python"
238 fi
239
232 PYTHON_ABIS="${python2_version} ${python3_version}" 240 PYTHON_ABIS="${python2_version} ${python3_version}"
233 PYTHON_ABIS="${PYTHON_ABIS# }" 241 PYTHON_ABIS="${PYTHON_ABIS# }"
234 export PYTHON_ABIS="${PYTHON_ABIS% }" 242 export PYTHON_ABIS="${PYTHON_ABIS% }"
235 fi 243 fi
236 fi 244 fi
555 if [[ -n "${PYTHON_ABI}" ]]; then 563 if [[ -n "${PYTHON_ABI}" ]]; then
556 pyatom="dev-lang/python:${PYTHON_ABI}" 564 pyatom="dev-lang/python:${PYTHON_ABI}"
557 else 565 else
558 python_version 566 python_version
559 pyatom="dev-lang/python:${PYVER}" 567 pyatom="dev-lang/python:${PYVER}"
568 fi
569
570 # Workaround for older versions of Portage.
571 # has_version() calls portageq which is implemented in Python.
572 if has_version "=dev-lang/python-2*"; then
573 local EPYTHON
574 export EPYTHON="$(readlink /usr/bin/python2)"
560 fi 575 fi
561 576
562 for use in ${PYTHON_USE_WITH}; do 577 for use in ${PYTHON_USE_WITH}; do
563 if ! has_version "${pyatom}[${use}]"; then 578 if ! has_version "${pyatom}[${use}]"; then
564 python_pkg_setup_fail "Please rebuild ${pyatom} with the following USE flags enabled: ${PYTHON_USE_WITH}" 579 python_pkg_setup_fail "Please rebuild ${pyatom} with the following USE flags enabled: ${PYTHON_USE_WITH}"

Legend:
Removed from v.1.75  
changed lines
  Added in v.1.76

  ViewVC Help
Powered by ViewVC 1.1.20