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

Diff of /eclass/python.eclass

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

Revision 1.125 Revision 1.126
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.125 2011/07/08 07:47:30 djc Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.126 2011/07/08 07:48:38 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
16fi 16fi
17 17
18_CPYTHON2_GLOBALLY_SUPPORTED_ABIS=(2.4 2.5 2.6 2.7) 18_CPYTHON2_GLOBALLY_SUPPORTED_ABIS=(2.4 2.5 2.6 2.7)
19_CPYTHON3_GLOBALLY_SUPPORTED_ABIS=(3.1 3.2 3.3) 19_CPYTHON3_GLOBALLY_SUPPORTED_ABIS=(3.1 3.2 3.3)
20_JYTHON_GLOBALLY_SUPPORTED_ABIS=(2.5-jython) 20_JYTHON_GLOBALLY_SUPPORTED_ABIS=(2.5-jython)
21_PYPY_GLOBALLY_SUPPORTED_ABIS=(2.7-pypy-1.5)
21_PYTHON_GLOBALLY_SUPPORTED_ABIS=(${_CPYTHON2_GLOBALLY_SUPPORTED_ABIS[@]} ${_CPYTHON3_GLOBALLY_SUPPORTED_ABIS[@]} ${_JYTHON_GLOBALLY_SUPPORTED_ABIS[@]}) 22_PYTHON_GLOBALLY_SUPPORTED_ABIS=(${_CPYTHON2_GLOBALLY_SUPPORTED_ABIS[@]} ${_CPYTHON3_GLOBALLY_SUPPORTED_ABIS[@]} ${_JYTHON_GLOBALLY_SUPPORTED_ABIS[@]} ${_PYPY_GLOBALLY_SUPPORTED_ABIS[@]})
22 23
23# ================================================================================================ 24# ================================================================================================
24# ===================================== HANDLING OF METADATA ===================================== 25# ===================================== HANDLING OF METADATA =====================================
25# ================================================================================================ 26# ================================================================================================
26 27
59 60
60 if [[ "${pattern}" == *"-cpython" ]]; then 61 if [[ "${pattern}" == *"-cpython" ]]; then
61 [[ "${PYTHON_ABI}" =~ ^[[:digit:]]+\.[[:digit:]]+$ && "${PYTHON_ABI}" == ${pattern%-cpython} ]] 62 [[ "${PYTHON_ABI}" =~ ^[[:digit:]]+\.[[:digit:]]+$ && "${PYTHON_ABI}" == ${pattern%-cpython} ]]
62 elif [[ "${pattern}" == *"-jython" ]]; then 63 elif [[ "${pattern}" == *"-jython" ]]; then
63 [[ "${PYTHON_ABI}" == ${pattern} ]] 64 [[ "${PYTHON_ABI}" == ${pattern} ]]
65 elif [[ "${pattern}" == *"-pypy-"* ]]; then
66 [[ "${PYTHON_ABI}" == ${pattern} ]]
64 else 67 else
65 if [[ "${PYTHON_ABI}" =~ ^[[:digit:]]+\.[[:digit:]]+$ ]]; then 68 if [[ "${PYTHON_ABI}" =~ ^[[:digit:]]+\.[[:digit:]]+$ ]]; then
66 [[ "${PYTHON_ABI}" == ${pattern} ]] 69 [[ "${PYTHON_ABI}" == ${pattern} ]]
67 elif [[ "${PYTHON_ABI}" =~ ^[[:digit:]]+\.[[:digit:]]+-jython$ ]]; then 70 elif [[ "${PYTHON_ABI}" =~ ^[[:digit:]]+\.[[:digit:]]+-jython$ ]]; then
68 [[ "${PYTHON_ABI%-jython}" == ${pattern} ]] 71 [[ "${PYTHON_ABI%-jython}" == ${pattern} ]]
72 elif [[ "${PYTHON_ABI}" =~ ^[[:digit:]]+\.[[:digit:]]+-pypy-[[:digit:]]+\.[[:digit:]]+$ ]]; then
73 [[ "${PYTHON_ABI%-pypy-*}" == ${pattern} ]]
69 else 74 else
70 die "${FUNCNAME}(): Unrecognized Python ABI '${PYTHON_ABI}'" 75 die "${FUNCNAME}(): Unrecognized Python ABI '${PYTHON_ABI}'"
71 fi 76 fi
72 fi 77 fi
73 else 78 else
292_python_implementation() { 297_python_implementation() {
293 if [[ "${CATEGORY}/${PN}" == "dev-lang/python" ]]; then 298 if [[ "${CATEGORY}/${PN}" == "dev-lang/python" ]]; then
294 return 0 299 return 0
295 elif [[ "${CATEGORY}/${PN}" == "dev-java/jython" ]]; then 300 elif [[ "${CATEGORY}/${PN}" == "dev-java/jython" ]]; then
296 return 0 301 return 0
302 elif [[ "${CATEGORY}/${PN}" == "dev-python/pypy" ]]; then
303 return 0
297 else 304 else
298 return 1 305 return 1
299 fi 306 fi
300} 307}
301 308
460 467
461if ! has "${EAPI:-0}" 0 1 2 3 || { has "${EAPI:-0}" 2 3 && [[ -n "${PYTHON_USE_WITH}" || -n "${PYTHON_USE_WITH_OR}" ]]; }; then 468if ! has "${EAPI:-0}" 0 1 2 3 || { has "${EAPI:-0}" 2 3 && [[ -n "${PYTHON_USE_WITH}" || -n "${PYTHON_USE_WITH_OR}" ]]; }; then
462 EXPORT_FUNCTIONS pkg_setup 469 EXPORT_FUNCTIONS pkg_setup
463fi 470fi
464 471
465_PYTHON_SHEBANG_BASE_PART_REGEX='^#![[:space:]]*([^[:space:]]*/usr/bin/env[[:space:]]+)?([^[:space:]]*/)?(jython|python)' 472_PYTHON_SHEBANG_BASE_PART_REGEX='^#![[:space:]]*([^[:space:]]*/usr/bin/env[[:space:]]+)?([^[:space:]]*/)?(jython|pypy-c|python)'
466 473
467# @FUNCTION: python_convert_shebangs 474# @FUNCTION: python_convert_shebangs
468# @USAGE: [-q|--quiet] [-r|--recursive] [-x|--only-executables] [--] <Python_ABI|Python_version> <file|directory> [files|directories] 475# @USAGE: [-q|--quiet] [-r|--recursive] [-x|--only-executables] [--] <Python_ABI|Python_version> <file|directory> [files|directories]
469# @DESCRIPTION: 476# @DESCRIPTION:
470# Convert shebangs in specified files. Directories can be specified only with --recursive option. 477# Convert shebangs in specified files. Directories can be specified only with --recursive option.
538 545
539 if [[ "${quiet}" == "0" ]]; then 546 if [[ "${quiet}" == "0" ]]; then
540 einfo "Converting shebang in '${file}'" 547 einfo "Converting shebang in '${file}'"
541 fi 548 fi
542 549
543 sed -e "1s:^#![[:space:]]*\([^[:space:]]*/usr/bin/env[[:space:]]\)\?[[:space:]]*\([^[:space:]]*/\)\?\(jython\|python\)\([[:digit:]]\+\(\.[[:digit:]]\+\)\?\)\?\(\$\|[[:space:]].*\):#!\1\2${python_interpreter}\6:" -i "${file}" || die "Conversion of shebang in '${file}' failed" 550 sed -e "1s:^#![[:space:]]*\([^[:space:]]*/usr/bin/env[[:space:]]\)\?[[:space:]]*\([^[:space:]]*/\)\?\(jython\|pypy-c\|python\)\([[:digit:]]\+\(\.[[:digit:]]\+\)\?\)\?\(\$\|[[:space:]].*\):#!\1\2${python_interpreter}\6:" -i "${file}" || die "Conversion of shebang in '${file}' failed"
544 fi 551 fi
545 done 552 done
546} 553}
547 554
548# @FUNCTION: python_clean_installation_image 555# @FUNCTION: python_clean_installation_image
1226import subprocess 1233import subprocess
1227import sys 1234import sys
1228 1235
1229cpython_re = re.compile(r"^python(\d+\.\d+)$") 1236cpython_re = re.compile(r"^python(\d+\.\d+)$")
1230jython_re = re.compile(r"^jython(\d+\.\d+)$") 1237jython_re = re.compile(r"^jython(\d+\.\d+)$")
1238pypy_re = re.compile(r"^pypy-c(\d+\.\d+)$")
1231python_shebang_re = re.compile(r"^#! *(${EPREFIX}/usr/bin/python|(${EPREFIX})?/usr/bin/env +(${EPREFIX}/usr/bin/)?python)") 1239python_shebang_re = re.compile(r"^#! *(${EPREFIX}/usr/bin/python|(${EPREFIX})?/usr/bin/env +(${EPREFIX}/usr/bin/)?python)")
1232python_verification_output_re = re.compile("^GENTOO_PYTHON_TARGET_SCRIPT_PATH supported\n$") 1240python_verification_output_re = re.compile("^GENTOO_PYTHON_TARGET_SCRIPT_PATH supported\n$")
1241
1242pypy_versions_mapping = {
1243 "1.5": "2.7"
1244}
1233 1245
1234def get_PYTHON_ABI(EPYTHON): 1246def get_PYTHON_ABI(EPYTHON):
1235 cpython_matched = cpython_re.match(EPYTHON) 1247 cpython_matched = cpython_re.match(EPYTHON)
1236 jython_matched = jython_re.match(EPYTHON) 1248 jython_matched = jython_re.match(EPYTHON)
1249 pypy_matched = pypy_re.match(EPYTHON)
1237 if cpython_matched is not None: 1250 if cpython_matched is not None:
1238 PYTHON_ABI = cpython_matched.group(1) 1251 PYTHON_ABI = cpython_matched.group(1)
1239 elif jython_matched is not None: 1252 elif jython_matched is not None:
1240 PYTHON_ABI = jython_matched.group(1) + "-jython" 1253 PYTHON_ABI = jython_matched.group(1) + "-jython"
1254 elif pypy_matched is not None:
1255 PYTHON_ABI = pypy_versions_mapping[pypy_matched.group(1)] + "-pypy-" + pypy_matched.group(1)
1241 else: 1256 else:
1242 PYTHON_ABI = None 1257 PYTHON_ABI = None
1243 return PYTHON_ABI 1258 return PYTHON_ABI
1244 1259
1245EOF 1260EOF
1652 1667
1653# ================================================================================================ 1668# ================================================================================================
1654# ======================================= GETTER FUNCTIONS ======================================= 1669# ======================================= GETTER FUNCTIONS =======================================
1655# ================================================================================================ 1670# ================================================================================================
1656 1671
1657_PYTHON_ABI_EXTRACTION_COMMAND='import platform 1672_PYTHON_ABI_EXTRACTION_COMMAND=\
1673'import platform
1658import sys 1674import sys
1659sys.stdout.write(".".join(str(x) for x in sys.version_info[:2])) 1675sys.stdout.write(".".join(str(x) for x in sys.version_info[:2]))
1660if platform.system()[:4] == "Java": 1676if platform.system()[:4] == "Java":
1661 sys.stdout.write("-jython")' 1677 sys.stdout.write("-jython")
1678elif hasattr(platform, "python_implementation") and platform.python_implementation() == "PyPy":
1679 sys.stdout.write("-pypy-" + ".".join(str(x) for x in sys.pypy_version_info[:2]))'
1662 1680
1663_python_get_implementation() { 1681_python_get_implementation() {
1664 local ignore_invalid="0" 1682 local ignore_invalid="0"
1665 1683
1666 while (($#)); do 1684 while (($#)); do
1688 1706
1689 if [[ "$1" =~ ^[[:digit:]]+\.[[:digit:]]+$ ]]; then 1707 if [[ "$1" =~ ^[[:digit:]]+\.[[:digit:]]+$ ]]; then
1690 echo "CPython" 1708 echo "CPython"
1691 elif [[ "$1" =~ ^[[:digit:]]+\.[[:digit:]]+-jython$ ]]; then 1709 elif [[ "$1" =~ ^[[:digit:]]+\.[[:digit:]]+-jython$ ]]; then
1692 echo "Jython" 1710 echo "Jython"
1711 elif [[ "$1" =~ ^[[:digit:]]+\.[[:digit:]]+-pypy-[[:digit:]]+\.[[:digit:]]+$ ]]; then
1712 echo "PyPy"
1693 else 1713 else
1694 if [[ "${ignore_invalid}" == "0" ]]; then 1714 if [[ "${ignore_invalid}" == "0" ]]; then
1695 die "${FUNCNAME}(): Unrecognized Python ABI '$1'" 1715 die "${FUNCNAME}(): Unrecognized Python ABI '$1'"
1696 fi 1716 fi
1697 fi 1717 fi
1806 else 1826 else
1807 if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then 1827 if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
1808 python_interpreter="python${PYTHON_ABI}" 1828 python_interpreter="python${PYTHON_ABI}"
1809 elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then 1829 elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
1810 python_interpreter="jython${PYTHON_ABI%-jython}" 1830 python_interpreter="jython${PYTHON_ABI%-jython}"
1831 elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "PyPy" ]]; then
1832 python_interpreter="pypy-c${PYTHON_ABI#*-pypy-}"
1811 fi 1833 fi
1812 1834
1813 if [[ "${absolute_path_output}" == "1" ]]; then 1835 if [[ "${absolute_path_output}" == "1" ]]; then
1814 echo -n "${EPREFIX}/usr/bin/${python_interpreter}" 1836 echo -n "${EPREFIX}/usr/bin/${python_interpreter}"
1815 else 1837 else
1908 if [[ "${EAPI:-0}" == "0" ]]; then 1930 if [[ "${EAPI:-0}" == "0" ]]; then
1909 if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then 1931 if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
1910 echo "=dev-lang/python-${PYTHON_ABI}*" 1932 echo "=dev-lang/python-${PYTHON_ABI}*"
1911 elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then 1933 elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
1912 echo "=dev-java/jython-${PYTHON_ABI%-jython}*" 1934 echo "=dev-java/jython-${PYTHON_ABI%-jython}*"
1935 elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "PyPy" ]]; then
1936 echo "=dev-python/pypy-${PYTHON_ABI#*-pypy-}*"
1913 fi 1937 fi
1914 else 1938 else
1915 if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then 1939 if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
1916 echo "dev-lang/python:${PYTHON_ABI}" 1940 echo "dev-lang/python:${PYTHON_ABI}"
1917 elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then 1941 elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
1918 echo "dev-java/jython:${PYTHON_ABI%-jython}" 1942 echo "dev-java/jython:${PYTHON_ABI%-jython}"
1943 elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "PyPy" ]]; then
1944 echo "dev-python/pypy:${PYTHON_ABI#*-pypy-}"
1919 fi 1945 fi
1920 fi 1946 fi
1921} 1947}
1922 1948
1923# @FUNCTION: python_get_includedir 1949# @FUNCTION: python_get_includedir
1970 1996
1971 if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then 1997 if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
1972 echo "${prefix}usr/include/python${PYTHON_ABI}" 1998 echo "${prefix}usr/include/python${PYTHON_ABI}"
1973 elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then 1999 elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
1974 echo "${prefix}usr/share/jython-${PYTHON_ABI%-jython}/Include" 2000 echo "${prefix}usr/share/jython-${PYTHON_ABI%-jython}/Include"
2001 elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "PyPy" ]]; then
2002 echo "${prefix}usr/$(get_libdir)/pypy${PYTHON_ABI#*-pypy-}/include"
1975 fi 2003 fi
1976} 2004}
1977 2005
1978# @FUNCTION: python_get_libdir 2006# @FUNCTION: python_get_libdir
1979# @USAGE: [-b|--base-path] [-f|--final-ABI] 2007# @USAGE: [-b|--base-path] [-f|--final-ABI]
1980# @DESCRIPTION: 2008# @DESCRIPTION:
1981# Print path to Python library directory. 2009# Print path to Python standard library directory.
1982# If --base-path option is specified, then path not prefixed with "/" is printed. 2010# If --base-path option is specified, then path not prefixed with "/" is printed.
1983# If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used. 2011# If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
1984python_get_libdir() { 2012python_get_libdir() {
1985 _python_check_python_pkg_setup_execution 2013 _python_check_python_pkg_setup_execution
1986 2014
2025 2053
2026 if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then 2054 if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
2027 echo "${prefix}usr/$(get_libdir)/python${PYTHON_ABI}" 2055 echo "${prefix}usr/$(get_libdir)/python${PYTHON_ABI}"
2028 elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then 2056 elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
2029 echo "${prefix}usr/share/jython-${PYTHON_ABI%-jython}/Lib" 2057 echo "${prefix}usr/share/jython-${PYTHON_ABI%-jython}/Lib"
2058 elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "PyPy" ]]; then
2059 die "${FUNCNAME}(): PyPy has multiple standard library directories"
2030 fi 2060 fi
2031} 2061}
2032 2062
2033# @FUNCTION: python_get_sitedir 2063# @FUNCTION: python_get_sitedir
2034# @USAGE: [-b|--base-path] [-f|--final-ABI] 2064# @USAGE: [-b|--base-path] [-f|--final-ABI]
2037# If --base-path option is specified, then path not prefixed with "/" is printed. 2067# If --base-path option is specified, then path not prefixed with "/" is printed.
2038# If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used. 2068# If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
2039python_get_sitedir() { 2069python_get_sitedir() {
2040 _python_check_python_pkg_setup_execution 2070 _python_check_python_pkg_setup_execution
2041 2071
2042 local final_ABI="0" options=() 2072 local base_path="0" final_ABI="0" prefix PYTHON_ABI="${PYTHON_ABI}"
2043 2073
2044 while (($#)); do 2074 while (($#)); do
2045 case "$1" in 2075 case "$1" in
2046 -b|--base-path) 2076 -b|--base-path)
2047 options+=("$1") 2077 base_path="1"
2048 ;; 2078 ;;
2049 -f|--final-ABI) 2079 -f|--final-ABI)
2050 final_ABI="1" 2080 final_ABI="1"
2051 options+=("$1")
2052 ;; 2081 ;;
2053 -*) 2082 -*)
2054 die "${FUNCNAME}(): Unrecognized option '$1'" 2083 die "${FUNCNAME}(): Unrecognized option '$1'"
2055 ;; 2084 ;;
2056 *) 2085 *)
2057 die "${FUNCNAME}(): Invalid usage" 2086 die "${FUNCNAME}(): Invalid usage"
2058 ;; 2087 ;;
2059 esac 2088 esac
2060 shift 2089 shift
2061 done 2090 done
2091
2092 if [[ "${base_path}" == "0" ]]; then
2093 prefix="/"
2094 fi
2062 2095
2063 if [[ "${final_ABI}" == "1" ]]; then 2096 if [[ "${final_ABI}" == "1" ]]; then
2064 if ! _python_package_supporting_installation_for_multiple_python_abis; then 2097 if ! _python_package_supporting_installation_for_multiple_python_abis; then
2065 die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs" 2098 die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
2066 fi 2099 fi
2100 PYTHON_ABI="$(PYTHON -f --ABI)"
2067 else 2101 else
2068 if _python_package_supporting_installation_for_multiple_python_abis && ! _python_abi-specific_local_scope; then 2102 if _python_package_supporting_installation_for_multiple_python_abis; then
2103 if ! _python_abi-specific_local_scope; then
2069 die "${FUNCNAME}() should be used in ABI-specific local scope" 2104 die "${FUNCNAME}() should be used in ABI-specific local scope"
2070 fi 2105 fi
2106 else
2107 PYTHON_ABI="${PYTHON_ABI:-$(PYTHON --ABI)}"
2071 fi 2108 fi
2109 fi
2072 2110
2073 echo "$(python_get_libdir "${options[@]}")/site-packages" 2111 if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
2112 echo "${prefix}usr/$(get_libdir)/python${PYTHON_ABI}/site-packages"
2113 elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
2114 echo "${prefix}usr/share/jython-${PYTHON_ABI%-jython}/Lib/site-packages"
2115 elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "PyPy" ]]; then
2116 echo "${prefix}usr/$(get_libdir)/pypy${PYTHON_ABI#*-pypy-}/site-packages"
2117 fi
2074} 2118}
2075 2119
2076# @FUNCTION: python_get_library 2120# @FUNCTION: python_get_library
2077# @USAGE: [-b|--base-path] [-f|--final-ABI] [-l|--linker-option] 2121# @USAGE: [-b|--base-path] [-f|--final-ABI] [-l|--linker-option]
2078# @DESCRIPTION: 2122# @DESCRIPTION:
2135 else 2179 else
2136 echo "${prefix}usr/$(get_libdir)/libpython${PYTHON_ABI}$(get_libname)" 2180 echo "${prefix}usr/$(get_libdir)/libpython${PYTHON_ABI}$(get_libname)"
2137 fi 2181 fi
2138 elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then 2182 elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
2139 die "${FUNCNAME}(): Jython does not have shared library" 2183 die "${FUNCNAME}(): Jython does not have shared library"
2184 elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "PyPy" ]]; then
2185 die "${FUNCNAME}(): PyPy does not have shared library"
2140 fi 2186 fi
2141} 2187}
2142 2188
2143# @FUNCTION: python_get_version 2189# @FUNCTION: python_get_version
2144# @USAGE: [-f|--final-ABI] [-l|--language] [--full] [--major] [--minor] [--micro] 2190# @USAGE: [-f|--final-ABI] [-l|--language] [--full] [--major] [--minor] [--micro]
2217 else 2263 else
2218 echo "${language_version}" 2264 echo "${language_version}"
2219 fi 2265 fi
2220 else 2266 else
2221 if [[ "${full}" == "1" ]]; then 2267 if [[ "${full}" == "1" ]]; then
2222 python_command="from sys import version_info; print('.'.join(str(x) for x in version_info[:3]))" 2268 python_command="import sys; print('.'.join(str(x) for x in getattr(sys, 'pypy_version_info', sys.version_info)[:3]))"
2223 elif [[ "${major}" == "1" ]]; then 2269 elif [[ "${major}" == "1" ]]; then
2224 python_command="from sys import version_info; print(version_info[0])" 2270 python_command="import sys; print(getattr(sys, 'pypy_version_info', sys.version_info)[0])"
2225 elif [[ "${minor}" == "1" ]]; then 2271 elif [[ "${minor}" == "1" ]]; then
2226 python_command="from sys import version_info; print(version_info[1])" 2272 python_command="import sys; print(getattr(sys, 'pypy_version_info', sys.version_info)[1])"
2227 elif [[ "${micro}" == "1" ]]; then 2273 elif [[ "${micro}" == "1" ]]; then
2228 python_command="from sys import version_info; print(version_info[2])" 2274 python_command="import sys; print(getattr(sys, 'pypy_version_info', sys.version_info)[2])"
2229 else 2275 else
2230 if [[ -n "${PYTHON_ABI}" && "${final_ABI}" == "0" ]]; then 2276 if [[ -n "${PYTHON_ABI}" && "${final_ABI}" == "0" ]]; then
2231 if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then 2277 if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
2232 echo "${PYTHON_ABI}" 2278 echo "${PYTHON_ABI}"
2233 elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then 2279 elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
2234 echo "${PYTHON_ABI%-jython}" 2280 echo "${PYTHON_ABI%-jython}"
2281 elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "PyPy" ]]; then
2282 echo "${PYTHON_ABI#*-pypy-}"
2235 fi 2283 fi
2236 return 2284 return
2237 fi 2285 fi
2238 python_command="from sys import version_info; print('.'.join(str(x) for x in version_info[:2]))" 2286 python_command="from sys import version_info; print('.'.join(str(x) for x in version_info[:2]))"
2239 fi 2287 fi
2759 dirs+=("${root}$(python_get_sitedir)/${dir}") 2807 dirs+=("${root}$(python_get_sitedir)/${dir}")
2760 done 2808 done
2761 for dir in "${evaluated_dirs[@]}"; do 2809 for dir in "${evaluated_dirs[@]}"; do
2762 eval "dirs+=(\"\${root}${dir}\")" 2810 eval "dirs+=(\"\${root}${dir}\")"
2763 done 2811 done
2764 stderr+="${stderr:+$'\n'}$("$(PYTHON)" "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${dirs[@]}" 2>&1)" || return_code="1" 2812 stderr+="${stderr:+$'\n'}$("$(PYTHON)" -m compileall "${options[@]}" "${dirs[@]}" 2>&1)" || return_code="1"
2765 if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then 2813 if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
2766 "$(PYTHON)" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${dirs[@]}" &> /dev/null || return_code="1" 2814 "$(PYTHON)" -O -m compileall "${options[@]}" "${dirs[@]}" &> /dev/null || return_code="1"
2767 fi 2815 fi
2768 _python_clean_compiled_modules "${dirs[@]}" 2816 _python_clean_compiled_modules "${dirs[@]}"
2769 fi 2817 fi
2770 if ((${#site_packages_files[@]})) || ((${#evaluated_files[@]})); then 2818 if ((${#site_packages_files[@]})) || ((${#evaluated_files[@]})); then
2771 for file in "${site_packages_files[@]}"; do 2819 for file in "${site_packages_files[@]}"; do
2772 files+=("${root}$(python_get_sitedir)/${file}") 2820 files+=("${root}$(python_get_sitedir)/${file}")
2773 done 2821 done
2774 for file in "${evaluated_files[@]}"; do 2822 for file in "${evaluated_files[@]}"; do
2775 eval "files+=(\"\${root}${file}\")" 2823 eval "files+=(\"\${root}${file}\")"
2776 done 2824 done
2777 stderr+="${stderr:+$'\n'}$("$(PYTHON)" "${root}$(python_get_libdir)/py_compile.py" "${files[@]}" 2>&1)" || return_code="1" 2825 stderr+="${stderr:+$'\n'}$("$(PYTHON)" -m py_compile "${files[@]}" 2>&1)" || return_code="1"
2778 if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then 2826 if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
2779 "$(PYTHON)" -O "${root}$(python_get_libdir)/py_compile.py" "${files[@]}" &> /dev/null || return_code="1" 2827 "$(PYTHON)" -O -m py_compile "${files[@]}" &> /dev/null || return_code="1"
2780 fi 2828 fi
2781 _python_clean_compiled_modules "${files[@]}" 2829 _python_clean_compiled_modules "${files[@]}"
2782 fi 2830 fi
2783 eend "${return_code}" 2831 eend "${return_code}"
2784 if [[ -n "${stderr}" ]]; then 2832 if [[ -n "${stderr}" ]]; then
2803 if ((${#other_dirs[@]})) || ((${#other_files[@]})); then 2851 if ((${#other_dirs[@]})) || ((${#other_files[@]})); then
2804 return_code="0" 2852 return_code="0"
2805 stderr="" 2853 stderr=""
2806 ebegin "Compilation and optimization of Python modules placed outside of site-packages directories for $(python_get_implementation_and_version)" 2854 ebegin "Compilation and optimization of Python modules placed outside of site-packages directories for $(python_get_implementation_and_version)"
2807 if ((${#other_dirs[@]})); then 2855 if ((${#other_dirs[@]})); then
2808 stderr+="${stderr:+$'\n'}$("$(PYTHON ${PYTHON_ABI})" "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" 2>&1)" || return_code="1" 2856 stderr+="${stderr:+$'\n'}$("$(PYTHON ${PYTHON_ABI})" -m compileall "${options[@]}" "${other_dirs[@]}" 2>&1)" || return_code="1"
2809 if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then 2857 if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
2810 "$(PYTHON ${PYTHON_ABI})" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" &> /dev/null || return_code="1" 2858 "$(PYTHON ${PYTHON_ABI})" -O -m compileall "${options[@]}" "${other_dirs[@]}" &> /dev/null || return_code="1"
2811 fi 2859 fi
2812 _python_clean_compiled_modules "${other_dirs[@]}" 2860 _python_clean_compiled_modules "${other_dirs[@]}"
2813 fi 2861 fi
2814 if ((${#other_files[@]})); then 2862 if ((${#other_files[@]})); then
2815 stderr+="${stderr:+$'\n'}$("$(PYTHON ${PYTHON_ABI})" "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" 2>&1)" || return_code="1" 2863 stderr+="${stderr:+$'\n'}$("$(PYTHON ${PYTHON_ABI})" -m py_compile "${other_files[@]}" 2>&1)" || return_code="1"
2816 if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then 2864 if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
2817 "$(PYTHON ${PYTHON_ABI})" -O "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" &> /dev/null || return_code="1" 2865 "$(PYTHON ${PYTHON_ABI})" -O -m py_compile "${other_files[@]}" &> /dev/null || return_code="1"
2818 fi 2866 fi
2819 _python_clean_compiled_modules "${other_files[@]}" 2867 _python_clean_compiled_modules "${other_files[@]}"
2820 fi 2868 fi
2821 eend "${return_code}" 2869 eend "${return_code}"
2822 if [[ -n "${stderr}" ]]; then 2870 if [[ -n "${stderr}" ]]; then

Legend:
Removed from v.1.125  
changed lines
  Added in v.1.126

  ViewVC Help
Powered by ViewVC 1.1.20