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

Diff of /eclass/distutils.eclass

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

Revision 1.76 Revision 1.79
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.76 2010/07/17 23:03:29 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#
25if [[ -z "$(declare -p PYTHON_DEPEND 2> /dev/null)" ]]; then 25if [[ -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}"
28fi 28fi
29 29
30if [[ -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
46fi
47
30# 'python' variable is deprecated. Use PYTHON() instead. 48# 'python' variable is deprecated. Use PYTHON() instead.
31if has "${EAPI:-0}" 0 1 2 && [[ -z "${SUPPORT_PYTHON_ABIS}" ]]; then 49if has "${EAPI:-0}" 0 1 2 && [[ -z "${SUPPORT_PYTHON_ABIS}" ]]; then
32 python="python" 50 python="python"
33else 51else
34 python="die" 52 python="die"
68 if [[ "${DISTUTILS_SRC_TEST}" == "nosetests" ]]; then 86 if [[ "${DISTUTILS_SRC_TEST}" == "nosetests" ]]; then
69 IUSE="test" 87 IUSE="test"
70 DEPEND+="${DEPEND:+ }test? ( dev-python/nose )" 88 DEPEND+="${DEPEND:+ }test? ( dev-python/nose )"
71 elif [[ "${DISTUTILS_SRC_TEST}" == "py.test" ]]; then 89 elif [[ "${DISTUTILS_SRC_TEST}" == "py.test" ]]; then
72 IUSE="test" 90 IUSE="test"
73 DEPEND+="${DEPEND:+ }test? ( dev-python/py )" 91 DEPEND+="${DEPEND:+ }test? ( dev-python/pytest )"
74 # trial requires an argument, which is usually equal to "${PN}". 92 # trial requires an argument, which is usually equal to "${PN}".
75 elif [[ "${DISTUTILS_SRC_TEST}" =~ ^trial(\ .*)?$ ]]; then 93 elif [[ "${DISTUTILS_SRC_TEST}" =~ ^trial(\ .*)?$ ]]; then
76 IUSE="test" 94 IUSE="test"
77 DEPEND+="${DEPEND:+ }test? ( dev-python/twisted )" 95 DEPEND+="${DEPEND:+ }test? ( dev-python/twisted )"
78 fi 96 fi
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.
107if [[ -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: 116fi
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
99_distutils_get_build_dir() { 122_distutils_get_build_dir() {
100 if [[ -n "${SUPPORT_PYTHON_ABIS}" && -z "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]]; then 123 if _python_package_supporting_installation_for_multiple_python_abis && [[ -z "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]]; then
101 echo "build-${PYTHON_ABI}" 124 echo "build-${PYTHON_ABI}"
102 else 125 else
103 echo "build" 126 echo "build"
104 fi 127 fi
105} 128}
106 129
107_distutils_get_PYTHONPATH() { 130_distutils_get_PYTHONPATH() {
108 if [[ -n "${SUPPORT_PYTHON_ABIS}" && -z "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]]; then 131 if _python_package_supporting_installation_for_multiple_python_abis && [[ -z "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]]; then
109 ls -d build-${PYTHON_ABI}/lib* 2> /dev/null 132 ls -d build-${PYTHON_ABI}/lib* 2> /dev/null
110 else 133 else
111 ls -d build/lib* 2> /dev/null 134 ls -d build/lib* 2> /dev/null
112 fi 135 fi
113} 136}
178 die "${FUNCNAME}() can be used only in src_compile() phase" 201 die "${FUNCNAME}() can be used only in src_compile() phase"
179 fi 202 fi
180 203
181 _python_set_color_variables 204 _python_set_color_variables
182 205
183 if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 206 if _python_package_supporting_installation_for_multiple_python_abis; then
184 distutils_building() { 207 distutils_building() {
185 _distutils_hook pre 208 _distutils_hook pre
186 209
187 local setup_file 210 local setup_file
188 for setup_file in "${DISTUTILS_SETUP_FILES[@]-setup.py}"; do 211 for setup_file in "${DISTUTILS_SETUP_FILES[@]-setup.py}"; do
205_distutils_src_test_hook() { 228_distutils_src_test_hook() {
206 if [[ "$#" -ne 1 ]]; then 229 if [[ "$#" -ne 1 ]]; then
207 die "${FUNCNAME}() requires 1 arguments" 230 die "${FUNCNAME}() requires 1 arguments"
208 fi 231 fi
209 232
210 if [[ -z "${SUPPORT_PYTHON_ABIS}" ]]; then 233 if ! _python_package_supporting_installation_for_multiple_python_abis; then
211 return 234 return
212 fi 235 fi
213 236
214 if [[ "$(type -t "distutils_src_test_pre_hook")" == "function" ]]; then 237 if [[ "$(type -t "distutils_src_test_pre_hook")" == "function" ]]; then
215 eval "python_execute_$1_pre_hook() { 238 eval "python_execute_$1_pre_hook() {
235 fi 258 fi
236 259
237 _python_set_color_variables 260 _python_set_color_variables
238 261
239 if [[ "${DISTUTILS_SRC_TEST}" == "setup.py" ]]; then 262 if [[ "${DISTUTILS_SRC_TEST}" == "setup.py" ]]; then
240 if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 263 if _python_package_supporting_installation_for_multiple_python_abis; then
241 distutils_testing() { 264 distutils_testing() {
242 _distutils_hook pre 265 _distutils_hook pre
243 266
244 local setup_file 267 local setup_file
245 for setup_file in "${DISTUTILS_SETUP_FILES[@]-setup.py}"; do 268 for setup_file in "${DISTUTILS_SETUP_FILES[@]-setup.py}"; do
295 fi 318 fi
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 [[ -n "${SUPPORT_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
381 376
382 _python_initialize_prefix_variables 377 _python_initialize_prefix_variables
383 378
384 local pylibdir pymod 379 local pylibdir pymod
385 if [[ -z "$(declare -p PYTHON_MODNAME 2> /dev/null)" ]]; then 380 if [[ -z "$(declare -p PYTHON_MODNAME 2> /dev/null)" ]]; then
386 for pylibdir in "${EROOT}"usr/$(get_libdir)/python* "${EROOT}"/usr/share/jython-*/Lib; do 381 for pylibdir in "${EROOT}"usr/$(get_libdir)/python* "${EROOT}"usr/share/jython-*/Lib; do
387 if [[ -d "${pylibdir}/site-packages/${PN}" ]]; then 382 if [[ -d "${pylibdir}/site-packages/${PN}" ]]; then
388 PYTHON_MODNAME="${PN}" 383 PYTHON_MODNAME="${PN}"
389 fi 384 fi
390 done 385 done
391 fi 386 fi
392 387
393 if [[ -n "${PYTHON_MODNAME}" ]]; then 388 if [[ -n "${PYTHON_MODNAME}" ]]; then
394 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 389 if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
395 python_mod_optimize ${PYTHON_MODNAME} 390 python_mod_optimize ${PYTHON_MODNAME}
396 else 391 else
397 for pymod in ${PYTHON_MODNAME}; do 392 for pymod in ${PYTHON_MODNAME}; do
398 python_mod_optimize "$(python_get_sitedir)/${pymod}" 393 python_mod_optimize "$(python_get_sitedir)/${pymod}"
399 done 394 done
414 409
415 _python_initialize_prefix_variables 410 _python_initialize_prefix_variables
416 411
417 local pylibdir pymod 412 local pylibdir pymod
418 if [[ -z "$(declare -p PYTHON_MODNAME 2> /dev/null)" ]]; then 413 if [[ -z "$(declare -p PYTHON_MODNAME 2> /dev/null)" ]]; then
419 for pylibdir in "${EROOT}"usr/$(get_libdir)/python* "${EROOT}"/usr/share/jython-*/Lib; do 414 for pylibdir in "${EROOT}"usr/$(get_libdir)/python* "${EROOT}"usr/share/jython-*/Lib; do
420 if [[ -d "${pylibdir}/site-packages/${PN}" ]]; then 415 if [[ -d "${pylibdir}/site-packages/${PN}" ]]; then
421 PYTHON_MODNAME="${PN}" 416 PYTHON_MODNAME="${PN}"
422 fi 417 fi
423 done 418 done
424 fi 419 fi
425 420
426 if [[ -n "${PYTHON_MODNAME}" ]]; then 421 if [[ -n "${PYTHON_MODNAME}" ]]; then
427 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 422 if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
428 python_mod_cleanup ${PYTHON_MODNAME} 423 python_mod_cleanup ${PYTHON_MODNAME}
429 else 424 else
430 for pymod in ${PYTHON_MODNAME}; do 425 for pymod in ${PYTHON_MODNAME}; do
431 for pylibdir in "${EROOT}"usr/$(get_libdir)/python*; do 426 for pylibdir in "${EROOT}"usr/$(get_libdir)/python*; do
432 if [[ -d "${pylibdir}/site-packages/${pymod}" ]]; then 427 if [[ -d "${pylibdir}/site-packages/${pymod}" ]]; then

Legend:
Removed from v.1.76  
changed lines
  Added in v.1.79

  ViewVC Help
Powered by ViewVC 1.1.20