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

Contents of /eclass/distutils.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.85 - (show annotations) (download)
Thu Nov 20 15:32:09 2014 UTC (3 months, 1 week ago) by mgorny
Branch: MAIN
CVS Tags: HEAD
Changes since 1.84: +4 -2 lines
Deprecate the few eclasses.

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

  ViewVC Help
Powered by ViewVC 1.1.20