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

Diff of /eclass/python.eclass

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

Revision 1.74 Revision 1.75
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.74 2009/10/02 02:02:24 arfrever Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.75 2009/10/02 17:32:23 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.
125 die "'/usr/bin/python-config' isn't valid script" 125 die "'/usr/bin/python-config' isn't valid script"
126 fi 126 fi
127 127
128 # USE_${ABI_TYPE^^} and RESTRICT_${ABI_TYPE^^}_ABIS variables hopefully will be included in EAPI >= 4. 128 # USE_${ABI_TYPE^^} and RESTRICT_${ABI_TYPE^^}_ABIS variables hopefully will be included in EAPI >= 4.
129 if [[ "$(declare -p PYTHON_ABIS 2> /dev/null)" != "declare -x PYTHON_ABIS="* ]] && has "${EAPI:-0}" 0 1 2 3; then 129 if [[ "$(declare -p PYTHON_ABIS 2> /dev/null)" != "declare -x PYTHON_ABIS="* ]] && has "${EAPI:-0}" 0 1 2 3; then
130 local ABI restricted_ABI support_ABI supported_PYTHON_ABIS= 130 local ABI python2_supported_versions python3_supported_versions restricted_ABI support_ABI supported_PYTHON_ABIS=
131 PYTHON_ABI_SUPPORTED_VALUES="2.4 2.5 2.6 2.7 3.0 3.1 3.2" 131 PYTHON_ABI_SUPPORTED_VALUES="2.4 2.5 2.6 2.7 3.0 3.1 3.2"
132 python2_supported_versions="2.4 2.5 2.6 2.7"
133 python3_supported_versions="3.0 3.1 3.2"
132 134
133 if [[ "$(declare -p USE_PYTHON 2> /dev/null)" == "declare -x USE_PYTHON="* ]]; then 135 if [[ "$(declare -p USE_PYTHON 2> /dev/null)" == "declare -x USE_PYTHON="* ]]; then
136 local python2_enabled="0" python3_enabled="0"
137
134 if [[ -z "${USE_PYTHON}" ]]; then 138 if [[ -z "${USE_PYTHON}" ]]; then
135 die "USE_PYTHON variable is empty" 139 die "USE_PYTHON variable is empty"
136 fi 140 fi
137 141
138 for ABI in ${USE_PYTHON}; do 142 for ABI in ${USE_PYTHON}; do
139 if ! has "${ABI}" ${PYTHON_ABI_SUPPORTED_VALUES}; then 143 if ! has "${ABI}" ${PYTHON_ABI_SUPPORTED_VALUES}; then
140 die "USE_PYTHON variable contains invalid value '${ABI}'" 144 die "USE_PYTHON variable contains invalid value '${ABI}'"
141 fi 145 fi
146
147 if has "${ABI}" ${python2_supported_versions}; then
148 python2_enabled="1"
149 fi
150 if has "${ABI}" ${python3_supported_versions}; then
151 python3_enabled="1"
152 fi
153
142 support_ABI="1" 154 support_ABI="1"
143 for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do 155 for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
144 if python -c "from fnmatch import fnmatch; exit(not fnmatch('${ABI}', '${restricted_ABI}'))"; then 156 if python -c "from fnmatch import fnmatch; exit(not fnmatch('${ABI}', '${restricted_ABI}'))"; then
145 support_ABI="0" 157 support_ABI="0"
146 break 158 break
151 export PYTHON_ABIS="${supported_PYTHON_ABIS# }" 163 export PYTHON_ABIS="${supported_PYTHON_ABIS# }"
152 164
153 if [[ -z "${PYTHON_ABIS//[${IFS}]/}" ]]; then 165 if [[ -z "${PYTHON_ABIS//[${IFS}]/}" ]]; then
154 die "USE_PYTHON variable doesn't enable any version of Python supported by ${CATEGORY}/${PF}" 166 die "USE_PYTHON variable doesn't enable any version of Python supported by ${CATEGORY}/${PF}"
155 fi 167 fi
168
169 if [[ "${python2_enabled}" == "0" ]]; then
170 ewarn "USE_PYTHON variable doesn't enable any version of Python 2. This configuration is unsupported."
171 fi
172 if [[ "${python3_enabled}" == "0" ]]; then
173 ewarn "USE_PYTHON variable doesn't enable any version of Python 3. This configuration is unsupported."
174 fi
156 else 175 else
157 local ABI python2_version= python2_supported_versions python3_version= python3_supported_versions restricted_ABI support_python_major_version 176 local python2_version= python3_version= support_python_major_version
158 177
159 if has_version "=dev-lang/python-2*"; then 178 if has_version "=dev-lang/python-2*"; then
160 if [[ "$(readlink /usr/bin/python2)" != "python2."* ]]; then 179 if [[ "$(readlink /usr/bin/python2)" != "python2."* ]]; then
161 die "'/usr/bin/python2' isn't valid symlink" 180 die "'/usr/bin/python2' isn't valid symlink"
162 fi 181 fi
163 182
164 python2_version="$(/usr/bin/python2 -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')" 183 python2_version="$(/usr/bin/python2 -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')"
165 python2_supported_versions="2.4 2.5 2.6 2.7"
166 184
167 for ABI in ${python2_supported_versions}; do 185 for ABI in ${python2_supported_versions}; do
168 support_python_major_version="1" 186 support_python_major_version="1"
169 for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do 187 for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
170 if python -c "from fnmatch import fnmatch; exit(not fnmatch('${ABI}', '${restricted_ABI}'))"; then 188 if python -c "from fnmatch import fnmatch; exit(not fnmatch('${ABI}', '${restricted_ABI}'))"; then
188 if [[ "$(readlink /usr/bin/python3)" != "python3."* ]]; then 206 if [[ "$(readlink /usr/bin/python3)" != "python3."* ]]; then
189 die "'/usr/bin/python3' isn't valid symlink" 207 die "'/usr/bin/python3' isn't valid symlink"
190 fi 208 fi
191 209
192 python3_version="$(/usr/bin/python3 -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')" 210 python3_version="$(/usr/bin/python3 -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')"
193 python3_supported_versions="3.0 3.1 3.2"
194 211
195 for ABI in ${python3_supported_versions}; do 212 for ABI in ${python3_supported_versions}; do
196 support_python_major_version="1" 213 support_python_major_version="1"
197 for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do 214 for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
198 if python -c "from fnmatch import fnmatch; exit(not fnmatch('${ABI}', '${restricted_ABI}'))"; then 215 if python -c "from fnmatch import fnmatch; exit(not fnmatch('${ABI}', '${restricted_ABI}'))"; then

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

  ViewVC Help
Powered by ViewVC 1.1.20