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

Diff of /eclass/python.eclass

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

Revision 1.91 Revision 1.93
1# Copyright 1999-2010 Gentoo Foundation 1# Copyright 1999-2010 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.91 2010/02/28 15:49:33 arfrever Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.93 2010/03/12 18:27:01 betelgeuse 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
188# @DESCRIPTION: 188# @DESCRIPTION:
189# Makes sure PYTHON_USE_WITH or PYTHON_USE_WITH_OR listed use flags 189# Makes sure PYTHON_USE_WITH or PYTHON_USE_WITH_OR listed use flags
190# are respected. Only exported if one of those variables is set. 190# are respected. Only exported if one of those variables is set.
191if ! has "${EAPI:-0}" 0 1 && [[ -n ${PYTHON_USE_WITH} || -n ${PYTHON_USE_WITH_OR} ]]; then 191if ! has "${EAPI:-0}" 0 1 && [[ -n ${PYTHON_USE_WITH} || -n ${PYTHON_USE_WITH_OR} ]]; then
192 python_pkg_setup() { 192 python_pkg_setup() {
193 # Check if phase is pkg_setup().
194 [[ "${EBUILD_PHASE}" != "setup" ]] && die "${FUNCNAME}() can be used only in pkg_setup() phase"
195
193 python_pkg_setup_fail() { 196 python_pkg_setup_fail() {
194 eerror "${1}" 197 eerror "${1}"
195 die "${1}" 198 die "${1}"
196 } 199 }
197 200
227 unset -f python_pkg_setup_check_USE_flags python_pkg_setup_fail 230 unset -f python_pkg_setup_check_USE_flags python_pkg_setup_fail
228 } 231 }
229 232
230 EXPORT_FUNCTIONS pkg_setup 233 EXPORT_FUNCTIONS pkg_setup
231 234
232 _PYTHON_USE_WITH_ATOM="" 235 _PYTHON_USE_WITH_ATOMS_ARRAY=()
233 if [[ -n "${PYTHON_USE_WITH}" ]]; then 236 if [[ -n "${PYTHON_USE_WITH}" ]]; then
234 for _PYTHON_ATOM in "${_PYTHON_ATOMS[@]}"; do 237 for _PYTHON_ATOM in "${_PYTHON_ATOMS[@]}"; do
235 _PYTHON_USE_WITH_ATOM+="${_PYTHON_USE_WITH_ATOM:+ }${_PYTHON_ATOM}[${PYTHON_USE_WITH/ /,}]" 238 _PYTHON_USE_WITH_ATOMS_ARRAY+=("${_PYTHON_ATOM}[${PYTHON_USE_WITH/ /,}]")
236 done 239 done
237 _PYTHON_USE_WITH_ATOM="|| ( ${_PYTHON_USE_WITH_ATOM} )"
238 elif [[ -n "${PYTHON_USE_WITH_OR}" ]]; then 240 elif [[ -n "${PYTHON_USE_WITH_OR}" ]]; then
239 for _USE_flag in ${PYTHON_USE_WITH_OR}; do 241 for _USE_flag in ${PYTHON_USE_WITH_OR}; do
240 for _PYTHON_ATOM in "${_PYTHON_ATOMS[@]}"; do 242 for _PYTHON_ATOM in "${_PYTHON_ATOMS[@]}"; do
241 _PYTHON_USE_WITH_ATOM+="${_PYTHON_USE_WITH_ATOM:+ }${_PYTHON_ATOM}[${_USE_flag}]" 243 _PYTHON_USE_WITH_ATOMS_ARRAY+=("${_PYTHON_ATOM}[${_USE_flag}]")
242 done 244 done
243 done 245 done
244 unset _USE_flag 246 unset _USE_flag
247 fi
248 if [[ "${#_PYTHON_USE_WITH_ATOMS_ARRAY[@]}" -gt 1 ]]; then
245 _PYTHON_USE_WITH_ATOM="|| ( ${_PYTHON_USE_WITH_ATOM} )" 249 _PYTHON_USE_WITH_ATOMS="|| ( ${_PYTHON_USE_WITH_ATOMS_ARRAY[@]} )"
250 else
251 _PYTHON_USE_WITH_ATOMS="${_PYTHON_USE_WITH_ATOMS_ARRAY[@]}"
246 fi 252 fi
247 if [[ -n "${PYTHON_USE_WITH_OPT}" ]]; then 253 if [[ -n "${PYTHON_USE_WITH_OPT}" ]]; then
248 _PYTHON_USE_WITH_ATOM="${PYTHON_USE_WITH_OPT}? ( ${_PYTHON_USE_WITH_ATOM} )" 254 _PYTHON_USE_WITH_ATOMS="${PYTHON_USE_WITH_OPT}? ( ${_PYTHON_USE_WITH_ATOMS} )"
249 fi 255 fi
250 DEPEND+=" ${_PYTHON_USE_WITH_ATOM}" 256 DEPEND+=" ${_PYTHON_USE_WITH_ATOMS}"
251 RDEPEND+=" ${_PYTHON_USE_WITH_ATOM}" 257 RDEPEND+=" ${_PYTHON_USE_WITH_ATOMS}"
252 unset _PYTHON_ATOM _PYTHON_USE_WITH_ATOM 258 unset _PYTHON_ATOM _PYTHON_USE_WITH_ATOMS _PYTHON_USE_WITH_ATOMS_ARRAY
253fi 259fi
254 260
255unset _PYTHON_ATOMS 261unset _PYTHON_ATOMS
256 262
257# ================================================================================================ 263# ================================================================================================
1261 die "${FUNCNAME}(): Jython does not have shared library" 1267 die "${FUNCNAME}(): Jython does not have shared library"
1262 fi 1268 fi
1263} 1269}
1264 1270
1265# @FUNCTION: python_get_version 1271# @FUNCTION: python_get_version
1266# @USAGE: [-f|--final-ABI] [--major] [--minor] [--micro] 1272# @USAGE: [-f|--final-ABI] [--full] [--major] [--minor] [--micro]
1267# @DESCRIPTION: 1273# @DESCRIPTION:
1268# Print Python version. 1274# Print Python version.
1269# --major, --minor and --micro options cannot be specified simultaneously. 1275# --full, --major, --minor and --micro options cannot be specified simultaneously.
1270# If --major, --minor and --micro options are not specified, then "${major_version}.${minor_version}" is printed. 1276# If --full, --major, --minor and --micro options are not specified, then "${major_version}.${minor_version}" is printed.
1271# If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used. 1277# If --final-ABI option is specified, then final ABI from the list of enabled ABIs is used.
1272python_get_version() { 1278python_get_version() {
1273 local final_ABI="0" major="0" minor="0" micro="0" python_command 1279 local final_ABI="0" full="0" major="0" minor="0" micro="0" python_command
1274 1280
1275 while (($#)); do 1281 while (($#)); do
1276 case "$1" in 1282 case "$1" in
1277 -f|--final-ABI) 1283 -f|--final-ABI)
1278 final_ABI="1" 1284 final_ABI="1"
1279 ;; 1285 ;;
1286 --full)
1287 full="1"
1288 ;;
1280 --major) 1289 --major)
1281 major="1" 1290 major="1"
1282 ;; 1291 ;;
1283 --minor) 1292 --minor)
1284 minor="1" 1293 minor="1"
1294 ;; 1303 ;;
1295 esac 1304 esac
1296 shift 1305 shift
1297 done 1306 done
1298 1307
1299 if [[ "$((${major} + ${minor} + ${micro}))" -gt 1 ]]; then 1308 if [[ "$((${full} + ${major} + ${minor} + ${micro}))" -gt 1 ]]; then
1300 die "${FUNCNAME}(): '--major', '--minor' or '--micro' options cannot be specified simultaneously" 1309 die "${FUNCNAME}(): '--full', '--major', '--minor' or '--micro' options cannot be specified simultaneously"
1301 fi 1310 fi
1302 1311
1312 if [[ "${full}" == "1" ]]; then
1313 python_command="from sys import version_info; print('.'.join(str(x) for x in version_info[:3]))"
1303 if [[ "${major}" == "1" ]]; then 1314 elif [[ "${major}" == "1" ]]; then
1304 python_command="from sys import version_info; print(version_info[0])" 1315 python_command="from sys import version_info; print(version_info[0])"
1305 elif [[ "${minor}" == "1" ]]; then 1316 elif [[ "${minor}" == "1" ]]; then
1306 python_command="from sys import version_info; print(version_info[1])" 1317 python_command="from sys import version_info; print(version_info[1])"
1307 elif [[ "${micro}" == "1" ]]; then 1318 elif [[ "${micro}" == "1" ]]; then
1308 python_command="from sys import version_info; print(version_info[2])" 1319 python_command="from sys import version_info; print(version_info[2])"
1309 else 1320 else
1321 if [[ -n "${PYTHON_ABI}" && "${final_ABI}" == "0" ]]; then
1322 if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
1323 echo "${PYTHON_ABI}"
1324 elif [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
1325 echo "${PYTHON_ABI%-jython}"
1326 fi
1327 return
1328 fi
1310 python_command="from sys import version_info; print('.'.join(str(x) for x in version_info[:2]))" 1329 python_command="from sys import version_info; print('.'.join(str(x) for x in version_info[:2]))"
1311 fi 1330 fi
1312 1331
1313 if [[ "${final_ABI}" == "1" ]]; then 1332 if [[ "${final_ABI}" == "1" ]]; then
1314 "$(PYTHON -f)" -c "${python_command}" 1333 "$(PYTHON -f)" -c "${python_command}"
1487# @DESCRIPTION: 1506# @DESCRIPTION:
1488# User-configurable verbosity of tests of Python modules. 1507# User-configurable verbosity of tests of Python modules.
1489# Supported values: 0, 1, 2, 3, 4. 1508# Supported values: 0, 1, 2, 3, 4.
1490PYTHON_TEST_VERBOSITY="${PYTHON_TEST_VERBOSITY:-1}" 1509PYTHON_TEST_VERBOSITY="${PYTHON_TEST_VERBOSITY:-1}"
1491 1510
1511_python_test_hook() {
1512 if [[ "$#" -ne 1 ]]; then
1513 die "${FUNCNAME}() requires 1 argument"
1514 fi
1515
1516 if [[ -n "${SUPPORT_PYTHON_ABIS}" && "$(type -t "${FUNCNAME[3]}_$1_hook")" == "function" ]]; then
1517 "${FUNCNAME[3]}_$1_hook"
1518 fi
1519}
1520
1492# @FUNCTION: python_execute_nosetests 1521# @FUNCTION: python_execute_nosetests
1493# @USAGE: [-P|--PYTHONPATH PYTHONPATH] [-s|--separate-build-dirs] [--] [arguments] 1522# @USAGE: [-P|--PYTHONPATH PYTHONPATH] [-s|--separate-build-dirs] [--] [arguments]
1494# @DESCRIPTION: 1523# @DESCRIPTION:
1495# Execute nosetests for all enabled versions of Python. 1524# Execute nosetests for all enabled versions of Python.
1525# In ebuilds of packages supporting installation for multiple versions of Python, this function
1526# calls python_execute_nosetests_pre_hook() and python_execute_nosetests_post_hook(), if they are defined.
1496python_execute_nosetests() { 1527python_execute_nosetests() {
1497 _python_set_color_variables 1528 _python_set_color_variables
1498 1529
1499 local PYTHONPATH_template= separate_build_dirs= 1530 local PYTHONPATH_template= separate_build_dirs=
1500 1531
1529 if [[ ! -e "${evaluated_PYTHONPATH}" ]]; then 1560 if [[ ! -e "${evaluated_PYTHONPATH}" ]]; then
1530 unset evaluated_PYTHONPATH 1561 unset evaluated_PYTHONPATH
1531 fi 1562 fi
1532 fi 1563 fi
1533 1564
1565 _python_test_hook pre
1566
1534 if [[ -n "${evaluated_PYTHONPATH}" ]]; then 1567 if [[ -n "${evaluated_PYTHONPATH}" ]]; then
1535 echo ${_BOLD}PYTHONPATH="${evaluated_PYTHONPATH}" nosetests --verbosity="${PYTHON_TEST_VERBOSITY}" "$@"${_NORMAL} 1568 echo ${_BOLD}PYTHONPATH="${evaluated_PYTHONPATH}" nosetests --verbosity="${PYTHON_TEST_VERBOSITY}" "$@"${_NORMAL}
1536 PYTHONPATH="${evaluated_PYTHONPATH}" nosetests --verbosity="${PYTHON_TEST_VERBOSITY}" "$@" 1569 PYTHONPATH="${evaluated_PYTHONPATH}" nosetests --verbosity="${PYTHON_TEST_VERBOSITY}" "$@" || return "$?"
1537 else 1570 else
1538 echo ${_BOLD}nosetests --verbosity="${PYTHON_TEST_VERBOSITY}" "$@"${_NORMAL} 1571 echo ${_BOLD}nosetests --verbosity="${PYTHON_TEST_VERBOSITY}" "$@"${_NORMAL}
1539 nosetests --verbosity="${PYTHON_TEST_VERBOSITY}" "$@" 1572 nosetests --verbosity="${PYTHON_TEST_VERBOSITY}" "$@" || return "$?"
1540 fi 1573 fi
1574
1575 _python_test_hook post
1541 } 1576 }
1542 if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 1577 if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
1543 python_execute_function ${separate_build_dirs:+-s} python_test_function "$@" 1578 python_execute_function ${separate_build_dirs:+-s} python_test_function "$@"
1544 else 1579 else
1545 if [[ -n "${separate_build_dirs}" ]]; then 1580 if [[ -n "${separate_build_dirs}" ]]; then
1553 1588
1554# @FUNCTION: python_execute_py.test 1589# @FUNCTION: python_execute_py.test
1555# @USAGE: [-P|--PYTHONPATH PYTHONPATH] [-s|--separate-build-dirs] [--] [arguments] 1590# @USAGE: [-P|--PYTHONPATH PYTHONPATH] [-s|--separate-build-dirs] [--] [arguments]
1556# @DESCRIPTION: 1591# @DESCRIPTION:
1557# Execute py.test for all enabled versions of Python. 1592# Execute py.test for all enabled versions of Python.
1593# In ebuilds of packages supporting installation for multiple versions of Python, this function
1594# calls python_execute_py.test_pre_hook() and python_execute_py.test_post_hook(), if they are defined.
1558python_execute_py.test() { 1595python_execute_py.test() {
1559 _python_set_color_variables 1596 _python_set_color_variables
1560 1597
1561 local PYTHONPATH_template= separate_build_dirs= 1598 local PYTHONPATH_template= separate_build_dirs=
1562 1599
1591 if [[ ! -e "${evaluated_PYTHONPATH}" ]]; then 1628 if [[ ! -e "${evaluated_PYTHONPATH}" ]]; then
1592 unset evaluated_PYTHONPATH 1629 unset evaluated_PYTHONPATH
1593 fi 1630 fi
1594 fi 1631 fi
1595 1632
1633 _python_test_hook pre
1634
1596 if [[ -n "${evaluated_PYTHONPATH}" ]]; then 1635 if [[ -n "${evaluated_PYTHONPATH}" ]]; then
1597 echo ${_BOLD}PYTHONPATH="${evaluated_PYTHONPATH}" py.test $([[ "${PYTHON_TEST_VERBOSITY}" -ge 2 ]] && echo -v) "$@"${_NORMAL} 1636 echo ${_BOLD}PYTHONPATH="${evaluated_PYTHONPATH}" py.test $([[ "${PYTHON_TEST_VERBOSITY}" -ge 2 ]] && echo -v) "$@"${_NORMAL}
1598 PYTHONPATH="${evaluated_PYTHONPATH}" py.test $([[ "${PYTHON_TEST_VERBOSITY}" -ge 2 ]] && echo -v) "$@" 1637 PYTHONPATH="${evaluated_PYTHONPATH}" py.test $([[ "${PYTHON_TEST_VERBOSITY}" -ge 2 ]] && echo -v) "$@" || return "$?"
1599 else 1638 else
1600 echo ${_BOLD}py.test $([[ "${PYTHON_TEST_VERBOSITY}" -gt 1 ]] && echo -v) "$@"${_NORMAL} 1639 echo ${_BOLD}py.test $([[ "${PYTHON_TEST_VERBOSITY}" -gt 1 ]] && echo -v) "$@"${_NORMAL}
1601 py.test $([[ "${PYTHON_TEST_VERBOSITY}" -gt 1 ]] && echo -v) "$@" 1640 py.test $([[ "${PYTHON_TEST_VERBOSITY}" -gt 1 ]] && echo -v) "$@" || return "$?"
1602 fi 1641 fi
1642
1643 _python_test_hook post
1603 } 1644 }
1604 if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 1645 if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
1605 python_execute_function ${separate_build_dirs:+-s} python_test_function "$@" 1646 python_execute_function ${separate_build_dirs:+-s} python_test_function "$@"
1606 else 1647 else
1607 if [[ -n "${separate_build_dirs}" ]]; then 1648 if [[ -n "${separate_build_dirs}" ]]; then
1615 1656
1616# @FUNCTION: python_execute_trial 1657# @FUNCTION: python_execute_trial
1617# @USAGE: [-P|--PYTHONPATH PYTHONPATH] [-s|--separate-build-dirs] [--] [arguments] 1658# @USAGE: [-P|--PYTHONPATH PYTHONPATH] [-s|--separate-build-dirs] [--] [arguments]
1618# @DESCRIPTION: 1659# @DESCRIPTION:
1619# Execute trial for all enabled versions of Python. 1660# Execute trial for all enabled versions of Python.
1661# In ebuilds of packages supporting installation for multiple versions of Python, this function
1662# calls python_execute_trial_pre_hook() and python_execute_trial_post_hook(), if they are defined.
1620python_execute_trial() { 1663python_execute_trial() {
1621 _python_set_color_variables 1664 _python_set_color_variables
1622 1665
1623 local PYTHONPATH_template= separate_build_dirs= 1666 local PYTHONPATH_template= separate_build_dirs=
1624 1667
1653 if [[ ! -e "${evaluated_PYTHONPATH}" ]]; then 1696 if [[ ! -e "${evaluated_PYTHONPATH}" ]]; then
1654 unset evaluated_PYTHONPATH 1697 unset evaluated_PYTHONPATH
1655 fi 1698 fi
1656 fi 1699 fi
1657 1700
1701 _python_test_hook pre
1702
1658 if [[ -n "${evaluated_PYTHONPATH}" ]]; then 1703 if [[ -n "${evaluated_PYTHONPATH}" ]]; then
1659 echo ${_BOLD}PYTHONPATH="${evaluated_PYTHONPATH}" trial $([[ "${PYTHON_TEST_VERBOSITY}" -ge 4 ]] && echo --spew) "$@"${_NORMAL} 1704 echo ${_BOLD}PYTHONPATH="${evaluated_PYTHONPATH}" trial $([[ "${PYTHON_TEST_VERBOSITY}" -ge 4 ]] && echo --spew) "$@"${_NORMAL}
1660 PYTHONPATH="${evaluated_PYTHONPATH}" trial $([[ "${PYTHON_TEST_VERBOSITY}" -ge 4 ]] && echo --spew) "$@" 1705 PYTHONPATH="${evaluated_PYTHONPATH}" trial $([[ "${PYTHON_TEST_VERBOSITY}" -ge 4 ]] && echo --spew) "$@" || return "$?"
1661 else 1706 else
1662 echo ${_BOLD}trial $([[ "${PYTHON_TEST_VERBOSITY}" -ge 4 ]] && echo --spew) "$@"${_NORMAL} 1707 echo ${_BOLD}trial $([[ "${PYTHON_TEST_VERBOSITY}" -ge 4 ]] && echo --spew) "$@"${_NORMAL}
1663 trial $([[ "${PYTHON_TEST_VERBOSITY}" -ge 4 ]] && echo --spew) "$@" 1708 trial $([[ "${PYTHON_TEST_VERBOSITY}" -ge 4 ]] && echo --spew) "$@" || return "$?"
1664 fi 1709 fi
1710
1711 _python_test_hook post
1665 } 1712 }
1666 if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 1713 if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
1667 python_execute_function ${separate_build_dirs:+-s} python_test_function "$@" 1714 python_execute_function ${separate_build_dirs:+-s} python_test_function "$@"
1668 else 1715 else
1669 if [[ -n "${separate_build_dirs}" ]]; then 1716 if [[ -n "${separate_build_dirs}" ]]; then
1702# If no arguments supplied, it will recompile not recursively all modules 1749# If no arguments supplied, it will recompile not recursively all modules
1703# under sys.path (eg. /usr/lib/python2.6, /usr/lib/python2.6/site-packages). 1750# under sys.path (eg. /usr/lib/python2.6, /usr/lib/python2.6/site-packages).
1704# 1751#
1705# If supplied with arguments, it will recompile all modules recursively 1752# If supplied with arguments, it will recompile all modules recursively
1706# in the supplied directory. 1753# in the supplied directory.
1707# This function should only be run in pkg_postinst().
1708# 1754#
1709# Options passed to this function are passed to compileall.py. 1755# Options passed to this function are passed to compileall.py.
1710# 1756#
1711# Example: 1757# This function can be used only in pkg_postinst() phase.
1712# python_mod_optimize ctypesgencore
1713python_mod_optimize() { 1758python_mod_optimize() {
1714 _python_initialize_prefix_variables 1759 _python_initialize_prefix_variables
1715 1760
1716 # Check if phase is pkg_postinst(). 1761 # Check if phase is pkg_postinst().
1717 [[ ${EBUILD_PHASE} != "postinst" ]] && die "${FUNCNAME}() should only be run in pkg_postinst()" 1762 [[ ${EBUILD_PHASE} != "postinst" ]] && die "${FUNCNAME}() can be used only in pkg_postinst() phase"
1718 1763
1719 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 1764 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
1720 local dir file options=() other_dirs=() other_files=() previous_PYTHON_ABI="${PYTHON_ABI}" PYTHON_ABI="${PYTHON_ABI}" return_code root site_packages_absolute_dirs=() site_packages_dirs=() site_packages_absolute_files=() site_packages_files=() 1765 local dir file options=() other_dirs=() other_files=() previous_PYTHON_ABI="${PYTHON_ABI}" PYTHON_ABI="${PYTHON_ABI}" return_code root site_packages_absolute_dirs=() site_packages_dirs=() site_packages_absolute_files=() site_packages_files=()
1721 1766
1722 # Strip trailing slash from ROOT. 1767 # Strip trailing slash from ROOT.
1882# 1927#
1883# It will recursively scan all compiled Python modules in the directories and 1928# It will recursively scan all compiled Python modules in the directories and
1884# determine if they are orphaned (i.e. their corresponding .py files are missing.) 1929# determine if they are orphaned (i.e. their corresponding .py files are missing.)
1885# If they are, then it will remove their corresponding .pyc and .pyo files. 1930# If they are, then it will remove their corresponding .pyc and .pyo files.
1886# 1931#
1887# This function should only be run in pkg_postrm(). 1932# This function can be used only in pkg_postrm() phase.
1888python_mod_cleanup() { 1933python_mod_cleanup() {
1889 _python_initialize_prefix_variables 1934 _python_initialize_prefix_variables
1890 _python_set_color_variables 1935 _python_set_color_variables
1891 1936
1892 local path py_file PYTHON_ABI="${PYTHON_ABI}" SEARCH_PATH=() root 1937 local path py_file PYTHON_ABI="${PYTHON_ABI}" SEARCH_PATH=() root
1893 1938
1894 # Check if phase is pkg_postrm(). 1939 # Check if phase is pkg_postrm().
1895 [[ ${EBUILD_PHASE} != "postrm" ]] && die "${FUNCNAME}() should only be run in pkg_postrm()" 1940 [[ ${EBUILD_PHASE} != "postrm" ]] && die "${FUNCNAME}() can be used only in pkg_postrm() phase"
1896 1941
1897 # Strip trailing slash from ROOT. 1942 # Strip trailing slash from ROOT.
1898 root="${EROOT%/}" 1943 root="${EROOT%/}"
1899 1944
1900 if (($#)); then 1945 if (($#)); then
1978 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 2023 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
1979 eerror "Use PYTHON() and/or python_get_*() instead of ${FUNCNAME}()." 2024 eerror "Use PYTHON() and/or python_get_*() instead of ${FUNCNAME}()."
1980 die "${FUNCNAME}() cannot be used in this EAPI" 2025 die "${FUNCNAME}() cannot be used in this EAPI"
1981 fi 2026 fi
1982 2027
2028 if [[ "${FUNCNAME[1]}" != "distutils_python_version" ]]; then
2029 einfo
2030 einfo "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01."
2031 einfo "Use PYTHON() instead of python variable. Use python_get_*() instead of PYVER* variables."
2032 einfo
2033 fi
2034
1983 [[ -n "${PYVER}" ]] && return 0 2035 [[ -n "${PYVER}" ]] && return 0
1984 local tmpstr 2036 local tmpstr
1985 python="${python:-${EPREFIX}/usr/bin/python}" 2037 python="${python:-${EPREFIX}/usr/bin/python}"
1986 tmpstr="$(EPYTHON= ${python} -V 2>&1 )" 2038 tmpstr="$(EPYTHON= ${python} -V 2>&1 )"
1987 export PYVER_ALL="${tmpstr#Python }" 2039 export PYVER_ALL="${tmpstr#Python }"
2009 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 2061 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
2010 eerror "Use USE dependencies and/or has_version() instead of ${FUNCNAME}()." 2062 eerror "Use USE dependencies and/or has_version() instead of ${FUNCNAME}()."
2011 die "${FUNCNAME}() cannot be used in this EAPI" 2063 die "${FUNCNAME}() cannot be used in this EAPI"
2012 fi 2064 fi
2013 2065
2066 einfo
2067 einfo "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01."
2068 einfo "Use USE dependencies and/or has_version() instead of ${FUNCNAME}()."
2069 einfo
2070
2014 if [[ "$#" -ne 1 ]]; then 2071 if [[ "$#" -ne 1 ]]; then
2015 die "${FUNCNAME}() requires 1 argument" 2072 die "${FUNCNAME}() requires 1 argument"
2016 fi 2073 fi
2017 "$(PYTHON ${PYTHON_ABI})" -c "import $1" &> /dev/null 2074 "$(PYTHON ${PYTHON_ABI})" -c "import $1" &> /dev/null
2018} 2075}
2023# support. If not, prints an error message and dies. 2080# support. If not, prints an error message and dies.
2024python_tkinter_exists() { 2081python_tkinter_exists() {
2025 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 2082 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
2026 eerror "Use PYTHON_USE_WITH=\"xml\" and python_pkg_setup() instead of ${FUNCNAME}()." 2083 eerror "Use PYTHON_USE_WITH=\"xml\" and python_pkg_setup() instead of ${FUNCNAME}()."
2027 die "${FUNCNAME}() cannot be used in this EAPI" 2084 die "${FUNCNAME}() cannot be used in this EAPI"
2085 fi
2086
2087 if [[ "${FUNCNAME[1]}" != "distutils_python_tkinter" ]]; then
2088 einfo
2089 einfo "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01."
2090 einfo "Use PYTHON_USE_WITH=\"xml\" and python_pkg_setup() instead of ${FUNCNAME}()."
2091 einfo
2028 fi 2092 fi
2029 2093
2030 if ! "$(PYTHON ${PYTHON_ABI})" -c "from sys import version_info 2094 if ! "$(PYTHON ${PYTHON_ABI})" -c "from sys import version_info
2031if version_info[0] == 3: 2095if version_info[0] == 3:
2032 import tkinter 2096 import tkinter
2041 2105
2042# @FUNCTION: python_mod_compile 2106# @FUNCTION: python_mod_compile
2043# @USAGE: <file> [more files ...] 2107# @USAGE: <file> [more files ...]
2044# @DESCRIPTION: 2108# @DESCRIPTION:
2045# Given filenames, it will pre-compile the module's .pyc and .pyo. 2109# Given filenames, it will pre-compile the module's .pyc and .pyo.
2046# This function should only be run in pkg_postinst() 2110# This function can be used only in pkg_postinst() phase.
2047# 2111#
2048# Example: 2112# Example:
2049# python_mod_compile /usr/lib/python2.3/site-packages/pygoogle.py 2113# python_mod_compile /usr/lib/python2.3/site-packages/pygoogle.py
2050# 2114#
2051python_mod_compile() { 2115python_mod_compile() {
2057 _python_initialize_prefix_variables 2121 _python_initialize_prefix_variables
2058 2122
2059 local f myroot myfiles=() 2123 local f myroot myfiles=()
2060 2124
2061 # Check if phase is pkg_postinst() 2125 # Check if phase is pkg_postinst()
2062 [[ ${EBUILD_PHASE} != postinst ]] && die "${FUNCNAME}() should only be run in pkg_postinst()" 2126 [[ ${EBUILD_PHASE} != postinst ]] && die "${FUNCNAME}() can be used only in pkg_postinst() phase"
2063 2127
2064 # strip trailing slash 2128 # strip trailing slash
2065 myroot="${EROOT%/}" 2129 myroot="${EROOT%/}"
2066 2130
2067 # respect ROOT 2131 # respect ROOT

Legend:
Removed from v.1.91  
changed lines
  Added in v.1.93

  ViewVC Help
Powered by ViewVC 1.1.20