# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/distutils.eclass,v 1.72 2010/02/08 09:35:38 pva Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/distutils.eclass,v 1.73 2010/02/28 11:52:22 arfrever Exp $
# @ECLASS: distutils.eclass
# @MAINTAINER:
# Original author: Jon Nelson <jnelson@gentoo.org>
# @BLURB: Eclass for packages with build systems using Distutils
# @DESCRIPTION:
-# The distutils eclass defines phase functions for packages with build systems using Distutils
+# The distutils eclass defines phase functions for packages with build systems using Distutils.
inherit multilib python
EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_postinst pkg_postrm
;;
*)
- EXPORT_FUNCTIONS src_unpack src_prepare src_compile src_install pkg_postinst pkg_postrm
+ EXPORT_FUNCTIONS src_prepare src_compile src_install pkg_postinst pkg_postrm
;;
esac
if [[ -z "${PYTHON_DEPEND}" ]]; then
- DEPEND="virtual/python"
+ DEPEND="dev-lang/python"
RDEPEND="${DEPEND}"
fi
-if has "${EAPI:-0}" 0 1 2; then
+if has "${EAPI:-0}" 0 1 2 && [[ -z "${SUPPORT_PYTHON_ABIS}" ]]; then
python="python"
else
- # Use "$(PYTHON)" or "$(PYTHON -A)" instead of "${python}".
+ # Use "$(PYTHON)" instead of "${python}".
python="die"
fi
# Set this to disable renaming of Python scripts containing versioned shebangs
# and generation of wrapper scripts.
+# @ECLASS-VARIABLE: DISTUTILS_NONVERSIONED_PYTHON_SCRIPTS
+# @DESCRIPTION:
+# List of paths to Python scripts, relative to ${D}, which are excluded from
+# renaming and generation of wrapper scripts.
+
# @ECLASS-VARIABLE: DOCS
# @DESCRIPTION:
# Additional documentation files installed by distutils_src_install().
# @DESCRIPTION:
# The distutils src_unpack function. This function is exported.
distutils_src_unpack() {
+ if ! has "${EAPI:-0}" 0 1; then
+ die "${FUNCNAME}() cannot be used in this EAPI"
+ fi
+
if [[ "${EBUILD_PHASE}" != "unpack" ]]; then
die "${FUNCNAME}() can be used only in src_unpack() phase"
fi
unpack ${A}
cd "${S}"
- has "${EAPI:-0}" 0 1 && distutils_src_prepare
+ distutils_src_prepare
}
# @FUNCTION: distutils_src_prepare
die "${FUNCNAME}() can be used only in src_compile() phase"
fi
+ _python_set_color_variables
+
if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
distutils_building() {
_distutils_hook pre
- echo "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build -b "$(_distutils_get_build_dir)" "$@"
+ echo ${_BOLD}"$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build -b "$(_distutils_get_build_dir)" "$@"${_NORMAL}
"$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build -b "$(_distutils_get_build_dir)" "$@" || return "$?"
_distutils_hook post
}
python_execute_function ${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES:+-s} distutils_building "$@"
else
- echo "$(PYTHON -A)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build "$@"
- "$(PYTHON -A)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build "$@" || die "Building failed"
+ echo ${_BOLD}"$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build "$@"${_NORMAL}
+ "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build "$@" || die "Building failed"
fi
}
# @DESCRIPTION:
# The distutils src_test function. This function is exported, when DISTUTILS_SRC_TEST variable is set.
distutils_src_test() {
+ _python_set_color_variables
+
if [[ "${DISTUTILS_SRC_TEST}" == "setup.py" ]]; then
if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
distutils_testing() {
- echo PYTHONPATH="$(_distutils_get_PYTHONPATH)" "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" $([[ -z "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]] && echo build -b "$(_distutils_get_build_dir)") test "$@"
+ echo ${_BOLD}PYTHONPATH="$(_distutils_get_PYTHONPATH)" "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" $([[ -z "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]] && echo build -b "$(_distutils_get_build_dir)") test "$@"${_NORMAL}
PYTHONPATH="$(_distutils_get_PYTHONPATH)" "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" $([[ -z "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]] && echo build -b "$(_distutils_get_build_dir)") test "$@"
}
python_execute_function ${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES:+-s} distutils_testing "$@"
else
- echo PYTHONPATH="$(_distutils_get_PYTHONPATH)" "$(PYTHON -A)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" test "$@" || die "Testing failed"
- PYTHONPATH="$(_distutils_get_PYTHONPATH)" "$(PYTHON -A)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" test "$@" || die "Testing failed"
+ echo ${_BOLD}PYTHONPATH="$(_distutils_get_PYTHONPATH)" "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" test "$@"${_NORMAL}
+ PYTHONPATH="$(_distutils_get_PYTHONPATH)" "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" test "$@" || die "Testing failed"
fi
elif [[ "${DISTUTILS_SRC_TEST}" == "nosetests" ]]; then
python_execute_nosetests -P '$(_distutils_get_PYTHONPATH)' ${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES:+-s} -- "$@"
die "${FUNCNAME}() can be used only in src_install() phase"
fi
+ _python_set_color_variables
+
if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
if [[ -z "${DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS}" && "${BASH_VERSINFO[0]}" -ge 4 ]]; then
declare -A wrapper_scripts=()
if [[ -d "${D}usr/bin" ]]; then
cd "${D}usr/bin"
- local file
+ local nonversioned_file file
for file in *; do
- if [[ -f "${file}" && ! "${file}" =~ [[:digit:]]+\.[[:digit:]]+$ && "$(head -n1 "${file}")" =~ ^'#!'.*python[[:digit:]]+\.[[:digit:]]+ ]]; then
+ if [[ -f "${file}" && ! "${file}" =~ [[:digit:]]+\.[[:digit:]](-jython)?+$ && "$(head -n1 "${file}")" =~ ^'#!'.*(python|jython-)[[:digit:]]+\.[[:digit:]]+ ]]; then
+ for nonversioned_file in "${DISTUTILS_NONVERSIONED_PYTHON_SCRIPTS[@]}"; do
+ [[ "${nonversioned_file}" == "/usr/bin/${file}" ]] && continue 2
+ done
mv "${file}" "${file}-${PYTHON_ABI}" || die "Renaming of '${file}' failed"
wrapper_scripts+=(["${D}usr/bin/${file}"]=)
fi
distutils_installation() {
_distutils_hook pre
- echo "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" $([[ -z "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]] && echo build -b "$(_distutils_get_build_dir)") install --root="${D}" --no-compile "$@"
+ echo ${_BOLD}"$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" $([[ -z "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]] && echo build -b "$(_distutils_get_build_dir)") install --root="${D}" --no-compile "$@"${_NORMAL}
"$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" $([[ -z "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]] && echo build -b "$(_distutils_get_build_dir)") install --root="${D}" --no-compile "$@" || return "$?"
if [[ -z "${DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS}" && "${BASH_VERSINFO[0]}" -ge 4 ]]; then
# Mark the package to be rebuilt after a Python upgrade.
python_need_rebuild
- echo "$(PYTHON -A)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@"
- "$(PYTHON -A)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@" || die "Installation failed"
+ echo ${_BOLD}"$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@"${_NORMAL}
+ "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@" || die "Installation failed"
fi
if [[ -e "${D}usr/local" ]]; then
local pylibdir pymod
if [[ -z "${PYTHON_MODNAME}" ]]; then
- for pylibdir in "${ROOT}"/usr/$(get_libdir)/python*; do
+ for pylibdir in "${ROOT}"usr/$(get_libdir)/python* "${ROOT}"/usr/share/jython-*/Lib; do
if [[ -d "${pylibdir}/site-packages/${PN}" ]]; then
PYTHON_MODNAME="${PN}"
fi
local pylibdir pymod
if [[ -z "${PYTHON_MODNAME}" ]]; then
- for pylibdir in "${ROOT}"/usr/$(get_libdir)/python*; do
+ for pylibdir in "${ROOT}"usr/$(get_libdir)/python* "${ROOT}"/usr/share/jython-*/Lib; do
if [[ -d "${pylibdir}/site-packages/${PN}" ]]; then
PYTHON_MODNAME="${PN}"
fi
python_mod_cleanup ${PYTHON_MODNAME}
else
for pymod in ${PYTHON_MODNAME}; do
- for pylibdir in "${ROOT}"/usr/$(get_libdir)/python*; do
+ for pylibdir in "${ROOT}"usr/$(get_libdir)/python*; do
if [[ -d "${pylibdir}/site-packages/${pymod}" ]]; then
- python_mod_cleanup "${pylibdir#${ROOT}}/site-packages/${pymod}"
+ python_mod_cleanup "${pylibdir#${ROOT%/}}/site-packages/${pymod}"
fi
done
done
# @DESCRIPTION:
# Deprecated wrapper function for deprecated python_version().
distutils_python_version() {
- if ! has "${EAPI:-0}" 0 1 2; then
+ if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
eerror "Use PYTHON() and/or python_get_*() instead of ${FUNCNAME}()."
die "${FUNCNAME}() cannot be used in this EAPI"
fi
# @FUNCTION: distutils_python_tkinter
# @DESCRIPTION:
-# Deprecated wrapper function for python_tkinter_exists().
+# Deprecated wrapper function for deprecated python_tkinter_exists().
distutils_python_tkinter() {
- if ! has "${EAPI:-0}" 0 1 2; then
- eerror "Use python_tkinter_exists() instead of ${FUNCNAME}()."
+ if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
+ eerror "Use PYTHON_USE_WITH=\"xml\" and python_pkg_setup() instead of ${FUNCNAME}()."
die "${FUNCNAME}() cannot be used in this EAPI"
fi