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

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

  ViewVC Help
Powered by ViewVC 1.1.20