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

Diff of /eclass/distutils.eclass

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

Revision 1.59 Revision 1.85
1# Copyright 1999-2009 Gentoo Foundation 1# Copyright 1999-2014 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.59 2009/08/12 02:24:34 arfrever Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/distutils.eclass,v 1.85 2014/11/20 15:32:09 mgorny Exp $
4 4
5# @ECLASS: distutils.eclass 5# @ECLASS: distutils.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# <python@gentoo.org> 7# Gentoo Python Project <python@gentoo.org>
8# @BLURB: Eclass for packages with build systems using Distutils
9# @DESCRIPTION:
10# The distutils eclass defines phase functions for packages with build systems using Distutils.
8# 11#
9# Original author: Jon Nelson <jnelson@gentoo.org> 12# This eclass is DEPRECATED. Please use distutils-r1 instead.
10# @BLURB: This eclass allows easier installation of distutils-based python modules
11# @DESCRIPTION:
12# The distutils eclass is designed to allow easier installation of
13# distutils-based python modules and their incorporation into
14# the Gentoo Linux system.
15 13
16inherit eutils multilib python 14if [[ -z "${_PYTHON_ECLASS_INHERITED}" ]]; then
15 inherit python
16fi
17
18inherit multilib
17 19
18case "${EAPI:-0}" in 20case "${EAPI:-0}" in
19 0|1) 21 0|1)
20 EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_postinst pkg_postrm 22 EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_postinst pkg_postrm
21 ;; 23 ;;
22 *) 24 *)
23 EXPORT_FUNCTIONS src_unpack src_prepare src_compile src_install pkg_postinst pkg_postrm 25 EXPORT_FUNCTIONS src_prepare src_compile src_install pkg_postinst pkg_postrm
24 ;; 26 ;;
25esac 27esac
26 28
27# @ECLASS-VARIABLE: PYTHON_SLOT_VERSION 29if [[ -z "$(declare -p PYTHON_DEPEND 2> /dev/null)" ]]; then
28# @DESCRIPTION:
29# This helps make it possible to add extensions to python slots.
30# Normally only a -py21- ebuild would set PYTHON_SLOT_VERSION.
31if [ "${PYTHON_SLOT_VERSION}" = "2.1" ] ; then
32 DEPEND="=dev-lang/python-2.1*" 30 DEPEND="dev-lang/python"
31 RDEPEND="${DEPEND}"
32fi
33
34 if has "${EAPI:-0}" 0 1 && [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
35 ewarn
36 ewarn "\"${EBUILD}\":"
37 ewarn "Deprecation Warning: Usage of distutils.eclass in packages supporting installation"
38 ewarn "for multiple Python ABIs in EAPI <=1 is deprecated."
39 ewarn "The ebuild should to be fixed. Please report a bug, if it has not been already reported."
40 ewarn
41 elif has "${EAPI:-0}" 0 1 2 && [[ -z "${SUPPORT_PYTHON_ABIS}" ]]; then
42 ewarn
43 ewarn "\"${EBUILD}\":"
44 ewarn "Deprecation Warning: Usage of distutils.eclass in packages not supporting installation"
45 ewarn "for multiple Python ABIs in EAPI <=2 is deprecated."
46 ewarn "The ebuild should to be fixed. Please report a bug, if it has not been already reported."
47 ewarn
48 fi
49
50# 'python' variable is deprecated. Use PYTHON() instead.
51if has "${EAPI:-0}" 0 1 2 && [[ -z "${SUPPORT_PYTHON_ABIS}" ]]; then
33 python="python2.1" 52 python="python"
34elif [ "${PYTHON_SLOT_VERSION}" = "2.3" ] ; then
35 DEPEND="=dev-lang/python-2.3*"
36 python="python2.3"
37else 53else
38 DEPEND="virtual/python" 54 python="die"
39 python="python" 55fi
56
57# @ECLASS-VARIABLE: DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES
58# @DESCRIPTION:
59# Set this to use separate source directories for each enabled version of Python.
60
61# @ECLASS-VARIABLE: DISTUTILS_SETUP_FILES
62# @DESCRIPTION:
63# Array of paths to setup files.
64# Syntax:
65# [current_working_directory|]path_to_setup_file
66
67# @ECLASS-VARIABLE: DISTUTILS_GLOBAL_OPTIONS
68# @DESCRIPTION:
69# Array of global options passed to setup files.
70# Syntax in EAPI <4:
71# global_option
72# Syntax in EAPI >=4:
73# Python_ABI_pattern global_option
74
75# @ECLASS-VARIABLE: DISTUTILS_SRC_TEST
76# @DESCRIPTION:
77# Type of test command used by distutils_src_test().
78# IUSE and DEPEND are automatically adjusted, unless DISTUTILS_DISABLE_TEST_DEPENDENCY is set.
79# Valid values:
80# setup.py
81# nosetests
82# py.test
83# trial [arguments]
84
85# @ECLASS-VARIABLE: DISTUTILS_DISABLE_TEST_DEPENDENCY
86# @DESCRIPTION:
87# Disable modification of IUSE and DEPEND caused by setting of DISTUTILS_SRC_TEST.
88
89if [[ -n "${DISTUTILS_SRC_TEST}" && ! "${DISTUTILS_SRC_TEST}" =~ ^(setup\.py|nosetests|py\.test|trial(\ .*)?)$ ]]; then
90 die "'DISTUTILS_SRC_TEST' variable has unsupported value '${DISTUTILS_SRC_TEST}'"
91fi
92
93if [[ -z "${DISTUTILS_DISABLE_TEST_DEPENDENCY}" ]]; then
94 if [[ "${DISTUTILS_SRC_TEST}" == "nosetests" ]]; then
95 IUSE="test"
96 DEPEND+="${DEPEND:+ }test? ( dev-python/nose )"
97 elif [[ "${DISTUTILS_SRC_TEST}" == "py.test" ]]; then
98 IUSE="test"
99 DEPEND+="${DEPEND:+ }test? ( dev-python/pytest )"
100 # trial requires an argument, which is usually equal to "${PN}".
101 elif [[ "${DISTUTILS_SRC_TEST}" =~ ^trial(\ .*)?$ ]]; then
102 IUSE="test"
103 DEPEND+="${DEPEND:+ }test? ( dev-python/twisted-core )"
104 fi
105fi
106
107if [[ -n "${DISTUTILS_SRC_TEST}" ]]; then
108 EXPORT_FUNCTIONS src_test
109fi
110
111# Scheduled for deletion on 2011-06-01.
112if [[ -n "${DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS}" ]]; then
113 eerror "Use PYTHON_NONVERSIONED_EXECUTABLES=(\".*\") instead of DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS variable."
114 die "DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS variable is banned"
40fi 115fi
41 116
42# @ECLASS-VARIABLE: DOCS 117# @ECLASS-VARIABLE: DOCS
43# @DESCRIPTION: 118# @DESCRIPTION:
44# Additional DOCS 119# Additional documentation files installed by distutils_src_install().
120
121_distutils_get_build_dir() {
122 if _python_package_supporting_installation_for_multiple_python_abis && [[ -z "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]]; then
123 echo "build-${PYTHON_ABI}"
124 else
125 echo "build"
126 fi
127}
128
129_distutils_get_PYTHONPATH() {
130 if _python_package_supporting_installation_for_multiple_python_abis && [[ -z "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]]; then
131 ls -d build-${PYTHON_ABI}/lib* 2> /dev/null
132 else
133 ls -d build/lib* 2> /dev/null
134 fi
135}
136
137_distutils_hook() {
138 if [[ "$#" -ne 1 ]]; then
139 die "${FUNCNAME}() requires 1 argument"
140 fi
141 if [[ "$(type -t "distutils_src_${EBUILD_PHASE}_$1_hook")" == "function" ]]; then
142 "distutils_src_${EBUILD_PHASE}_$1_hook"
143 fi
144}
145
146_distutils_prepare_global_options() {
147 local element option pattern
148
149 if [[ -n "$(declare -p DISTUTILS_GLOBAL_OPTIONS 2> /dev/null)" && "$(declare -p DISTUTILS_GLOBAL_OPTIONS)" != "declare -a DISTUTILS_GLOBAL_OPTIONS="* ]]; then
150 die "DISTUTILS_GLOBAL_OPTIONS should be indexed array"
151 fi
152
153 if has "${EAPI:-0}" 0 1 2 3; then
154 _DISTUTILS_GLOBAL_OPTIONS=("${DISTUTILS_GLOBAL_OPTIONS[@]}")
155 else
156 _DISTUTILS_GLOBAL_OPTIONS=()
157
158 for element in "${DISTUTILS_GLOBAL_OPTIONS[@]}"; do
159 if [[ ! "${element}" =~ ^[^[:space:]]+\ . ]]; then
160 die "Element '${element}' of DISTUTILS_GLOBAL_OPTIONS array has invalid syntax"
161 fi
162 pattern="${element%% *}"
163 option="${element#* }"
164 if _python_check_python_abi_matching "${PYTHON_ABI}" "${pattern}"; then
165 _DISTUTILS_GLOBAL_OPTIONS+=("${option}")
166 fi
167 done
168 fi
169}
170
171_distutils_prepare_current_working_directory() {
172 if [[ "$1" == *"|"*"|"* ]]; then
173 die "Element '$1' of DISTUTILS_SETUP_FILES array has invalid syntax"
174 fi
175
176 if [[ "$1" == *"|"* ]]; then
177 echo "${_BOLD}[${1%|*}]${_NORMAL}"
178 pushd "${1%|*}" > /dev/null || die "Entering directory '${1%|*}' failed"
179 fi
180}
181
182_distutils_restore_current_working_directory() {
183 if [[ "$1" == *"|"* ]]; then
184 popd > /dev/null || die "Leaving directory '${1%|*}' failed"
185 fi
186}
45 187
46# @FUNCTION: distutils_src_unpack 188# @FUNCTION: distutils_src_unpack
47# @DESCRIPTION: 189# @DESCRIPTION:
48# The distutils src_unpack function, this function is exported 190# The distutils src_unpack function. This function is exported.
49distutils_src_unpack() { 191distutils_src_unpack() {
192 if ! has "${EAPI:-0}" 0 1; then
193 die "${FUNCNAME}() cannot be used in this EAPI"
194 fi
195
50 if [[ "${EBUILD_PHASE}" != "unpack" ]]; then 196 if [[ "${EBUILD_PHASE}" != "unpack" ]]; then
51 die "${FUNCNAME}() can be used only in src_unpack() phase" 197 die "${FUNCNAME}() can be used only in src_unpack() phase"
52 fi 198 fi
53 199
54 unpack ${A} 200 unpack ${A}
55 cd "${S}" 201 cd "${S}"
56 202
57 has "${EAPI:-0}" 0 1 && distutils_src_prepare 203 distutils_src_prepare
58} 204}
59 205
60# @FUNCTION: distutils_src_prepare 206# @FUNCTION: distutils_src_prepare
61# @DESCRIPTION: 207# @DESCRIPTION:
62# The distutils src_prepare function, this function is exported 208# The distutils src_prepare function. This function is exported.
63distutils_src_prepare() { 209distutils_src_prepare() {
64 if ! has "${EAPI:-0}" 0 1 && [[ "${EBUILD_PHASE}" != "prepare" ]]; then 210 if ! has "${EAPI:-0}" 0 1 && [[ "${EBUILD_PHASE}" != "prepare" ]]; then
65 die "${FUNCNAME}() can be used only in src_prepare() phase" 211 die "${FUNCNAME}() can be used only in src_prepare() phase"
66 fi 212 fi
67 213
68 # remove ez_setup stuff to prevent packages 214 _python_check_python_pkg_setup_execution
69 # from installing setuptools on their own 215
216 local distribute_setup_existence="0" ez_setup_existence="0"
217
218 if [[ "$#" -ne 0 ]]; then
219 die "${FUNCNAME}() does not accept arguments"
220 fi
221
222 # Delete ez_setup files to prevent packages from installing Setuptools on their own.
223 [[ -d ez_setup || -f ez_setup.py ]] && ez_setup_existence="1"
70 rm -rf ez_setup* 224 rm -fr ez_setup*
225 if [[ "${ez_setup_existence}" == "1" ]]; then
71 echo "def use_setuptools(*args, **kwargs): pass" > ez_setup.py 226 echo "def use_setuptools(*args, **kwargs): pass" > ez_setup.py
227 fi
228
229 # Delete distribute_setup files to prevent packages from installing Distribute on their own.
230 [[ -d distribute_setup || -f distribute_setup.py ]] && distribute_setup_existence="1"
231 rm -fr distribute_setup*
232 if [[ "${distribute_setup_existence}" == "1" ]]; then
233 echo "def use_setuptools(*args, **kwargs): pass" > distribute_setup.py
234 fi
235
236 if [[ -n "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]]; then
237 python_copy_sources
238 fi
72} 239}
73 240
74# @FUNCTION: distutils_src_compile 241# @FUNCTION: distutils_src_compile
75# @DESCRIPTION: 242# @DESCRIPTION:
76# The distutils src_compile function, this function is exported 243# The distutils src_compile function. This function is exported.
244# In ebuilds of packages supporting installation for multiple versions of Python, this function
245# calls distutils_src_compile_pre_hook() and distutils_src_compile_post_hook(), if they are defined.
77distutils_src_compile() { 246distutils_src_compile() {
78 if [[ "${EBUILD_PHASE}" != "compile" ]]; then 247 if [[ "${EBUILD_PHASE}" != "compile" ]]; then
79 die "${FUNCNAME}() can be used only in src_compile() phase" 248 die "${FUNCNAME}() can be used only in src_compile() phase"
80 fi 249 fi
81 250
82 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 251 _python_check_python_pkg_setup_execution
83 building() { 252 _python_set_color_variables
84 echo "$(PYTHON)" setup.py build -b "build-${PYTHON_ABI}" "$@" 253
85 "$(PYTHON)" setup.py build -b "build-${PYTHON_ABI}" "$@" 254 local setup_file
255
256 if _python_package_supporting_installation_for_multiple_python_abis; then
257 distutils_building() {
258 _distutils_hook pre
259
260 _distutils_prepare_global_options
261
262 for setup_file in "${DISTUTILS_SETUP_FILES[@]-setup.py}"; do
263 _distutils_prepare_current_working_directory "${setup_file}"
264
265 echo ${_BOLD}"$(PYTHON)" "${setup_file#*|}" "${_DISTUTILS_GLOBAL_OPTIONS[@]}" build -b "$(_distutils_get_build_dir)" "$@"${_NORMAL}
266 "$(PYTHON)" "${setup_file#*|}" "${_DISTUTILS_GLOBAL_OPTIONS[@]}" build -b "$(_distutils_get_build_dir)" "$@" || return "$?"
267
268 _distutils_restore_current_working_directory "${setup_file}"
269 done
270
271 _distutils_hook post
86 } 272 }
87 python_execute_function building "$@" 273 python_execute_function ${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES:+-s} distutils_building "$@"
274 unset -f distutils_building
275 else
276 _distutils_prepare_global_options
277
278 for setup_file in "${DISTUTILS_SETUP_FILES[@]-setup.py}"; do
279 _distutils_prepare_current_working_directory "${setup_file}"
280
281 echo ${_BOLD}"$(PYTHON)" "${setup_file#*|}" "${_DISTUTILS_GLOBAL_OPTIONS[@]}" build "$@"${_NORMAL}
282 "$(PYTHON)" "${setup_file#*|}" "${_DISTUTILS_GLOBAL_OPTIONS[@]}" build "$@" || die "Building failed"
283
284 _distutils_restore_current_working_directory "${setup_file}"
285 done
286 fi
287}
288
289_distutils_src_test_hook() {
290 if [[ "$#" -ne 1 ]]; then
291 die "${FUNCNAME}() requires 1 arguments"
292 fi
293
294 if ! _python_package_supporting_installation_for_multiple_python_abis; then
295 return
296 fi
297
298 if [[ "$(type -t "distutils_src_test_pre_hook")" == "function" ]]; then
299 eval "python_execute_$1_pre_hook() {
300 distutils_src_test_pre_hook
301 }"
302 fi
303
304 if [[ "$(type -t "distutils_src_test_post_hook")" == "function" ]]; then
305 eval "python_execute_$1_post_hook() {
306 distutils_src_test_post_hook
307 }"
308 fi
309}
310
311# @FUNCTION: distutils_src_test
312# @DESCRIPTION:
313# The distutils src_test function. This function is exported, when DISTUTILS_SRC_TEST variable is set.
314# In ebuilds of packages supporting installation for multiple versions of Python, this function
315# calls distutils_src_test_pre_hook() and distutils_src_test_post_hook(), if they are defined.
316distutils_src_test() {
317 if [[ "${EBUILD_PHASE}" != "test" ]]; then
318 die "${FUNCNAME}() can be used only in src_test() phase"
319 fi
320
321 _python_check_python_pkg_setup_execution
322 _python_set_color_variables
323
324 local arguments setup_file
325
326 if [[ "${DISTUTILS_SRC_TEST}" == "setup.py" ]]; then
327 if _python_package_supporting_installation_for_multiple_python_abis; then
328 distutils_testing() {
329 _distutils_hook pre
330
331 _distutils_prepare_global_options
332
333 for setup_file in "${DISTUTILS_SETUP_FILES[@]-setup.py}"; do
334 _distutils_prepare_current_working_directory "${setup_file}"
335
336 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}
337 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 "$?"
338
339 _distutils_restore_current_working_directory "${setup_file}"
340 done
341
342 _distutils_hook post
343 }
344 python_execute_function ${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES:+-s} distutils_testing "$@"
345 unset -f distutils_testing
88 else 346 else
89 echo ${python} setup.py build "$@" 347 _distutils_prepare_global_options
90 ${python} setup.py build "$@" || die "Building failed" 348
349 for setup_file in "${DISTUTILS_SETUP_FILES[@]-setup.py}"; do
350 _distutils_prepare_current_working_directory "${setup_file}"
351
352 echo ${_BOLD}PYTHONPATH="$(_distutils_get_PYTHONPATH)" "$(PYTHON)" "${setup_file#*|}" "${_DISTUTILS_GLOBAL_OPTIONS[@]}" test "$@"${_NORMAL}
353 PYTHONPATH="$(_distutils_get_PYTHONPATH)" "$(PYTHON)" "${setup_file#*|}" "${_DISTUTILS_GLOBAL_OPTIONS[@]}" test "$@" || die "Testing failed"
354
355 _distutils_restore_current_working_directory "${setup_file}"
356 done
357 fi
358 elif [[ "${DISTUTILS_SRC_TEST}" == "nosetests" ]]; then
359 _distutils_src_test_hook nosetests
360
361 python_execute_nosetests -P '$(_distutils_get_PYTHONPATH)' ${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES:+-s} -- "$@"
362 elif [[ "${DISTUTILS_SRC_TEST}" == "py.test" ]]; then
363 _distutils_src_test_hook py.test
364
365 python_execute_py.test -P '$(_distutils_get_PYTHONPATH)' ${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES:+-s} -- "$@"
366 # trial requires an argument, which is usually equal to "${PN}".
367 elif [[ "${DISTUTILS_SRC_TEST}" =~ ^trial(\ .*)?$ ]]; then
368 if [[ "${DISTUTILS_SRC_TEST}" == "trial "* ]]; then
369 arguments="${DISTUTILS_SRC_TEST#trial }"
370 else
371 arguments="${PN}"
372 fi
373
374 _distutils_src_test_hook trial
375
376 python_execute_trial -P '$(_distutils_get_PYTHONPATH)' ${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES:+-s} -- ${arguments} "$@"
377 else
378 die "'DISTUTILS_SRC_TEST' variable has unsupported value '${DISTUTILS_SRC_TEST}'"
91 fi 379 fi
92} 380}
93 381
94# @FUNCTION: distutils_src_install 382# @FUNCTION: distutils_src_install
95# @DESCRIPTION: 383# @DESCRIPTION:
96# The distutils src_install function, this function is exported. 384# The distutils src_install function. This function is exported.
97# It also installs the "standard docs" (CHANGELOG, Change*, KNOWN_BUGS, MAINTAINERS, 385# In ebuilds of packages supporting installation for multiple versions of Python, this function
98# PKG-INFO, CONTRIBUTORS, TODO, NEWS, MANIFEST*, README*, and AUTHORS) 386# calls distutils_src_install_pre_hook() and distutils_src_install_post_hook(), if they are defined.
387# It also installs some standard documentation files (AUTHORS, Change*, CHANGELOG, CONTRIBUTORS,
388# KNOWN_BUGS, MAINTAINERS, NEWS, README*, TODO).
99distutils_src_install() { 389distutils_src_install() {
100 if [[ "${EBUILD_PHASE}" != "install" ]]; then 390 if [[ "${EBUILD_PHASE}" != "install" ]]; then
101 die "${FUNCNAME}() can be used only in src_install() phase" 391 die "${FUNCNAME}() can be used only in src_install() phase"
102 fi 392 fi
103 393
104 local pylibdir 394 _python_check_python_pkg_setup_execution
395 _python_initialize_prefix_variables
396 _python_set_color_variables
105 397
106 # Mark the package to be rebuilt after a python upgrade. 398 local default_docs doc line nspkg_pth_file nspkg_pth_files=() setup_file
107 python_need_rebuild
108 399
109 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 400 if _python_package_supporting_installation_for_multiple_python_abis; then
110 installation() { 401 distutils_installation() {
111 # need this for python-2.5 + setuptools in cases where 402 _distutils_hook pre
112 # a package uses distutils but does not install anything
113 # in site-packages. (eg. dev-java/java-config-2.x)
114 # - liquidx (14/08/2006)
115 pylibdir="$("$(PYTHON)" -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')"
116 [[ -n "${pylibdir}" ]] && dodir "${pylibdir}"
117 403
118 echo "$(PYTHON)" setup.py build -b "build-${PYTHON_ABI}" install --root="${D}" --no-compile "$@" 404 _distutils_prepare_global_options
119 "$(PYTHON)" setup.py build -b "build-${PYTHON_ABI}" install --root="${D}" --no-compile "$@" 405
406 for setup_file in "${DISTUTILS_SETUP_FILES[@]-setup.py}"; do
407 _distutils_prepare_current_working_directory "${setup_file}"
408
409 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}
410 "$(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 "$?"
411
412 _distutils_restore_current_working_directory "${setup_file}"
413 done
414
415 _distutils_hook post
120 } 416 }
121 python_execute_function installation "$@" 417 python_execute_function ${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES:+-s} distutils_installation "$@"
122 else 418 unset -f distutils_installation
123 # need this for python-2.5 + setuptools in cases where
124 # a package uses distutils but does not install anything
125 # in site-packages. (eg. dev-java/java-config-2.x)
126 # - liquidx (14/08/2006)
127 pylibdir="$(${python} -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')"
128 [[ -n "${pylibdir}" ]] && dodir "${pylibdir}"
129 419
130 echo ${python} setup.py install --root="${D}" --no-compile "$@" 420 python_merge_intermediate_installation_images "${T}/images"
131 ${python} setup.py install --root="${D}" --no-compile "$@" || die "Installation failed" 421 else
132 fi 422 # Mark the package to be rebuilt after a Python upgrade.
423 python_need_rebuild
133 424
134 DDOCS="CHANGELOG KNOWN_BUGS MAINTAINERS PKG-INFO CONTRIBUTORS TODO NEWS" 425 _distutils_prepare_global_options
135 DDOCS="${DDOCS} Change* MANIFEST* README* AUTHORS"
136 426
137 local doc 427 for setup_file in "${DISTUTILS_SETUP_FILES[@]-setup.py}"; do
138 for doc in ${DDOCS}; do 428 _distutils_prepare_current_working_directory "${setup_file}"
429
430 echo ${_BOLD}"$(PYTHON)" "${setup_file#*|}" "${_DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@"${_NORMAL}
431 "$(PYTHON)" "${setup_file#*|}" "${_DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@" || die "Installation failed"
432
433 _distutils_restore_current_working_directory "${setup_file}"
434 done
435 fi
436
437 while read -d $'\0' -r nspkg_pth_file; do
438 nspkg_pth_files+=("${nspkg_pth_file}")
439 done < <(find "${ED}" -name "*-nspkg.pth" -type f -print0)
440
441 if [[ "${#nspkg_pth_files[@]}" -gt 0 ]]; then
442 einfo
443 einfo "Python namespaces:"
444 for nspkg_pth_file in "${nspkg_pth_files[@]}"; do
445 einfo " '${nspkg_pth_file#${ED%/}}':"
446 while read -r line; do
447 einfo " $(echo "${line}" | sed -e "s/.*types\.ModuleType('\([^']\+\)').*/\1/")"
448 done < "${nspkg_pth_file}"
449 #if ! has "${EAPI:-0}" 0 1 2 3; then
450 # rm -f "${nspkg_pth_file}" || die "Deletion of '${nspkg_pth_file}' failed"
451 #fi
452 done
453 einfo
454 fi
455
456 if [[ -e "${ED}usr/local" ]]; then
457 die "Illegal installation into /usr/local"
458 fi
459
460 default_docs="AUTHORS Change* CHANGELOG CONTRIBUTORS KNOWN_BUGS MAINTAINERS NEWS README* TODO"
461
462 for doc in ${default_docs}; do
139 [[ -s "$doc" ]] && dodoc $doc 463 [[ -s "${doc}" ]] && dodoc "${doc}"
140 done 464 done
141 465
142 [[ -n "${DOCS}" ]] && dodoc ${DOCS} 466 if has "${EAPI:-0}" 0 1 2 3; then
143} 467 if [[ -n "${DOCS}" ]]; then
468 dodoc ${DOCS} || die "dodoc failed"
469 fi
470 else
471 if [[ -n "${DOCS}" ]]; then
472 dodoc -r ${DOCS} || die "dodoc failed"
473 fi
474 fi
144 475
476 DISTUTILS_SRC_INSTALL_EXECUTED="1"
477}
478
145# @FUNCTION: distutils_pkg_postrm 479# @FUNCTION: distutils_pkg_postinst
146# @DESCRIPTION: 480# @DESCRIPTION:
147# Generic pyc/pyo cleanup script. This function is exported. 481# The distutils pkg_postinst function. This function is exported.
482# When PYTHON_MODNAME variable is set, then this function calls python_mod_optimize() with modules
483# specified in PYTHON_MODNAME variable. Otherwise it calls python_mod_optimize() with module, whose
484# name is equal to name of current package, if this module exists.
148distutils_pkg_postrm() { 485distutils_pkg_postinst() {
149 if [[ "${EBUILD_PHASE}" != "postrm" ]]; then 486 if [[ "${EBUILD_PHASE}" != "postinst" ]]; then
150 die "${FUNCNAME}() can be used only in pkg_postrm() phase" 487 die "${FUNCNAME}() can be used only in pkg_postinst() phase"
488 fi
489
490 _python_check_python_pkg_setup_execution
491 _python_initialize_prefix_variables
492
493 if [[ -z "${DISTUTILS_SRC_INSTALL_EXECUTED}" ]]; then
494 die "${FUNCNAME}() called illegally"
151 fi 495 fi
152 496
153 local pylibdir pymod 497 local pylibdir pymod
154 if [[ -z "${PYTHON_MODNAME}" ]]; then 498
499 if [[ "$#" -ne 0 ]]; then
500 die "${FUNCNAME}() does not accept arguments"
501 fi
502
503 if [[ -z "$(declare -p PYTHON_MODNAME 2> /dev/null)" ]]; then
155 for pylibdir in "${ROOT}"/usr/$(get_libdir)/python*; do 504 for pylibdir in "${EROOT}"usr/$(get_libdir)/python* "${EROOT}"usr/share/jython-*/Lib; do
156 if [[ -d "${pylibdir}/site-packages/${PN}" ]]; then 505 if [[ -d "${pylibdir}/site-packages/${PN}" ]]; then
157 PYTHON_MODNAME="${PN}" 506 PYTHON_MODNAME="${PN}"
158 fi 507 fi
159 done 508 done
160 fi 509 fi
161 510
162 if [[ -n "${PYTHON_MODNAME}" ]]; then 511 if [[ -n "${PYTHON_MODNAME}" ]]; then
512 if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
513 python_mod_optimize ${PYTHON_MODNAME}
514 else
163 for pymod in ${PYTHON_MODNAME}; do 515 for pymod in ${PYTHON_MODNAME}; do
164 for pylibdir in "${ROOT}"/usr/$(get_libdir)/python*; do 516 python_mod_optimize "$(python_get_sitedir)/${pymod}"
165 if [[ -d "${pylibdir}/site-packages/${pymod}" ]]; then
166 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
167 python_mod_cleanup "${pymod}"
168 else
169 python_mod_cleanup "${pylibdir#${ROOT}}/site-packages/${pymod}"
170 fi
171 fi
172 done 517 done
173 done
174 else
175 python_mod_cleanup
176 fi 518 fi
519 fi
177} 520}
178 521
179# @FUNCTION: distutils_pkg_postinst 522# @FUNCTION: distutils_pkg_postrm
180# @DESCRIPTION: 523# @DESCRIPTION:
181# This is a generic optimization, you should override it if your package 524# The distutils pkg_postrm function. This function is exported.
182# installs modules in another directory. This function is exported. 525# When PYTHON_MODNAME variable is set, then this function calls python_mod_cleanup() with modules
526# specified in PYTHON_MODNAME variable. Otherwise it calls python_mod_cleanup() with module, whose
527# name is equal to name of current package, if this module exists.
183distutils_pkg_postinst() { 528distutils_pkg_postrm() {
184 if [[ "${EBUILD_PHASE}" != "postinst" ]]; then 529 if [[ "${EBUILD_PHASE}" != "postrm" ]]; then
185 die "${FUNCNAME}() can be used only in pkg_postinst() phase" 530 die "${FUNCNAME}() can be used only in pkg_postrm() phase"
531 fi
532
533 _python_check_python_pkg_setup_execution
534 _python_initialize_prefix_variables
535
536 if [[ -z "${DISTUTILS_SRC_INSTALL_EXECUTED}" ]]; then
537 die "${FUNCNAME}() called illegally"
186 fi 538 fi
187 539
188 local pylibdir pymod 540 local pylibdir pymod
189 if [[ -z "${PYTHON_MODNAME}" ]]; then 541
542 if [[ "$#" -ne 0 ]]; then
543 die "${FUNCNAME}() does not accept arguments"
544 fi
545
546 if [[ -z "$(declare -p PYTHON_MODNAME 2> /dev/null)" ]]; then
190 for pylibdir in "${ROOT}"/usr/$(get_libdir)/python*; do 547 for pylibdir in "${EROOT}"usr/$(get_libdir)/python* "${EROOT}"usr/share/jython-*/Lib; do
191 if [[ -d "${pylibdir}/site-packages/${PN}" ]]; then 548 if [[ -d "${pylibdir}/site-packages/${PN}" ]]; then
192 PYTHON_MODNAME="${PN}" 549 PYTHON_MODNAME="${PN}"
193 fi 550 fi
194 done 551 done
195 fi 552 fi
196 553
197 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 554 if [[ -n "${PYTHON_MODNAME}" ]]; then
555 if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
556 python_mod_cleanup ${PYTHON_MODNAME}
557 else
198 for pymod in ${PYTHON_MODNAME}; do 558 for pymod in ${PYTHON_MODNAME}; do
199 python_mod_optimize "${pymod}" 559 for pylibdir in "${EROOT}"usr/$(get_libdir)/python*; do
560 if [[ -d "${pylibdir}/site-packages/${pymod}" ]]; then
561 python_mod_cleanup "${pylibdir#${EROOT%/}}/site-packages/${pymod}"
562 fi
563 done
200 done 564 done
201 else
202 python_version
203 for pymod in ${PYTHON_MODNAME}; do
204 python_mod_optimize "/usr/$(get_libdir)/python${PYVER}/site-packages/${pymod}"
205 done
206 fi 565 fi
566 fi
207} 567}
208 568
209# @FUNCTION: distutils_python_version 569# @FUNCTION: distutils_get_intermediate_installation_image
210# @DESCRIPTION: 570# @DESCRIPTION:
211# Calls python_version, so that you can use something like 571# Print path to intermediate installation image.
212# e.g. insinto ${ROOT}/usr/include/python${PYVER} 572#
213distutils_python_version() { 573# This function can be used only in distutils_src_install_pre_hook() and distutils_src_install_post_hook().
214 python_version 574distutils_get_intermediate_installation_image() {
215} 575 if [[ "${EBUILD_PHASE}" != "install" ]]; then
576 die "${FUNCNAME}() can be used only in src_install() phase"
577 fi
216 578
217# @FUNCTION: distutils_python_tkinter 579 if ! _python_package_supporting_installation_for_multiple_python_abis; then
218# @DESCRIPTION: 580 die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
219# Checks for if tkinter support is compiled into python 581 fi
220distutils_python_tkinter() { 582
221 python_tkinter_exists 583 _python_check_python_pkg_setup_execution
584
585 if [[ ! "${FUNCNAME[1]}" =~ ^distutils_src_install_(pre|post)_hook$ ]]; then
586 die "${FUNCNAME}() can be used only in distutils_src_install_pre_hook() and distutils_src_install_post_hook()"
587 fi
588
589 if [[ "$#" -ne 0 ]]; then
590 die "${FUNCNAME}() does not accept arguments"
591 fi
592
593 echo "${T}/images/${PYTHON_ABI}"
222} 594}

Legend:
Removed from v.1.59  
changed lines
  Added in v.1.85

  ViewVC Help
Powered by ViewVC 1.1.20