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

Contents of /eclass/distutils.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.80 - (hide annotations) (download)
Tue Apr 12 18:49:03 2011 UTC (3 years, 5 months ago) by arfrever
Branch: MAIN
Changes since 1.79: +201 -59 lines
Unconditionally print deprecation warnings for usage of distutils.eclass in old EAPIs.
Support specifying current working directory in DISTUTILS_SETUP_FILES.
Support specifying Python ABI pattern in DISTUTILS_GLOBAL_OPTIONS in EAPI >=4.
Ban DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS.
Add sanity checks in some functions.
Disable installation of useless files in distutils_src_install().
Handle *-nspkg.pth files in distutils_src_install().
Support EAPI="4" in handling of DOCS in distutils_src_install.
Delete distutils_python_version() and distutils_python_tkinter().
Add distutils_get_intermediate_installation_image().

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

  ViewVC Help
Powered by ViewVC 1.1.20