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

Diff of /eclass/python.eclass

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

Revision 1.117 Revision 1.118
1# Copyright 1999-2011 Gentoo Foundation 1# Copyright 1999-2011 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.117 2011/07/04 11:28:24 djc Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.118 2011/07/08 07:37:49 djc 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
2137 die "${FUNCNAME}(): Jython does not have shared library" 2137 die "${FUNCNAME}(): Jython does not have shared library"
2138 fi 2138 fi
2139} 2139}
2140 2140
2141# @FUNCTION: python_get_version 2141# @FUNCTION: python_get_version
2142# @USAGE: [-f|--final-ABI] [--full] [--major] [--minor] [--micro] 2142# @USAGE: [-f|--final-ABI] [-l|--language] [--full] [--major] [--minor] [--micro]
2143# @DESCRIPTION: 2143# @DESCRIPTION:
2144# Print Python version. 2144# Print Python version.
2145# --full, --major, --minor and --micro options cannot be specified simultaneously. 2145# --full, --major, --minor and --micro options cannot be specified simultaneously.
2146# If --full, --major, --minor and --micro options are not specified, then "${major_version}.${minor_version}" is printed. 2146# If --full, --major, --minor and --micro options are not specified, then "${major_version}.${minor_version}" is printed.
2147# If --language option is specified, then Python language version is printed.
2148# --language and --full options cannot be specified simultaneously.
2149# --language and --micro options cannot be specified simultaneously.
2147# If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used. 2150# If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
2148python_get_version() { 2151python_get_version() {
2149 _python_check_python_pkg_setup_execution 2152 _python_check_python_pkg_setup_execution
2150 2153
2151 local final_ABI="0" full="0" major="0" minor="0" micro="0" python_command 2154 local final_ABI="0" language="0" language_version full="0" major="0" minor="0" micro="0" PYTHON_ABI="${PYTHON_ABI}" python_command
2152 2155
2153 while (($#)); do 2156 while (($#)); do
2154 case "$1" in 2157 case "$1" in
2155 -f|--final-ABI) 2158 -f|--final-ABI)
2156 final_ABI="1" 2159 final_ABI="1"
2157 ;; 2160 ;;
2161 -l|--language)
2162 language="1"
2163 ;;
2158 --full) 2164 --full)
2159 full="1" 2165 full="1"
2160 ;; 2166 ;;
2161 --major) 2167 --major)
2162 major="1" 2168 major="1"
2174 die "${FUNCNAME}(): Invalid usage" 2180 die "${FUNCNAME}(): Invalid usage"
2175 ;; 2181 ;;
2176 esac 2182 esac
2177 shift 2183 shift
2178 done 2184 done
2179
2180 if [[ "$((${full} + ${major} + ${minor} + ${micro}))" -gt 1 ]]; then
2181 die "${FUNCNAME}(): '--full', '--major', '--minor' or '--micro' options cannot be specified simultaneously"
2182 fi
2183
2184 if [[ "${full}" == "1" ]]; then
2185 python_command="from sys import version_info; print('.'.join(str(x) for x in version_info[:3]))"
2186 elif [[ "${major}" == "1" ]]; then
2187 python_command="from sys import version_info; print(version_info[0])"
2188 elif [[ "${minor}" == "1" ]]; then
2189 python_command="from sys import version_info; print(version_info[1])"
2190 elif [[ "${micro}" == "1" ]]; then
2191 python_command="from sys import version_info; print(version_info[2])"
2192 else
2193 if [[ -n "${PYTHON_ABI}" && "${final_ABI}" == "0" ]]; then
2194 if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
2195 echo "${PYTHON_ABI}"
2196 elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
2197 echo "${PYTHON_ABI%-jython}"
2198 fi
2199 return
2200 fi
2201 python_command="from sys import version_info; print('.'.join(str(x) for x in version_info[:2]))"
2202 fi
2203 2185
2204 if [[ "${final_ABI}" == "1" ]]; then 2186 if [[ "${final_ABI}" == "1" ]]; then
2205 if ! _python_package_supporting_installation_for_multiple_python_abis; then 2187 if ! _python_package_supporting_installation_for_multiple_python_abis; then
2206 die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs" 2188 die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
2207 fi 2189 fi
2208 "$(PYTHON -f)" -c "${python_command}"
2209 else 2190 else
2210 if _python_package_supporting_installation_for_multiple_python_abis && ! _python_abi-specific_local_scope; then 2191 if _python_package_supporting_installation_for_multiple_python_abis && ! _python_abi-specific_local_scope; then
2211 die "${FUNCNAME}() should be used in ABI-specific local scope" 2192 die "${FUNCNAME}() should be used in ABI-specific local scope"
2212 fi 2193 fi
2194 fi
2195
2196 if [[ "$((${full} + ${major} + ${minor} + ${micro}))" -gt 1 ]]; then
2197 die "${FUNCNAME}(): '--full', '--major', '--minor' or '--micro' options cannot be specified simultaneously"
2198 fi
2199
2200 if [[ "${language}" == "1" ]]; then
2201 if [[ "${final_ABI}" == "1" ]]; then
2202 PYTHON_ABI="$(PYTHON -f --ABI)"
2203 elif [[ -z "${PYTHON_ABI}" ]]; then
2204 PYTHON_ABI="$(PYTHON --ABI)"
2205 fi
2206 language_version="${PYTHON_ABI%%-*}"
2207 if [[ "${full}" == "1" ]]; then
2208 die "${FUNCNAME}(): '--language' and '--full' options cannot be specified simultaneously"
2209 elif [[ "${major}" == "1" ]]; then
2210 echo "${language_version%.*}"
2211 elif [[ "${minor}" == "1" ]]; then
2212 echo "${language_version#*.}"
2213 elif [[ "${micro}" == "1" ]]; then
2214 die "${FUNCNAME}(): '--language' and '--micro' options cannot be specified simultaneously"
2215 else
2216 echo "${language_version}"
2217 fi
2218 else
2219 if [[ "${full}" == "1" ]]; then
2220 python_command="from sys import version_info; print('.'.join(str(x) for x in version_info[:3]))"
2221 elif [[ "${major}" == "1" ]]; then
2222 python_command="from sys import version_info; print(version_info[0])"
2223 elif [[ "${minor}" == "1" ]]; then
2224 python_command="from sys import version_info; print(version_info[1])"
2225 elif [[ "${micro}" == "1" ]]; then
2226 python_command="from sys import version_info; print(version_info[2])"
2227 else
2228 if [[ -n "${PYTHON_ABI}" && "${final_ABI}" == "0" ]]; then
2229 if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
2230 echo "${PYTHON_ABI}"
2231 elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
2232 echo "${PYTHON_ABI%-jython}"
2233 fi
2234 return
2235 fi
2236 python_command="from sys import version_info; print('.'.join(str(x) for x in version_info[:2]))"
2237 fi
2238
2239 if [[ "${final_ABI}" == "1" ]]; then
2240 "$(PYTHON -f)" -c "${python_command}"
2241 else
2213 "$(PYTHON ${PYTHON_ABI})" -c "${python_command}" 2242 "$(PYTHON ${PYTHON_ABI})" -c "${python_command}"
2243 fi
2214 fi 2244 fi
2215} 2245}
2216 2246
2217# ================================================================================================ 2247# ================================================================================================
2218# ================================ FUNCTIONS FOR RUNNING OF TESTS ================================ 2248# ================================ FUNCTIONS FOR RUNNING OF TESTS ================================

Legend:
Removed from v.1.117  
changed lines
  Added in v.1.118

  ViewVC Help
Powered by ViewVC 1.1.20