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

Diff of /eclass/distutils.eclass

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

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

Legend:
Removed from v.1.75  
changed lines
  Added in v.1.82

  ViewVC Help
Powered by ViewVC 1.1.20