| 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/distutils.eclass,v 1.78 2010/12/13 13:36:33 arfrever Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/distutils.eclass,v 1.79 2010/12/24 15:05:24 arfrever Exp $ |
| 4 | |
4 | |
| 5 | # @ECLASS: distutils.eclass |
5 | # @ECLASS: distutils.eclass |
| 6 | # @MAINTAINER: |
6 | # @MAINTAINER: |
| 7 | # Gentoo Python Project <python@gentoo.org> |
7 | # Gentoo Python Project <python@gentoo.org> |
| 8 | # |
8 | # |
| … | |
… | |
| 23 | esac |
23 | esac |
| 24 | |
24 | |
| 25 | if [[ -z "$(declare -p PYTHON_DEPEND 2> /dev/null)" ]]; then |
25 | if [[ -z "$(declare -p PYTHON_DEPEND 2> /dev/null)" ]]; then |
| 26 | DEPEND="dev-lang/python" |
26 | DEPEND="dev-lang/python" |
| 27 | RDEPEND="${DEPEND}" |
27 | RDEPEND="${DEPEND}" |
|
|
28 | fi |
|
|
29 | |
|
|
30 | if [[ -n "${PYTHON_DEPRECATION_WARNINGS}" ]]; then |
|
|
31 | if has "${EAPI:-0}" 0 1 && [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then |
|
|
32 | ewarn |
|
|
33 | ewarn "\"${EBUILD}\":" |
|
|
34 | ewarn "Deprecation Warning: Usage of distutils.eclass in packages supporting installation" |
|
|
35 | ewarn "for multiple Python ABIs in EAPI <=1 is deprecated and will be banned on 2011-06-01." |
|
|
36 | ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." |
|
|
37 | ewarn |
|
|
38 | elif has "${EAPI:-0}" 0 1 2 && [[ -z "${SUPPORT_PYTHON_ABIS}" ]]; then |
|
|
39 | ewarn |
|
|
40 | ewarn "\"${EBUILD}\":" |
|
|
41 | ewarn "Deprecation Warning: Usage of distutils.eclass in packages not supporting installation" |
|
|
42 | ewarn "for multiple Python ABIs in EAPI <=2 is deprecated and will be banned on 2011-06-01." |
|
|
43 | ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." |
|
|
44 | ewarn |
|
|
45 | fi |
| 28 | fi |
46 | fi |
| 29 | |
47 | |
| 30 | # 'python' variable is deprecated. Use PYTHON() instead. |
48 | # 'python' variable is deprecated. Use PYTHON() instead. |
| 31 | if has "${EAPI:-0}" 0 1 2 && [[ -z "${SUPPORT_PYTHON_ABIS}" ]]; then |
49 | if has "${EAPI:-0}" 0 1 2 && [[ -z "${SUPPORT_PYTHON_ABIS}" ]]; then |
| 32 | python="python" |
50 | python="python" |
| … | |
… | |
| 84 | |
102 | |
| 85 | # @ECLASS-VARIABLE: DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS |
103 | # @ECLASS-VARIABLE: DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS |
| 86 | # @DESCRIPTION: |
104 | # @DESCRIPTION: |
| 87 | # Set this to disable renaming of Python scripts containing versioned shebangs |
105 | # Set this to disable renaming of Python scripts containing versioned shebangs |
| 88 | # and generation of wrapper scripts. |
106 | # and generation of wrapper scripts. |
|
|
107 | if [[ -n "${DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS}" ]]; then |
|
|
108 | ewarn |
|
|
109 | ewarn "\"${EBUILD}\":" |
|
|
110 | ewarn "Deprecation Warning: DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS is deprecated" |
|
|
111 | ewarn "and will be banned on 2011-02-01. Use PYTHON_NONVERSIONED_EXECUTABLES=(\".*\")." |
|
|
112 | ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." |
|
|
113 | ewarn |
| 89 | |
114 | |
| 90 | # @ECLASS-VARIABLE: DISTUTILS_NONVERSIONED_PYTHON_SCRIPTS |
115 | PYTHON_NONVERSIONED_EXECUTABLES=(".*") |
| 91 | # @DESCRIPTION: |
116 | fi |
| 92 | # List of paths to Python scripts, relative to ${ED}, which are excluded from |
|
|
| 93 | # renaming and generation of wrapper scripts. |
|
|
| 94 | |
117 | |
| 95 | # @ECLASS-VARIABLE: DOCS |
118 | # @ECLASS-VARIABLE: DOCS |
| 96 | # @DESCRIPTION: |
119 | # @DESCRIPTION: |
| 97 | # Additional documentation files installed by distutils_src_install(). |
120 | # Additional documentation files installed by distutils_src_install(). |
| 98 | |
121 | |
| … | |
… | |
| 296 | |
319 | |
| 297 | _python_initialize_prefix_variables |
320 | _python_initialize_prefix_variables |
| 298 | _python_set_color_variables |
321 | _python_set_color_variables |
| 299 | |
322 | |
| 300 | if _python_package_supporting_installation_for_multiple_python_abis; then |
323 | if _python_package_supporting_installation_for_multiple_python_abis; then |
| 301 | if [[ -z "${DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS}" && "${BASH_VERSINFO[0]}" -ge 4 ]]; then |
|
|
| 302 | declare -A wrapper_scripts=() |
|
|
| 303 | |
|
|
| 304 | rename_scripts_with_versioned_shebangs() { |
|
|
| 305 | if [[ -d "${ED}usr/bin" ]]; then |
|
|
| 306 | cd "${ED}usr/bin" |
|
|
| 307 | |
|
|
| 308 | local nonversioned_file file |
|
|
| 309 | for file in *; do |
|
|
| 310 | if [[ -f "${file}" && ! "${file}" =~ [[:digit:]]+\.[[:digit:]]+(-jython)?$ && "$(head -n1 "${file}")" =~ ^'#!'.*(python|jython-)[[:digit:]]+\.[[:digit:]]+ ]]; then |
|
|
| 311 | for nonversioned_file in "${DISTUTILS_NONVERSIONED_PYTHON_SCRIPTS[@]}"; do |
|
|
| 312 | [[ "${nonversioned_file}" == "/usr/bin/${file}" ]] && continue 2 |
|
|
| 313 | done |
|
|
| 314 | mv "${file}" "${file}-${PYTHON_ABI}" || die "Renaming of '${file}' failed" |
|
|
| 315 | wrapper_scripts+=(["${ED}usr/bin/${file}"]=) |
|
|
| 316 | fi |
|
|
| 317 | done |
|
|
| 318 | fi |
|
|
| 319 | } |
|
|
| 320 | fi |
|
|
| 321 | |
|
|
| 322 | distutils_installation() { |
324 | distutils_installation() { |
| 323 | _distutils_hook pre |
325 | _distutils_hook pre |
| 324 | |
326 | |
| 325 | local setup_file |
327 | local setup_file |
| 326 | for setup_file in "${DISTUTILS_SETUP_FILES[@]-setup.py}"; do |
328 | for setup_file in "${DISTUTILS_SETUP_FILES[@]-setup.py}"; do |
| 327 | echo ${_BOLD}"$(PYTHON)" "${setup_file}" "${DISTUTILS_GLOBAL_OPTIONS[@]}" $([[ -z "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]] && echo build -b "$(_distutils_get_build_dir)") install --root="${D}" --no-compile "$@"${_NORMAL} |
329 | echo ${_BOLD}"$(PYTHON)" "${setup_file}" "${DISTUTILS_GLOBAL_OPTIONS[@]}" $([[ -z "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]] && echo build -b "$(_distutils_get_build_dir)") install --no-compile --root="${T}/images/${PYTHON_ABI}" "$@"${_NORMAL} |
| 328 | "$(PYTHON)" "${setup_file}" "${DISTUTILS_GLOBAL_OPTIONS[@]}" $([[ -z "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]] && echo build -b "$(_distutils_get_build_dir)") install --root="${D}" --no-compile "$@" || return "$?" |
330 | "$(PYTHON)" "${setup_file}" "${DISTUTILS_GLOBAL_OPTIONS[@]}" $([[ -z "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]] && echo build -b "$(_distutils_get_build_dir)") install --no-compile --root="${T}/images/${PYTHON_ABI}" "$@" || return "$?" |
| 329 | done |
331 | done |
| 330 | |
|
|
| 331 | if [[ -z "${DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS}" && "${BASH_VERSINFO[0]}" -ge 4 ]]; then |
|
|
| 332 | rename_scripts_with_versioned_shebangs |
|
|
| 333 | fi |
|
|
| 334 | |
332 | |
| 335 | _distutils_hook post |
333 | _distutils_hook post |
| 336 | } |
334 | } |
| 337 | python_execute_function ${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES:+-s} distutils_installation "$@" |
335 | python_execute_function ${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES:+-s} distutils_installation "$@" |
| 338 | |
336 | |
| 339 | if [[ -z "${DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS}" && "${#wrapper_scripts[@]}" -ne 0 && "${BASH_VERSINFO[0]}" -ge 4 ]]; then |
337 | python_merge_intermediate_installation_images "${T}/images" |
| 340 | python_generate_wrapper_scripts "${!wrapper_scripts[@]}" |
|
|
| 341 | fi |
|
|
| 342 | unset wrapper_scripts |
|
|
| 343 | else |
338 | else |
| 344 | # Mark the package to be rebuilt after a Python upgrade. |
339 | # Mark the package to be rebuilt after a Python upgrade. |
| 345 | python_need_rebuild |
340 | python_need_rebuild |
| 346 | |
341 | |
| 347 | local setup_file |
342 | local setup_file |