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

Contents of /eclass/distutils.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.81 - (hide annotations) (download)
Sun Jan 1 05:02:27 2012 UTC (2 years, 11 months ago) by floppym
Branch: MAIN
Changes since 1.80: +7 -3 lines
Avoid including python.eclass more than once.

1 floppym 1.81 # Copyright 1999-2012 Gentoo Foundation
2 vapier 1.4 # Distributed under the terms of the GNU General Public License v2
3 floppym 1.81 # $Header: /var/cvsroot/gentoo-x86/eclass/distutils.eclass,v 1.80 2011/04/12 18:49:03 arfrever Exp $
4 dev-zero 1.46
5     # @ECLASS: distutils.eclass
6     # @MAINTAINER:
7 arfrever 1.70 # Gentoo Python Project <python@gentoo.org>
8     # @BLURB: Eclass for packages with build systems using Distutils
9 dev-zero 1.46 # @DESCRIPTION:
10 arfrever 1.73 # The distutils eclass defines phase functions for packages with build systems using Distutils.
11 jnelson 1.1
12 floppym 1.81 if [[ -z "${_PYTHON_ECLASS_INHERITED}" ]]; then
13     inherit python
14     fi
15    
16     inherit multilib
17 liquidx 1.16
18 pva 1.55 case "${EAPI:-0}" in
19     0|1)
20     EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_postinst pkg_postrm
21     ;;
22     *)
23 arfrever 1.73 EXPORT_FUNCTIONS src_prepare src_compile src_install pkg_postinst pkg_postrm
24 pva 1.55 ;;
25     esac
26    
27 arfrever 1.74 if [[ -z "$(declare -p PYTHON_DEPEND 2> /dev/null)" ]]; then
28 arfrever 1.73 DEPEND="dev-lang/python"
29 arfrever 1.62 RDEPEND="${DEPEND}"
30     fi
31 arfrever 1.68
32 arfrever 1.79 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    
48 arfrever 1.74 # 'python' variable is deprecated. Use PYTHON() instead.
49 arfrever 1.73 if has "${EAPI:-0}" 0 1 2 && [[ -z "${SUPPORT_PYTHON_ABIS}" ]]; then
50 arfrever 1.68 python="python"
51     else
52     python="die"
53     fi
54 arfrever 1.60
55 arfrever 1.61 # @ECLASS-VARIABLE: DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES
56     # @DESCRIPTION:
57     # Set this to use separate source directories for each enabled version of Python.
58    
59 arfrever 1.76 # @ECLASS-VARIABLE: DISTUTILS_SETUP_FILES
60     # @DESCRIPTION:
61 arfrever 1.80 # Array of paths to setup files.
62     # Syntax:
63     # [current_working_directory|]path_to_setup_file
64 arfrever 1.76
65 arfrever 1.60 # @ECLASS-VARIABLE: DISTUTILS_GLOBAL_OPTIONS
66 dev-zero 1.46 # @DESCRIPTION:
67 arfrever 1.80 # 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
72 jnelson 1.1
73 arfrever 1.70 # @ECLASS-VARIABLE: DISTUTILS_SRC_TEST
74     # @DESCRIPTION:
75     # Type of test command used by distutils_src_test().
76     # IUSE and DEPEND are automatically adjusted, unless DISTUTILS_DISABLE_TEST_DEPENDENCY is set.
77     # Valid values:
78     # setup.py
79     # nosetests
80     # py.test
81     # trial [arguments]
82    
83     # @ECLASS-VARIABLE: DISTUTILS_DISABLE_TEST_DEPENDENCY
84     # @DESCRIPTION:
85     # Disable modification of IUSE and DEPEND caused by setting of DISTUTILS_SRC_TEST.
86    
87     if [[ -n "${DISTUTILS_SRC_TEST}" && ! "${DISTUTILS_SRC_TEST}" =~ ^(setup\.py|nosetests|py\.test|trial(\ .*)?)$ ]]; then
88     die "'DISTUTILS_SRC_TEST' variable has unsupported value '${DISTUTILS_SRC_TEST}'"
89     fi
90    
91     if [[ -z "${DISTUTILS_DISABLE_TEST_DEPENDENCY}" ]]; then
92     if [[ "${DISTUTILS_SRC_TEST}" == "nosetests" ]]; then
93     IUSE="test"
94     DEPEND+="${DEPEND:+ }test? ( dev-python/nose )"
95     elif [[ "${DISTUTILS_SRC_TEST}" == "py.test" ]]; then
96     IUSE="test"
97 arfrever 1.78 DEPEND+="${DEPEND:+ }test? ( dev-python/pytest )"
98 arfrever 1.70 # trial requires an argument, which is usually equal to "${PN}".
99     elif [[ "${DISTUTILS_SRC_TEST}" =~ ^trial(\ .*)?$ ]]; then
100     IUSE="test"
101     DEPEND+="${DEPEND:+ }test? ( dev-python/twisted )"
102     fi
103     fi
104    
105     if [[ -n "${DISTUTILS_SRC_TEST}" ]]; then
106     EXPORT_FUNCTIONS src_test
107     fi
108    
109 arfrever 1.80 # Scheduled for deletion on 2011-06-01.
110 arfrever 1.79 if [[ -n "${DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS}" ]]; then
111 arfrever 1.80 eerror "Use PYTHON_NONVERSIONED_EXECUTABLES=(\".*\") instead of DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS variable."
112     die "DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS variable is banned"
113 arfrever 1.79 fi
114 arfrever 1.73
115 dev-zero 1.46 # @ECLASS-VARIABLE: DOCS
116     # @DESCRIPTION:
117 arfrever 1.70 # Additional documentation files installed by distutils_src_install().
118    
119     _distutils_get_build_dir() {
120 arfrever 1.77 if _python_package_supporting_installation_for_multiple_python_abis && [[ -z "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]]; then
121 arfrever 1.70 echo "build-${PYTHON_ABI}"
122     else
123     echo "build"
124     fi
125     }
126    
127     _distutils_get_PYTHONPATH() {
128 arfrever 1.77 if _python_package_supporting_installation_for_multiple_python_abis && [[ -z "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]]; then
129 arfrever 1.70 ls -d build-${PYTHON_ABI}/lib* 2> /dev/null
130     else
131     ls -d build/lib* 2> /dev/null
132     fi
133     }
134 dev-zero 1.46
135 arfrever 1.67 _distutils_hook() {
136     if [[ "$#" -ne 1 ]]; then
137     die "${FUNCNAME}() requires 1 argument"
138     fi
139     if [[ "$(type -t "distutils_src_${EBUILD_PHASE}_$1_hook")" == "function" ]]; then
140     "distutils_src_${EBUILD_PHASE}_$1_hook"
141     fi
142     }
143    
144 arfrever 1.80 _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"
183     fi
184     }
185    
186 dev-zero 1.46 # @FUNCTION: distutils_src_unpack
187     # @DESCRIPTION:
188 arfrever 1.70 # The distutils src_unpack function. This function is exported.
189 lucass 1.41 distutils_src_unpack() {
190 arfrever 1.73 if ! has "${EAPI:-0}" 0 1; then
191     die "${FUNCNAME}() cannot be used in this EAPI"
192     fi
193    
194 arfrever 1.59 if [[ "${EBUILD_PHASE}" != "unpack" ]]; then
195     die "${FUNCNAME}() can be used only in src_unpack() phase"
196     fi
197    
198 lucass 1.41 unpack ${A}
199     cd "${S}"
200    
201 arfrever 1.73 distutils_src_prepare
202 pva 1.55 }
203    
204     # @FUNCTION: distutils_src_prepare
205     # @DESCRIPTION:
206 arfrever 1.70 # The distutils src_prepare function. This function is exported.
207 pva 1.55 distutils_src_prepare() {
208 arfrever 1.59 if ! has "${EAPI:-0}" 0 1 && [[ "${EBUILD_PHASE}" != "prepare" ]]; then
209     die "${FUNCNAME}() can be used only in src_prepare() phase"
210     fi
211    
212 arfrever 1.80 _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    
220 arfrever 1.70 # Delete ez_setup files to prevent packages from installing Setuptools on their own.
221 arfrever 1.63 [[ -d ez_setup || -f ez_setup.py ]] && ez_setup_existence="1"
222 arfrever 1.61 rm -fr ez_setup*
223 arfrever 1.63 if [[ "${ez_setup_existence}" == "1" ]]; then
224 arfrever 1.61 echo "def use_setuptools(*args, **kwargs): pass" > ez_setup.py
225     fi
226    
227 arfrever 1.70 # Delete distribute_setup files to prevent packages from installing Distribute on their own.
228 arfrever 1.66 [[ -d distribute_setup || -f distribute_setup.py ]] && distribute_setup_existence="1"
229     rm -fr distribute_setup*
230     if [[ "${distribute_setup_existence}" == "1" ]]; then
231     echo "def use_setuptools(*args, **kwargs): pass" > distribute_setup.py
232     fi
233    
234 arfrever 1.61 if [[ -n "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]]; then
235     python_copy_sources
236     fi
237 lucass 1.41 }
238    
239 dev-zero 1.46 # @FUNCTION: distutils_src_compile
240     # @DESCRIPTION:
241 arfrever 1.70 # The distutils src_compile function. This function is exported.
242     # In ebuilds of packages supporting installation for multiple versions of Python, this function
243     # calls distutils_src_compile_pre_hook() and distutils_src_compile_post_hook(), if they are defined.
244 jnelson 1.1 distutils_src_compile() {
245 arfrever 1.59 if [[ "${EBUILD_PHASE}" != "compile" ]]; then
246     die "${FUNCNAME}() can be used only in src_compile() phase"
247     fi
248    
249 arfrever 1.80 _python_check_python_pkg_setup_execution
250 arfrever 1.73 _python_set_color_variables
251    
252 arfrever 1.80 local setup_file
253    
254 arfrever 1.77 if _python_package_supporting_installation_for_multiple_python_abis; then
255 arfrever 1.70 distutils_building() {
256     _distutils_hook pre
257    
258 arfrever 1.80 _distutils_prepare_global_options
259    
260 arfrever 1.76 for setup_file in "${DISTUTILS_SETUP_FILES[@]-setup.py}"; do
261 arfrever 1.80 _distutils_prepare_current_working_directory "${setup_file}"
262    
263     echo ${_BOLD}"$(PYTHON)" "${setup_file#*|}" "${_DISTUTILS_GLOBAL_OPTIONS[@]}" build -b "$(_distutils_get_build_dir)" "$@"${_NORMAL}
264     "$(PYTHON)" "${setup_file#*|}" "${_DISTUTILS_GLOBAL_OPTIONS[@]}" build -b "$(_distutils_get_build_dir)" "$@" || return "$?"
265    
266     _distutils_restore_current_working_directory "${setup_file}"
267 arfrever 1.76 done
268 arfrever 1.70
269     _distutils_hook post
270     }
271     python_execute_function ${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES:+-s} distutils_building "$@"
272 arfrever 1.80 unset -f distutils_building
273 arfrever 1.70 else
274 arfrever 1.80 _distutils_prepare_global_options
275    
276 arfrever 1.76 for setup_file in "${DISTUTILS_SETUP_FILES[@]-setup.py}"; do
277 arfrever 1.80 _distutils_prepare_current_working_directory "${setup_file}"
278    
279     echo ${_BOLD}"$(PYTHON)" "${setup_file#*|}" "${_DISTUTILS_GLOBAL_OPTIONS[@]}" build "$@"${_NORMAL}
280     "$(PYTHON)" "${setup_file#*|}" "${_DISTUTILS_GLOBAL_OPTIONS[@]}" build "$@" || die "Building failed"
281    
282     _distutils_restore_current_working_directory "${setup_file}"
283 arfrever 1.76 done
284 arfrever 1.70 fi
285     }
286 arfrever 1.67
287 arfrever 1.74 _distutils_src_test_hook() {
288     if [[ "$#" -ne 1 ]]; then
289     die "${FUNCNAME}() requires 1 arguments"
290     fi
291    
292 arfrever 1.77 if ! _python_package_supporting_installation_for_multiple_python_abis; then
293 arfrever 1.74 return
294     fi
295    
296     if [[ "$(type -t "distutils_src_test_pre_hook")" == "function" ]]; then
297     eval "python_execute_$1_pre_hook() {
298     distutils_src_test_pre_hook
299     }"
300     fi
301    
302     if [[ "$(type -t "distutils_src_test_post_hook")" == "function" ]]; then
303     eval "python_execute_$1_post_hook() {
304     distutils_src_test_post_hook
305     }"
306     fi
307     }
308    
309 arfrever 1.70 # @FUNCTION: distutils_src_test
310     # @DESCRIPTION:
311     # The distutils src_test function. This function is exported, when DISTUTILS_SRC_TEST variable is set.
312 arfrever 1.74 # In ebuilds of packages supporting installation for multiple versions of Python, this function
313     # calls distutils_src_test_pre_hook() and distutils_src_test_post_hook(), if they are defined.
314 arfrever 1.70 distutils_src_test() {
315 arfrever 1.75 if [[ "${EBUILD_PHASE}" != "test" ]]; then
316     die "${FUNCNAME}() can be used only in src_test() phase"
317     fi
318    
319 arfrever 1.80 _python_check_python_pkg_setup_execution
320 arfrever 1.73 _python_set_color_variables
321    
322 arfrever 1.80 local arguments setup_file
323    
324 arfrever 1.70 if [[ "${DISTUTILS_SRC_TEST}" == "setup.py" ]]; then
325 arfrever 1.77 if _python_package_supporting_installation_for_multiple_python_abis; then
326 arfrever 1.70 distutils_testing() {
327 arfrever 1.74 _distutils_hook pre
328    
329 arfrever 1.80 _distutils_prepare_global_options
330    
331 arfrever 1.76 for setup_file in "${DISTUTILS_SETUP_FILES[@]-setup.py}"; do
332 arfrever 1.80 _distutils_prepare_current_working_directory "${setup_file}"
333    
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}
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 arfrever 1.76 done
339 arfrever 1.74
340     _distutils_hook post
341 arfrever 1.61 }
342 arfrever 1.70 python_execute_function ${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES:+-s} distutils_testing "$@"
343 arfrever 1.80 unset -f distutils_testing
344 arfrever 1.70 else
345 arfrever 1.80 _distutils_prepare_global_options
346    
347 arfrever 1.76 for setup_file in "${DISTUTILS_SETUP_FILES[@]-setup.py}"; do
348 arfrever 1.80 _distutils_prepare_current_working_directory "${setup_file}"
349    
350     echo ${_BOLD}PYTHONPATH="$(_distutils_get_PYTHONPATH)" "$(PYTHON)" "${setup_file#*|}" "${_DISTUTILS_GLOBAL_OPTIONS[@]}" test "$@"${_NORMAL}
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 arfrever 1.76 done
355 arfrever 1.70 fi
356     elif [[ "${DISTUTILS_SRC_TEST}" == "nosetests" ]]; then
357 arfrever 1.74 _distutils_src_test_hook nosetests
358    
359 arfrever 1.70 python_execute_nosetests -P '$(_distutils_get_PYTHONPATH)' ${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES:+-s} -- "$@"
360     elif [[ "${DISTUTILS_SRC_TEST}" == "py.test" ]]; then
361 arfrever 1.74 _distutils_src_test_hook py.test
362    
363 arfrever 1.70 python_execute_py.test -P '$(_distutils_get_PYTHONPATH)' ${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES:+-s} -- "$@"
364     # trial requires an argument, which is usually equal to "${PN}".
365     elif [[ "${DISTUTILS_SRC_TEST}" =~ ^trial(\ .*)?$ ]]; then
366     if [[ "${DISTUTILS_SRC_TEST}" == "trial "* ]]; then
367 arfrever 1.80 arguments="${DISTUTILS_SRC_TEST#trial }"
368 arfrever 1.61 else
369 arfrever 1.80 arguments="${PN}"
370 arfrever 1.70 fi
371 arfrever 1.67
372 arfrever 1.74 _distutils_src_test_hook trial
373    
374 arfrever 1.80 python_execute_trial -P '$(_distutils_get_PYTHONPATH)' ${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES:+-s} -- ${arguments} "$@"
375 arfrever 1.56 else
376 arfrever 1.70 die "'DISTUTILS_SRC_TEST' variable has unsupported value '${DISTUTILS_SRC_TEST}'"
377 arfrever 1.56 fi
378 jnelson 1.1 }
379    
380 dev-zero 1.46 # @FUNCTION: distutils_src_install
381     # @DESCRIPTION:
382 arfrever 1.70 # The distutils src_install function. This function is exported.
383     # In ebuilds of packages supporting installation for multiple versions of Python, this function
384     # calls distutils_src_install_pre_hook() and distutils_src_install_post_hook(), if they are defined.
385     # It also installs some standard documentation files (AUTHORS, Change*, CHANGELOG, CONTRIBUTORS,
386 arfrever 1.80 # KNOWN_BUGS, MAINTAINERS, NEWS, README*, TODO).
387 jnelson 1.1 distutils_src_install() {
388 arfrever 1.59 if [[ "${EBUILD_PHASE}" != "install" ]]; then
389     die "${FUNCNAME}() can be used only in src_install() phase"
390     fi
391    
392 arfrever 1.80 _python_check_python_pkg_setup_execution
393 arfrever 1.74 _python_initialize_prefix_variables
394 arfrever 1.73 _python_set_color_variables
395    
396 arfrever 1.80 local default_docs doc line nspkg_pth_file nspkg_pth_files=() setup_file
397    
398 arfrever 1.77 if _python_package_supporting_installation_for_multiple_python_abis; then
399 arfrever 1.70 distutils_installation() {
400     _distutils_hook pre
401 arfrever 1.61
402 arfrever 1.80 _distutils_prepare_global_options
403    
404 arfrever 1.76 for setup_file in "${DISTUTILS_SETUP_FILES[@]-setup.py}"; do
405 arfrever 1.80 _distutils_prepare_current_working_directory "${setup_file}"
406    
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}
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 "$?"
409    
410     _distutils_restore_current_working_directory "${setup_file}"
411 arfrever 1.76 done
412 arfrever 1.67
413 arfrever 1.70 _distutils_hook post
414     }
415     python_execute_function ${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES:+-s} distutils_installation "$@"
416 arfrever 1.80 unset -f distutils_installation
417 arfrever 1.67
418 arfrever 1.79 python_merge_intermediate_installation_images "${T}/images"
419 liquidx 1.18 else
420 arfrever 1.69 # Mark the package to be rebuilt after a Python upgrade.
421     python_need_rebuild
422    
423 arfrever 1.80 _distutils_prepare_global_options
424    
425 arfrever 1.76 for setup_file in "${DISTUTILS_SETUP_FILES[@]-setup.py}"; do
426 arfrever 1.80 _distutils_prepare_current_working_directory "${setup_file}"
427    
428     echo ${_BOLD}"$(PYTHON)" "${setup_file#*|}" "${_DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@"${_NORMAL}
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 arfrever 1.76 done
451 arfrever 1.80 einfo
452 swegener 1.28 fi
453 lanius 1.20
454 arfrever 1.74 if [[ -e "${ED}usr/local" ]]; then
455 arfrever 1.64 die "Illegal installation into /usr/local"
456     fi
457    
458 arfrever 1.80 default_docs="AUTHORS Change* CHANGELOG CONTRIBUTORS KNOWN_BUGS MAINTAINERS NEWS README* TODO"
459 lanius 1.20
460 arfrever 1.62 for doc in ${default_docs}; do
461     [[ -s "${doc}" ]] && dodoc "${doc}"
462 lanius 1.20 done
463    
464 arfrever 1.80 if has "${EAPI:-0}" 0 1 2 3; then
465     if [[ -n "${DOCS}" ]]; then
466     dodoc ${DOCS} || die "dodoc failed"
467     fi
468     else
469     if [[ -n "${DOCS}" ]]; then
470     dodoc -r ${DOCS} || die "dodoc failed"
471     fi
472 arfrever 1.62 fi
473 arfrever 1.80
474     DISTUTILS_SRC_INSTALL_EXECUTED="1"
475 jnelson 1.1 }
476 kutsuya 1.6
477 arfrever 1.63 # @FUNCTION: distutils_pkg_postinst
478 dev-zero 1.46 # @DESCRIPTION:
479 arfrever 1.70 # The distutils pkg_postinst function. This function is exported.
480     # When PYTHON_MODNAME variable is set, then this function calls python_mod_optimize() with modules
481     # specified in PYTHON_MODNAME variable. Otherwise it calls python_mod_optimize() with module, whose
482     # name is equal to name of current package, if this module exists.
483 arfrever 1.63 distutils_pkg_postinst() {
484     if [[ "${EBUILD_PHASE}" != "postinst" ]]; then
485     die "${FUNCNAME}() can be used only in pkg_postinst() phase"
486 arfrever 1.59 fi
487    
488 arfrever 1.80 _python_check_python_pkg_setup_execution
489 arfrever 1.74 _python_initialize_prefix_variables
490    
491 arfrever 1.80 if [[ -z "${DISTUTILS_SRC_INSTALL_EXECUTED}" ]]; then
492     die "${FUNCNAME}() called illegally"
493     fi
494    
495 arfrever 1.56 local pylibdir pymod
496 arfrever 1.80
497     if [[ "$#" -ne 0 ]]; then
498     die "${FUNCNAME}() does not accept arguments"
499     fi
500    
501 arfrever 1.75 if [[ -z "$(declare -p PYTHON_MODNAME 2> /dev/null)" ]]; then
502 arfrever 1.77 for pylibdir in "${EROOT}"usr/$(get_libdir)/python* "${EROOT}"usr/share/jython-*/Lib; do
503 arfrever 1.56 if [[ -d "${pylibdir}/site-packages/${PN}" ]]; then
504     PYTHON_MODNAME="${PN}"
505 hawking 1.54 fi
506     done
507 hawking 1.49 fi
508 liquidx 1.19
509 arfrever 1.75 if [[ -n "${PYTHON_MODNAME}" ]]; then
510 arfrever 1.77 if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
511 arfrever 1.75 python_mod_optimize ${PYTHON_MODNAME}
512     else
513     for pymod in ${PYTHON_MODNAME}; do
514     python_mod_optimize "$(python_get_sitedir)/${pymod}"
515     done
516     fi
517 swegener 1.28 fi
518 liquidx 1.19 }
519    
520 arfrever 1.63 # @FUNCTION: distutils_pkg_postrm
521 dev-zero 1.46 # @DESCRIPTION:
522 arfrever 1.70 # The distutils pkg_postrm function. This function is exported.
523     # When PYTHON_MODNAME variable is set, then this function calls python_mod_cleanup() with modules
524     # specified in PYTHON_MODNAME variable. Otherwise it calls python_mod_cleanup() with module, whose
525     # name is equal to name of current package, if this module exists.
526 arfrever 1.63 distutils_pkg_postrm() {
527     if [[ "${EBUILD_PHASE}" != "postrm" ]]; then
528     die "${FUNCNAME}() can be used only in pkg_postrm() phase"
529 arfrever 1.59 fi
530    
531 arfrever 1.80 _python_check_python_pkg_setup_execution
532 arfrever 1.74 _python_initialize_prefix_variables
533    
534 arfrever 1.80 if [[ -z "${DISTUTILS_SRC_INSTALL_EXECUTED}" ]]; then
535     die "${FUNCNAME}() called illegally"
536     fi
537    
538 hawking 1.54 local pylibdir pymod
539 arfrever 1.80
540     if [[ "$#" -ne 0 ]]; then
541     die "${FUNCNAME}() does not accept arguments"
542     fi
543    
544 arfrever 1.75 if [[ -z "$(declare -p PYTHON_MODNAME 2> /dev/null)" ]]; then
545 arfrever 1.77 for pylibdir in "${EROOT}"usr/$(get_libdir)/python* "${EROOT}"usr/share/jython-*/Lib; do
546 arfrever 1.56 if [[ -d "${pylibdir}/site-packages/${PN}" ]]; then
547     PYTHON_MODNAME="${PN}"
548 hawking 1.54 fi
549     done
550 hawking 1.50 fi
551 swegener 1.28
552 arfrever 1.63 if [[ -n "${PYTHON_MODNAME}" ]]; then
553 arfrever 1.77 if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
554 arfrever 1.65 python_mod_cleanup ${PYTHON_MODNAME}
555     else
556     for pymod in ${PYTHON_MODNAME}; do
557 arfrever 1.74 for pylibdir in "${EROOT}"usr/$(get_libdir)/python*; do
558 arfrever 1.63 if [[ -d "${pylibdir}/site-packages/${pymod}" ]]; then
559 arfrever 1.74 python_mod_cleanup "${pylibdir#${EROOT%/}}/site-packages/${pymod}"
560 arfrever 1.63 fi
561     done
562 arfrever 1.65 done
563     fi
564 swegener 1.28 fi
565 liquidx 1.19 }
566    
567 arfrever 1.80 # @FUNCTION: distutils_get_intermediate_installation_image
568     # @DESCRIPTION:
569     # Print path to intermediate installation image.
570     #
571     # This function can be used only in distutils_src_install_pre_hook() and distutils_src_install_post_hook().
572     distutils_get_intermediate_installation_image() {
573     if [[ "${EBUILD_PHASE}" != "install" ]]; then
574     die "${FUNCNAME}() can be used only in src_install() phase"
575     fi
576    
577     if ! _python_package_supporting_installation_for_multiple_python_abis; then
578     die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
579     fi
580    
581     _python_check_python_pkg_setup_execution
582    
583     if [[ ! "${FUNCNAME[1]}" =~ ^distutils_src_install_(pre|post)_hook$ ]]; then
584     die "${FUNCNAME}() can be used only in distutils_src_install_pre_hook() and distutils_src_install_post_hook()"
585     fi
586    
587     if [[ "$#" -ne 0 ]]; then
588     die "${FUNCNAME}() does not accept arguments"
589     fi
590 liquidx 1.12
591 arfrever 1.80 echo "${T}/images/${PYTHON_ABI}"
592 vapier 1.8 }

  ViewVC Help
Powered by ViewVC 1.1.20