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

Diff of /eclass/distutils.eclass

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

Revision 1.74 Revision 1.76
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.74 2010/03/04 17:49:03 arfrever Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/distutils.eclass,v 1.76 2010/07/17 23:03:29 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#
36 36
37# @ECLASS-VARIABLE: DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES 37# @ECLASS-VARIABLE: DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES
38# @DESCRIPTION: 38# @DESCRIPTION:
39# Set this to use separate source directories for each enabled version of Python. 39# Set this to use separate source directories for each enabled version of Python.
40 40
41# @ECLASS-VARIABLE: DISTUTILS_SETUP_FILES
42# @DESCRIPTION:
43# Paths to setup files.
44
41# @ECLASS-VARIABLE: DISTUTILS_GLOBAL_OPTIONS 45# @ECLASS-VARIABLE: DISTUTILS_GLOBAL_OPTIONS
42# @DESCRIPTION: 46# @DESCRIPTION:
43# Global options passed to setup.py. 47# Global options passed to setup files.
44 48
45# @ECLASS-VARIABLE: DISTUTILS_SRC_TEST 49# @ECLASS-VARIABLE: DISTUTILS_SRC_TEST
46# @DESCRIPTION: 50# @DESCRIPTION:
47# Type of test command used by distutils_src_test(). 51# Type of test command used by distutils_src_test().
48# IUSE and DEPEND are automatically adjusted, unless DISTUTILS_DISABLE_TEST_DEPENDENCY is set. 52# IUSE and DEPEND are automatically adjusted, unless DISTUTILS_DISABLE_TEST_DEPENDENCY is set.
178 182
179 if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 183 if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
180 distutils_building() { 184 distutils_building() {
181 _distutils_hook pre 185 _distutils_hook pre
182 186
187 local setup_file
188 for setup_file in "${DISTUTILS_SETUP_FILES[@]-setup.py}"; do
183 echo ${_BOLD}"$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build -b "$(_distutils_get_build_dir)" "$@"${_NORMAL} 189 echo ${_BOLD}"$(PYTHON)" "${setup_file}" "${DISTUTILS_GLOBAL_OPTIONS[@]}" build -b "$(_distutils_get_build_dir)" "$@"${_NORMAL}
184 "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build -b "$(_distutils_get_build_dir)" "$@" || return "$?" 190 "$(PYTHON)" "${setup_file}" "${DISTUTILS_GLOBAL_OPTIONS[@]}" build -b "$(_distutils_get_build_dir)" "$@" || return "$?"
191 done
185 192
186 _distutils_hook post 193 _distutils_hook post
187 } 194 }
188 python_execute_function ${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES:+-s} distutils_building "$@" 195 python_execute_function ${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES:+-s} distutils_building "$@"
189 else 196 else
197 local setup_file
198 for setup_file in "${DISTUTILS_SETUP_FILES[@]-setup.py}"; do
190 echo ${_BOLD}"$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build "$@"${_NORMAL} 199 echo ${_BOLD}"$(PYTHON)" "${setup_file}" "${DISTUTILS_GLOBAL_OPTIONS[@]}" build "$@"${_NORMAL}
191 "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build "$@" || die "Building failed" 200 "$(PYTHON)" "${setup_file}" "${DISTUTILS_GLOBAL_OPTIONS[@]}" build "$@" || die "Building failed"
201 done
192 fi 202 fi
193} 203}
194 204
195_distutils_src_test_hook() { 205_distutils_src_test_hook() {
196 if [[ "$#" -ne 1 ]]; then 206 if [[ "$#" -ne 1 ]]; then
218# @DESCRIPTION: 228# @DESCRIPTION:
219# The distutils src_test function. This function is exported, when DISTUTILS_SRC_TEST variable is set. 229# The distutils src_test function. This function is exported, when DISTUTILS_SRC_TEST variable is set.
220# In ebuilds of packages supporting installation for multiple versions of Python, this function 230# In ebuilds of packages supporting installation for multiple versions of Python, this function
221# calls distutils_src_test_pre_hook() and distutils_src_test_post_hook(), if they are defined. 231# calls distutils_src_test_pre_hook() and distutils_src_test_post_hook(), if they are defined.
222distutils_src_test() { 232distutils_src_test() {
233 if [[ "${EBUILD_PHASE}" != "test" ]]; then
234 die "${FUNCNAME}() can be used only in src_test() phase"
235 fi
236
223 _python_set_color_variables 237 _python_set_color_variables
224 238
225 if [[ "${DISTUTILS_SRC_TEST}" == "setup.py" ]]; then 239 if [[ "${DISTUTILS_SRC_TEST}" == "setup.py" ]]; then
226 if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 240 if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
227 distutils_testing() { 241 distutils_testing() {
228 _distutils_hook pre 242 _distutils_hook pre
229 243
244 local setup_file
245 for setup_file in "${DISTUTILS_SETUP_FILES[@]-setup.py}"; do
230 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} 246 echo ${_BOLD}PYTHONPATH="$(_distutils_get_PYTHONPATH)" "$(PYTHON)" "${setup_file}" "${DISTUTILS_GLOBAL_OPTIONS[@]}" $([[ -z "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]] && echo build -b "$(_distutils_get_build_dir)") test "$@"${_NORMAL}
231 PYTHONPATH="$(_distutils_get_PYTHONPATH)" "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" $([[ -z "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]] && echo build -b "$(_distutils_get_build_dir)") test "$@" || return "$?" 247 PYTHONPATH="$(_distutils_get_PYTHONPATH)" "$(PYTHON)" "${setup_file}" "${DISTUTILS_GLOBAL_OPTIONS[@]}" $([[ -z "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]] && echo build -b "$(_distutils_get_build_dir)") test "$@" || return "$?"
248 done
232 249
233 _distutils_hook post 250 _distutils_hook post
234 } 251 }
235 python_execute_function ${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES:+-s} distutils_testing "$@" 252 python_execute_function ${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES:+-s} distutils_testing "$@"
236 else 253 else
254 local setup_file
255 for setup_file in "${DISTUTILS_SETUP_FILES[@]-setup.py}"; do
237 echo ${_BOLD}PYTHONPATH="$(_distutils_get_PYTHONPATH)" "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" test "$@"${_NORMAL} 256 echo ${_BOLD}PYTHONPATH="$(_distutils_get_PYTHONPATH)" "$(PYTHON)" "${setup_file}" "${DISTUTILS_GLOBAL_OPTIONS[@]}" test "$@"${_NORMAL}
238 PYTHONPATH="$(_distutils_get_PYTHONPATH)" "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" test "$@" || die "Testing failed" 257 PYTHONPATH="$(_distutils_get_PYTHONPATH)" "$(PYTHON)" "${setup_file}" "${DISTUTILS_GLOBAL_OPTIONS[@]}" test "$@" || die "Testing failed"
258 done
239 fi 259 fi
240 elif [[ "${DISTUTILS_SRC_TEST}" == "nosetests" ]]; then 260 elif [[ "${DISTUTILS_SRC_TEST}" == "nosetests" ]]; then
241 _distutils_src_test_hook nosetests 261 _distutils_src_test_hook nosetests
242 262
243 python_execute_nosetests -P '$(_distutils_get_PYTHONPATH)' ${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES:+-s} -- "$@" 263 python_execute_nosetests -P '$(_distutils_get_PYTHONPATH)' ${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES:+-s} -- "$@"
300 fi 320 fi
301 321
302 distutils_installation() { 322 distutils_installation() {
303 _distutils_hook pre 323 _distutils_hook pre
304 324
325 local setup_file
326 for setup_file in "${DISTUTILS_SETUP_FILES[@]-setup.py}"; do
305 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} 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}
306 "$(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 "$?" 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 "$?"
329 done
307 330
308 if [[ -z "${DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS}" && "${BASH_VERSINFO[0]}" -ge 4 ]]; then 331 if [[ -z "${DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS}" && "${BASH_VERSINFO[0]}" -ge 4 ]]; then
309 rename_scripts_with_versioned_shebangs 332 rename_scripts_with_versioned_shebangs
310 fi 333 fi
311 334
319 unset wrapper_scripts 342 unset wrapper_scripts
320 else 343 else
321 # Mark the package to be rebuilt after a Python upgrade. 344 # Mark the package to be rebuilt after a Python upgrade.
322 python_need_rebuild 345 python_need_rebuild
323 346
347 local setup_file
348 for setup_file in "${DISTUTILS_SETUP_FILES[@]-setup.py}"; do
324 echo ${_BOLD}"$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@"${_NORMAL} 349 echo ${_BOLD}"$(PYTHON)" "${setup_file}" "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@"${_NORMAL}
325 "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@" || die "Installation failed" 350 "$(PYTHON)" "${setup_file}" "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@" || die "Installation failed"
351 done
326 fi 352 fi
327 353
328 if [[ -e "${ED}usr/local" ]]; then 354 if [[ -e "${ED}usr/local" ]]; then
329 die "Illegal installation into /usr/local" 355 die "Illegal installation into /usr/local"
330 fi 356 fi
354 fi 380 fi
355 381
356 _python_initialize_prefix_variables 382 _python_initialize_prefix_variables
357 383
358 local pylibdir pymod 384 local pylibdir pymod
359 if [[ -z "${PYTHON_MODNAME}" ]]; then 385 if [[ -z "$(declare -p PYTHON_MODNAME 2> /dev/null)" ]]; then
360 for pylibdir in "${EROOT}"usr/$(get_libdir)/python* "${EROOT}"/usr/share/jython-*/Lib; do 386 for pylibdir in "${EROOT}"usr/$(get_libdir)/python* "${EROOT}"/usr/share/jython-*/Lib; do
361 if [[ -d "${pylibdir}/site-packages/${PN}" ]]; then 387 if [[ -d "${pylibdir}/site-packages/${PN}" ]]; then
362 PYTHON_MODNAME="${PN}" 388 PYTHON_MODNAME="${PN}"
363 fi 389 fi
364 done 390 done
365 fi 391 fi
366 392
393 if [[ -n "${PYTHON_MODNAME}" ]]; then
367 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 394 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
368 python_mod_optimize ${PYTHON_MODNAME} 395 python_mod_optimize ${PYTHON_MODNAME}
369 else 396 else
370 for pymod in ${PYTHON_MODNAME}; do 397 for pymod in ${PYTHON_MODNAME}; do
371 python_mod_optimize "$(python_get_sitedir)/${pymod}" 398 python_mod_optimize "$(python_get_sitedir)/${pymod}"
372 done 399 done
400 fi
373 fi 401 fi
374} 402}
375 403
376# @FUNCTION: distutils_pkg_postrm 404# @FUNCTION: distutils_pkg_postrm
377# @DESCRIPTION: 405# @DESCRIPTION:
385 fi 413 fi
386 414
387 _python_initialize_prefix_variables 415 _python_initialize_prefix_variables
388 416
389 local pylibdir pymod 417 local pylibdir pymod
390 if [[ -z "${PYTHON_MODNAME}" ]]; then 418 if [[ -z "$(declare -p PYTHON_MODNAME 2> /dev/null)" ]]; then
391 for pylibdir in "${EROOT}"usr/$(get_libdir)/python* "${EROOT}"/usr/share/jython-*/Lib; do 419 for pylibdir in "${EROOT}"usr/$(get_libdir)/python* "${EROOT}"/usr/share/jython-*/Lib; do
392 if [[ -d "${pylibdir}/site-packages/${PN}" ]]; then 420 if [[ -d "${pylibdir}/site-packages/${PN}" ]]; then
393 PYTHON_MODNAME="${PN}" 421 PYTHON_MODNAME="${PN}"
394 fi 422 fi
395 done 423 done
405 python_mod_cleanup "${pylibdir#${EROOT%/}}/site-packages/${pymod}" 433 python_mod_cleanup "${pylibdir#${EROOT%/}}/site-packages/${pymod}"
406 fi 434 fi
407 done 435 done
408 done 436 done
409 fi 437 fi
410 else
411 python_mod_cleanup
412 fi 438 fi
413} 439}
414 440
415# @FUNCTION: distutils_python_version 441# Scheduled for deletion on 2011-01-01.
416# @DESCRIPTION:
417# Deprecated wrapper function for deprecated python_version().
418distutils_python_version() { 442distutils_python_version() {
419 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
420 eerror "Use PYTHON() and/or python_get_*() instead of ${FUNCNAME}()."
421 die "${FUNCNAME}() cannot be used in this EAPI"
422 fi
423
424 _python_set_color_variables
425
426 eerror
427 eerror "${_RED}Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01.${_NORMAL}"
428 eerror "${_RED}Use PYTHON() instead of python variable. Use python_get_*() instead of PYVER* variables.${_NORMAL}" 443 eerror "Use PYTHON() instead of python variable. Use python_get_*() instead of PYVER* variables."
429 eerror 444 die "${FUNCNAME}() is banned"
430
431 python_version
432} 445}
433 446
434# @FUNCTION: distutils_python_tkinter 447# Scheduled for deletion on 2011-01-01.
435# @DESCRIPTION:
436# Deprecated wrapper function for deprecated python_tkinter_exists().
437distutils_python_tkinter() { 448distutils_python_tkinter() {
438 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
439 eerror "Use PYTHON_USE_WITH=\"xml\" and python_pkg_setup() instead of ${FUNCNAME}()." 449 eerror "Use PYTHON_USE_WITH=\"xml\" and python_pkg_setup() instead of ${FUNCNAME}()."
440 die "${FUNCNAME}() cannot be used in this EAPI" 450 die "${FUNCNAME}() is banned"
441 fi
442
443 _python_set_color_variables
444
445 eerror
446 eerror "${_RED}Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-07-01.${_NORMAL}"
447 eerror "${_RED}Use PYTHON_USE_WITH=\"xml\" and python_pkg_setup() instead of ${FUNCNAME}().${_NORMAL}"
448 eerror
449
450 python_tkinter_exists
451} 451}

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

  ViewVC Help
Powered by ViewVC 1.1.20