| 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.79 2010/12/24 15:05:24 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 | |
| 14 | inherit multilib python |
12 | inherit multilib python |
| … | |
… | |
| 25 | if [[ -z "$(declare -p PYTHON_DEPEND 2> /dev/null)" ]]; then |
23 | if [[ -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}" |
| 28 | fi |
26 | fi |
| 29 | |
27 | |
| 30 | if [[ -n "${PYTHON_DEPRECATION_WARNINGS}" ]]; then |
|
|
| 31 | if has "${EAPI:-0}" 0 1 && [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then |
28 | if has "${EAPI:-0}" 0 1 && [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then |
| 32 | ewarn |
29 | ewarn |
| 33 | ewarn "\"${EBUILD}\":" |
30 | ewarn "\"${EBUILD}\":" |
| 34 | ewarn "Deprecation Warning: Usage of distutils.eclass in packages supporting installation" |
31 | ewarn "Deprecation Warning: Usage of distutils.eclass in packages supporting installation" |
| 35 | ewarn "for multiple Python ABIs in EAPI <=1 is deprecated and will be banned on 2011-06-01." |
32 | ewarn "for multiple Python ABIs in EAPI <=1 is deprecated and will be banned on 2011-06-01." |
| … | |
… | |
| 41 | ewarn "Deprecation Warning: Usage of distutils.eclass in packages not supporting installation" |
38 | ewarn "Deprecation Warning: Usage of distutils.eclass in packages not supporting installation" |
| 42 | ewarn "for multiple Python ABIs in EAPI <=2 is deprecated and will be banned on 2011-06-01." |
39 | ewarn "for multiple Python ABIs in EAPI <=2 is deprecated and will be banned on 2011-06-01." |
| 43 | ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." |
40 | ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." |
| 44 | ewarn |
41 | ewarn |
| 45 | fi |
42 | fi |
| 46 | fi |
|
|
| 47 | |
43 | |
| 48 | # 'python' variable is deprecated. Use PYTHON() instead. |
44 | # 'python' variable is deprecated. Use PYTHON() instead. |
| 49 | if has "${EAPI:-0}" 0 1 2 && [[ -z "${SUPPORT_PYTHON_ABIS}" ]]; then |
45 | if has "${EAPI:-0}" 0 1 2 && [[ -z "${SUPPORT_PYTHON_ABIS}" ]]; then |
| 50 | python="python" |
46 | python="python" |
| 51 | else |
47 | else |
| … | |
… | |
| 56 | # @DESCRIPTION: |
52 | # @DESCRIPTION: |
| 57 | # 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. |
| 58 | |
54 | |
| 59 | # @ECLASS-VARIABLE: DISTUTILS_SETUP_FILES |
55 | # @ECLASS-VARIABLE: DISTUTILS_SETUP_FILES |
| 60 | # @DESCRIPTION: |
56 | # @DESCRIPTION: |
| 61 | # Paths to setup files. |
57 | # Array of paths to setup files. |
|
|
58 | # Syntax: |
|
|
59 | # [current_working_directory|]path_to_setup_file |
| 62 | |
60 | |
| 63 | # @ECLASS-VARIABLE: DISTUTILS_GLOBAL_OPTIONS |
61 | # @ECLASS-VARIABLE: DISTUTILS_GLOBAL_OPTIONS |
| 64 | # @DESCRIPTION: |
62 | # @DESCRIPTION: |
| 65 | # 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 |
| 66 | |
68 | |
| 67 | # @ECLASS-VARIABLE: DISTUTILS_SRC_TEST |
69 | # @ECLASS-VARIABLE: DISTUTILS_SRC_TEST |
| 68 | # @DESCRIPTION: |
70 | # @DESCRIPTION: |
| 69 | # Type of test command used by distutils_src_test(). |
71 | # Type of test command used by distutils_src_test(). |
| 70 | # 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. |
| … | |
… | |
| 98 | |
100 | |
| 99 | if [[ -n "${DISTUTILS_SRC_TEST}" ]]; then |
101 | if [[ -n "${DISTUTILS_SRC_TEST}" ]]; then |
| 100 | EXPORT_FUNCTIONS src_test |
102 | EXPORT_FUNCTIONS src_test |
| 101 | fi |
103 | fi |
| 102 | |
104 | |
| 103 | # @ECLASS-VARIABLE: DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS |
105 | # Scheduled for deletion on 2011-06-01. |
| 104 | # @DESCRIPTION: |
|
|
| 105 | # Set this to disable renaming of Python scripts containing versioned shebangs |
|
|
| 106 | # and generation of wrapper scripts. |
|
|
| 107 | if [[ -n "${DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS}" ]]; then |
106 | if [[ -n "${DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS}" ]]; then |
| 108 | ewarn |
107 | eerror "Use PYTHON_NONVERSIONED_EXECUTABLES=(\".*\") instead of DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS variable." |
| 109 | ewarn "\"${EBUILD}\":" |
108 | die "DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS variable is banned" |
| 110 | ewarn "Deprecation Warning: DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS is deprecated" |
|
|
| 111 | ewarn "and will be banned on 2011-02-01. Use PYTHON_NONVERSIONED_EXECUTABLES=(\".*\")." |
|
|
| 112 | ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported." |
|
|
| 113 | ewarn |
|
|
| 114 | |
|
|
| 115 | PYTHON_NONVERSIONED_EXECUTABLES=(".*") |
|
|
| 116 | fi |
109 | fi |
| 117 | |
110 | |
| 118 | # @ECLASS-VARIABLE: DOCS |
111 | # @ECLASS-VARIABLE: DOCS |
| 119 | # @DESCRIPTION: |
112 | # @DESCRIPTION: |
| 120 | # Additional documentation files installed by distutils_src_install(). |
113 | # Additional documentation files installed by distutils_src_install(). |
| … | |
… | |
| 139 | if [[ "$#" -ne 1 ]]; then |
132 | if [[ "$#" -ne 1 ]]; then |
| 140 | die "${FUNCNAME}() requires 1 argument" |
133 | die "${FUNCNAME}() requires 1 argument" |
| 141 | fi |
134 | fi |
| 142 | if [[ "$(type -t "distutils_src_${EBUILD_PHASE}_$1_hook")" == "function" ]]; then |
135 | if [[ "$(type -t "distutils_src_${EBUILD_PHASE}_$1_hook")" == "function" ]]; then |
| 143 | "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" |
| 144 | fi |
179 | fi |
| 145 | } |
180 | } |
| 146 | |
181 | |
| 147 | # @FUNCTION: distutils_src_unpack |
182 | # @FUNCTION: distutils_src_unpack |
| 148 | # @DESCRIPTION: |
183 | # @DESCRIPTION: |
| … | |
… | |
| 168 | distutils_src_prepare() { |
203 | distutils_src_prepare() { |
| 169 | if ! has "${EAPI:-0}" 0 1 && [[ "${EBUILD_PHASE}" != "prepare" ]]; then |
204 | if ! has "${EAPI:-0}" 0 1 && [[ "${EBUILD_PHASE}" != "prepare" ]]; then |
| 170 | die "${FUNCNAME}() can be used only in src_prepare() phase" |
205 | die "${FUNCNAME}() can be used only in src_prepare() phase" |
| 171 | fi |
206 | fi |
| 172 | |
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 | |
| 173 | # 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. |
| 174 | local ez_setup_existence="0" |
|
|
| 175 | [[ -d ez_setup || -f ez_setup.py ]] && ez_setup_existence="1" |
217 | [[ -d ez_setup || -f ez_setup.py ]] && ez_setup_existence="1" |
| 176 | rm -fr ez_setup* |
218 | rm -fr ez_setup* |
| 177 | if [[ "${ez_setup_existence}" == "1" ]]; then |
219 | if [[ "${ez_setup_existence}" == "1" ]]; then |
| 178 | echo "def use_setuptools(*args, **kwargs): pass" > ez_setup.py |
220 | echo "def use_setuptools(*args, **kwargs): pass" > ez_setup.py |
| 179 | fi |
221 | fi |
| 180 | |
222 | |
| 181 | # 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. |
| 182 | local distribute_setup_existence="0" |
|
|
| 183 | [[ -d distribute_setup || -f distribute_setup.py ]] && distribute_setup_existence="1" |
224 | [[ -d distribute_setup || -f distribute_setup.py ]] && distribute_setup_existence="1" |
| 184 | rm -fr distribute_setup* |
225 | rm -fr distribute_setup* |
| 185 | if [[ "${distribute_setup_existence}" == "1" ]]; then |
226 | if [[ "${distribute_setup_existence}" == "1" ]]; then |
| 186 | echo "def use_setuptools(*args, **kwargs): pass" > distribute_setup.py |
227 | echo "def use_setuptools(*args, **kwargs): pass" > distribute_setup.py |
| 187 | fi |
228 | fi |
| … | |
… | |
| 199 | distutils_src_compile() { |
240 | distutils_src_compile() { |
| 200 | if [[ "${EBUILD_PHASE}" != "compile" ]]; then |
241 | if [[ "${EBUILD_PHASE}" != "compile" ]]; then |
| 201 | die "${FUNCNAME}() can be used only in src_compile() phase" |
242 | die "${FUNCNAME}() can be used only in src_compile() phase" |
| 202 | fi |
243 | fi |
| 203 | |
244 | |
|
|
245 | _python_check_python_pkg_setup_execution |
| 204 | _python_set_color_variables |
246 | _python_set_color_variables |
|
|
247 | |
|
|
248 | local setup_file |
| 205 | |
249 | |
| 206 | if _python_package_supporting_installation_for_multiple_python_abis; then |
250 | if _python_package_supporting_installation_for_multiple_python_abis; then |
| 207 | distutils_building() { |
251 | distutils_building() { |
| 208 | _distutils_hook pre |
252 | _distutils_hook pre |
| 209 | |
253 | |
| 210 | local setup_file |
254 | _distutils_prepare_global_options |
|
|
255 | |
| 211 | 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 | |
| 212 | 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} |
| 213 | "$(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}" |
| 214 | done |
263 | done |
| 215 | |
264 | |
| 216 | _distutils_hook post |
265 | _distutils_hook post |
| 217 | } |
266 | } |
| 218 | 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 |
| 219 | else |
269 | else |
| 220 | local setup_file |
270 | _distutils_prepare_global_options |
|
|
271 | |
| 221 | 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 | |
| 222 | echo ${_BOLD}"$(PYTHON)" "${setup_file}" "${DISTUTILS_GLOBAL_OPTIONS[@]}" build "$@"${_NORMAL} |
275 | echo ${_BOLD}"$(PYTHON)" "${setup_file#*|}" "${_DISTUTILS_GLOBAL_OPTIONS[@]}" build "$@"${_NORMAL} |
| 223 | "$(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}" |
| 224 | done |
279 | done |
| 225 | fi |
280 | fi |
| 226 | } |
281 | } |
| 227 | |
282 | |
| 228 | _distutils_src_test_hook() { |
283 | _distutils_src_test_hook() { |
| … | |
… | |
| 255 | distutils_src_test() { |
310 | distutils_src_test() { |
| 256 | if [[ "${EBUILD_PHASE}" != "test" ]]; then |
311 | if [[ "${EBUILD_PHASE}" != "test" ]]; then |
| 257 | die "${FUNCNAME}() can be used only in src_test() phase" |
312 | die "${FUNCNAME}() can be used only in src_test() phase" |
| 258 | fi |
313 | fi |
| 259 | |
314 | |
|
|
315 | _python_check_python_pkg_setup_execution |
| 260 | _python_set_color_variables |
316 | _python_set_color_variables |
|
|
317 | |
|
|
318 | local arguments setup_file |
| 261 | |
319 | |
| 262 | if [[ "${DISTUTILS_SRC_TEST}" == "setup.py" ]]; then |
320 | if [[ "${DISTUTILS_SRC_TEST}" == "setup.py" ]]; then |
| 263 | if _python_package_supporting_installation_for_multiple_python_abis; then |
321 | if _python_package_supporting_installation_for_multiple_python_abis; then |
| 264 | distutils_testing() { |
322 | distutils_testing() { |
| 265 | _distutils_hook pre |
323 | _distutils_hook pre |
| 266 | |
324 | |
| 267 | local setup_file |
325 | _distutils_prepare_global_options |
|
|
326 | |
| 268 | 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 | |
| 269 | 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} |
| 270 | 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}" |
| 271 | done |
334 | done |
| 272 | |
335 | |
| 273 | _distutils_hook post |
336 | _distutils_hook post |
| 274 | } |
337 | } |
| 275 | 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 |
| 276 | else |
340 | else |
| 277 | local setup_file |
341 | _distutils_prepare_global_options |
|
|
342 | |
| 278 | 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 | |
| 279 | 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} |
| 280 | 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}" |
| 281 | done |
350 | done |
| 282 | fi |
351 | fi |
| 283 | elif [[ "${DISTUTILS_SRC_TEST}" == "nosetests" ]]; then |
352 | elif [[ "${DISTUTILS_SRC_TEST}" == "nosetests" ]]; then |
| 284 | _distutils_src_test_hook nosetests |
353 | _distutils_src_test_hook nosetests |
| 285 | |
354 | |
| … | |
… | |
| 288 | _distutils_src_test_hook py.test |
357 | _distutils_src_test_hook py.test |
| 289 | |
358 | |
| 290 | 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} -- "$@" |
| 291 | # trial requires an argument, which is usually equal to "${PN}". |
360 | # trial requires an argument, which is usually equal to "${PN}". |
| 292 | elif [[ "${DISTUTILS_SRC_TEST}" =~ ^trial(\ .*)?$ ]]; then |
361 | elif [[ "${DISTUTILS_SRC_TEST}" =~ ^trial(\ .*)?$ ]]; then |
| 293 | local trial_arguments |
|
|
| 294 | if [[ "${DISTUTILS_SRC_TEST}" == "trial "* ]]; then |
362 | if [[ "${DISTUTILS_SRC_TEST}" == "trial "* ]]; then |
| 295 | trial_arguments="${DISTUTILS_SRC_TEST#trial }" |
363 | arguments="${DISTUTILS_SRC_TEST#trial }" |
| 296 | else |
364 | else |
| 297 | trial_arguments="${PN}" |
365 | arguments="${PN}" |
| 298 | fi |
366 | fi |
| 299 | |
367 | |
| 300 | _distutils_src_test_hook trial |
368 | _distutils_src_test_hook trial |
| 301 | |
369 | |
| 302 | 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} "$@" |
| 303 | else |
371 | else |
| 304 | die "'DISTUTILS_SRC_TEST' variable has unsupported value '${DISTUTILS_SRC_TEST}'" |
372 | die "'DISTUTILS_SRC_TEST' variable has unsupported value '${DISTUTILS_SRC_TEST}'" |
| 305 | fi |
373 | fi |
| 306 | } |
374 | } |
| 307 | |
375 | |
| … | |
… | |
| 309 | # @DESCRIPTION: |
377 | # @DESCRIPTION: |
| 310 | # The distutils src_install function. This function is exported. |
378 | # The distutils src_install function. This function is exported. |
| 311 | # 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 |
| 312 | # 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. |
| 313 | # It also installs some standard documentation files (AUTHORS, Change*, CHANGELOG, CONTRIBUTORS, |
381 | # It also installs some standard documentation files (AUTHORS, Change*, CHANGELOG, CONTRIBUTORS, |
| 314 | # KNOWN_BUGS, MAINTAINERS, MANIFEST*, NEWS, PKG-INFO, README*, TODO). |
382 | # KNOWN_BUGS, MAINTAINERS, NEWS, README*, TODO). |
| 315 | distutils_src_install() { |
383 | distutils_src_install() { |
| 316 | if [[ "${EBUILD_PHASE}" != "install" ]]; then |
384 | if [[ "${EBUILD_PHASE}" != "install" ]]; then |
| 317 | die "${FUNCNAME}() can be used only in src_install() phase" |
385 | die "${FUNCNAME}() can be used only in src_install() phase" |
| 318 | fi |
386 | fi |
| 319 | |
387 | |
|
|
388 | _python_check_python_pkg_setup_execution |
| 320 | _python_initialize_prefix_variables |
389 | _python_initialize_prefix_variables |
| 321 | _python_set_color_variables |
390 | _python_set_color_variables |
|
|
391 | |
|
|
392 | local default_docs doc line nspkg_pth_file nspkg_pth_files=() setup_file |
| 322 | |
393 | |
| 323 | if _python_package_supporting_installation_for_multiple_python_abis; then |
394 | if _python_package_supporting_installation_for_multiple_python_abis; then |
| 324 | distutils_installation() { |
395 | distutils_installation() { |
| 325 | _distutils_hook pre |
396 | _distutils_hook pre |
| 326 | |
397 | |
| 327 | local setup_file |
398 | _distutils_prepare_global_options |
|
|
399 | |
| 328 | 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 | |
| 329 | echo ${_BOLD}"$(PYTHON)" "${setup_file}" "${DISTUTILS_GLOBAL_OPTIONS[@]}" $([[ -z "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]] && echo build -b "$(_distutils_get_build_dir)") install --no-compile --root="${T}/images/${PYTHON_ABI}" "$@"${_NORMAL} |
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} |
| 330 | "$(PYTHON)" "${setup_file}" "${DISTUTILS_GLOBAL_OPTIONS[@]}" $([[ -z "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]] && echo build -b "$(_distutils_get_build_dir)") install --no-compile --root="${T}/images/${PYTHON_ABI}" "$@" || return "$?" |
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}" |
| 331 | done |
407 | done |
| 332 | |
408 | |
| 333 | _distutils_hook post |
409 | _distutils_hook post |
| 334 | } |
410 | } |
| 335 | 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 |
| 336 | |
413 | |
| 337 | python_merge_intermediate_installation_images "${T}/images" |
414 | python_merge_intermediate_installation_images "${T}/images" |
| 338 | else |
415 | else |
| 339 | # Mark the package to be rebuilt after a Python upgrade. |
416 | # Mark the package to be rebuilt after a Python upgrade. |
| 340 | python_need_rebuild |
417 | python_need_rebuild |
| 341 | |
418 | |
| 342 | local setup_file |
419 | _distutils_prepare_global_options |
|
|
420 | |
| 343 | 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 | |
| 344 | 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} |
| 345 | "$(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}" |
| 346 | 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 |
| 347 | fi |
448 | fi |
| 348 | |
449 | |
| 349 | if [[ -e "${ED}usr/local" ]]; then |
450 | if [[ -e "${ED}usr/local" ]]; then |
| 350 | die "Illegal installation into /usr/local" |
451 | die "Illegal installation into /usr/local" |
| 351 | fi |
452 | fi |
| 352 | |
453 | |
| 353 | local default_docs |
|
|
| 354 | 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" |
| 355 | |
455 | |
| 356 | local doc |
|
|
| 357 | for doc in ${default_docs}; do |
456 | for doc in ${default_docs}; do |
| 358 | [[ -s "${doc}" ]] && dodoc "${doc}" |
457 | [[ -s "${doc}" ]] && dodoc "${doc}" |
| 359 | done |
458 | done |
| 360 | |
459 | |
|
|
460 | if has "${EAPI:-0}" 0 1 2 3; then |
| 361 | if [[ -n "${DOCS}" ]]; then |
461 | if [[ -n "${DOCS}" ]]; then |
| 362 | dodoc ${DOCS} || die "dodoc failed" |
462 | dodoc ${DOCS} || die "dodoc failed" |
| 363 | 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" |
| 364 | } |
471 | } |
| 365 | |
472 | |
| 366 | # @FUNCTION: distutils_pkg_postinst |
473 | # @FUNCTION: distutils_pkg_postinst |
| 367 | # @DESCRIPTION: |
474 | # @DESCRIPTION: |
| 368 | # The distutils pkg_postinst function. This function is exported. |
475 | # The distutils pkg_postinst function. This function is exported. |
| … | |
… | |
| 372 | distutils_pkg_postinst() { |
479 | distutils_pkg_postinst() { |
| 373 | if [[ "${EBUILD_PHASE}" != "postinst" ]]; then |
480 | if [[ "${EBUILD_PHASE}" != "postinst" ]]; then |
| 374 | die "${FUNCNAME}() can be used only in pkg_postinst() phase" |
481 | die "${FUNCNAME}() can be used only in pkg_postinst() phase" |
| 375 | fi |
482 | fi |
| 376 | |
483 | |
|
|
484 | _python_check_python_pkg_setup_execution |
| 377 | _python_initialize_prefix_variables |
485 | _python_initialize_prefix_variables |
| 378 | |
486 | |
|
|
487 | if [[ -z "${DISTUTILS_SRC_INSTALL_EXECUTED}" ]]; then |
|
|
488 | die "${FUNCNAME}() called illegally" |
|
|
489 | fi |
|
|
490 | |
| 379 | local pylibdir pymod |
491 | local pylibdir pymod |
|
|
492 | |
|
|
493 | if [[ "$#" -ne 0 ]]; then |
|
|
494 | die "${FUNCNAME}() does not accept arguments" |
|
|
495 | fi |
|
|
496 | |
| 380 | if [[ -z "$(declare -p PYTHON_MODNAME 2> /dev/null)" ]]; then |
497 | if [[ -z "$(declare -p PYTHON_MODNAME 2> /dev/null)" ]]; then |
| 381 | 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 |
| 382 | if [[ -d "${pylibdir}/site-packages/${PN}" ]]; then |
499 | if [[ -d "${pylibdir}/site-packages/${PN}" ]]; then |
| 383 | PYTHON_MODNAME="${PN}" |
500 | PYTHON_MODNAME="${PN}" |
| 384 | fi |
501 | fi |
| … | |
… | |
| 405 | distutils_pkg_postrm() { |
522 | distutils_pkg_postrm() { |
| 406 | if [[ "${EBUILD_PHASE}" != "postrm" ]]; then |
523 | if [[ "${EBUILD_PHASE}" != "postrm" ]]; then |
| 407 | die "${FUNCNAME}() can be used only in pkg_postrm() phase" |
524 | die "${FUNCNAME}() can be used only in pkg_postrm() phase" |
| 408 | fi |
525 | fi |
| 409 | |
526 | |
|
|
527 | _python_check_python_pkg_setup_execution |
| 410 | _python_initialize_prefix_variables |
528 | _python_initialize_prefix_variables |
| 411 | |
529 | |
|
|
530 | if [[ -z "${DISTUTILS_SRC_INSTALL_EXECUTED}" ]]; then |
|
|
531 | die "${FUNCNAME}() called illegally" |
|
|
532 | fi |
|
|
533 | |
| 412 | local pylibdir pymod |
534 | local pylibdir pymod |
|
|
535 | |
|
|
536 | if [[ "$#" -ne 0 ]]; then |
|
|
537 | die "${FUNCNAME}() does not accept arguments" |
|
|
538 | fi |
|
|
539 | |
| 413 | if [[ -z "$(declare -p PYTHON_MODNAME 2> /dev/null)" ]]; then |
540 | if [[ -z "$(declare -p PYTHON_MODNAME 2> /dev/null)" ]]; then |
| 414 | 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 |
| 415 | if [[ -d "${pylibdir}/site-packages/${PN}" ]]; then |
542 | if [[ -d "${pylibdir}/site-packages/${PN}" ]]; then |
| 416 | PYTHON_MODNAME="${PN}" |
543 | PYTHON_MODNAME="${PN}" |
| 417 | fi |
544 | fi |
| … | |
… | |
| 431 | done |
558 | done |
| 432 | fi |
559 | fi |
| 433 | fi |
560 | fi |
| 434 | } |
561 | } |
| 435 | |
562 | |
| 436 | # Scheduled for deletion on 2011-01-01. |
563 | # @FUNCTION: distutils_get_intermediate_installation_image |
| 437 | distutils_python_version() { |
564 | # @DESCRIPTION: |
| 438 | eerror "Use PYTHON() instead of python variable. Use python_get_*() instead of PYVER* variables." |
565 | # Print path to intermediate installation image. |
| 439 | die "${FUNCNAME}() is banned" |
566 | # |
| 440 | } |
567 | # This function can be used only in distutils_src_install_pre_hook() and distutils_src_install_post_hook(). |
|
|
568 | distutils_get_intermediate_installation_image() { |
|
|
569 | if [[ "${EBUILD_PHASE}" != "install" ]]; then |
|
|
570 | die "${FUNCNAME}() can be used only in src_install() phase" |
|
|
571 | fi |
| 441 | |
572 | |
| 442 | # Scheduled for deletion on 2011-01-01. |
573 | if ! _python_package_supporting_installation_for_multiple_python_abis; then |
| 443 | distutils_python_tkinter() { |
574 | die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs" |
| 444 | eerror "Use PYTHON_USE_WITH=\"xml\" and python_pkg_setup() instead of ${FUNCNAME}()." |
575 | fi |
| 445 | 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}" |
| 446 | } |
588 | } |