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

Contents of /eclass/python.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.76 - (hide annotations) (download)
Fri Oct 2 23:09:08 2009 UTC (4 years, 11 months ago) by arfrever
Branch: MAIN
Changes since 1.75: +18 -3 lines
Add the check to ensure that Python wrapper is configured to use the same version of Python as /usr/bin/python2 or /usr/bin/python3. Add workaround in python_pkg_setup() for older versions of Portage not supporting Python 3.

1 arfrever 1.56 # Copyright 1999-2009 Gentoo Foundation
2 liquidx 1.1 # Distributed under the terms of the GNU General Public License v2
3 arfrever 1.76 # $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.75 2009/10/02 17:32:23 arfrever Exp $
4 liquidx 1.1
5 dev-zero 1.33 # @ECLASS: python.eclass
6     # @MAINTAINER:
7     # python@gentoo.org
8 arfrever 1.74 # @BLURB: A utility eclass that should be inherited by anything that deals with Python or Python modules.
9 dev-zero 1.33 # @DESCRIPTION:
10 arfrever 1.66 # Some useful functions for dealing with Python.
11 liquidx 1.1
12 arfrever 1.65 inherit multilib
13 liquidx 1.2
14 carlo 1.23 if [[ -n "${NEED_PYTHON}" ]] ; then
15 betelgeuse 1.55 PYTHON_ATOM=">=dev-lang/python-${NEED_PYTHON}"
16     DEPEND="${PYTHON_ATOM}"
17 swegener 1.24 RDEPEND="${DEPEND}"
18 betelgeuse 1.55 else
19     PYTHON_ATOM="dev-lang/python"
20 carlo 1.22 fi
21 liquidx 1.18
22 arfrever 1.74 DEPEND+=" >=app-admin/eselect-python-20090804
23     >=app-shells/bash-3.2"
24 arfrever 1.56
25 liquidx 1.18 __python_eclass_test() {
26     __python_version_extract 2.3
27     echo -n "2.3 -> PYVER: $PYVER PYVER_MAJOR: $PYVER_MAJOR"
28     echo " PYVER_MINOR: $PYVER_MINOR PYVER_MICRO: $PYVER_MICRO"
29     __python_version_extract 2.3.4
30     echo -n "2.3.4 -> PYVER: $PYVER PYVER_MAJOR: $PYVER_MAJOR"
31     echo " PYVER_MINOR: $PYVER_MINOR PYVER_MICRO: $PYVER_MICRO"
32     __python_version_extract 2.3.5
33     echo -n "2.3.5 -> PYVER: $PYVER PYVER_MAJOR: $PYVER_MAJOR"
34     echo " PYVER_MINOR: $PYVER_MINOR PYVER_MICRO: $PYVER_MICRO"
35     __python_version_extract 2.4
36     echo -n "2.4 -> PYVER: $PYVER PYVER_MAJOR: $PYVER_MAJOR"
37     echo " PYVER_MINOR: $PYVER_MINOR PYVER_MICRO: $PYVER_MICRO"
38 liquidx 1.28 __python_version_extract 2.5b3
39     echo -n "2.5b3 -> PYVER: $PYVER PYVER_MAJOR: $PYVER_MAJOR"
40     echo " PYVER_MINOR: $PYVER_MINOR PYVER_MICRO: $PYVER_MICRO"
41 liquidx 1.18 }
42    
43 dev-zero 1.33 # @FUNCTION: python_version
44     # @DESCRIPTION:
45     # Run without arguments and it will export the version of python
46     # currently in use as $PYVER; sets PYVER/PYVER_MAJOR/PYVER_MINOR
47 liquidx 1.18 __python_version_extract() {
48 hawking 1.45 local verstr=$1
49 liquidx 1.18 export PYVER_MAJOR=${verstr:0:1}
50     export PYVER_MINOR=${verstr:2:1}
51 hawking 1.47 if [[ ${verstr:3:1} == . ]]; then
52 swegener 1.29 export PYVER_MICRO=${verstr:4}
53 liquidx 1.28 fi
54 swegener 1.21 export PYVER="${PYVER_MAJOR}.${PYVER_MINOR}"
55 liquidx 1.18 }
56    
57 liquidx 1.1 python_version() {
58 hawking 1.44 [[ -n "${PYVER}" ]] && return 0
59 liquidx 1.1 local tmpstr
60     python=${python:-/usr/bin/python}
61     tmpstr="$(${python} -V 2>&1 )"
62     export PYVER_ALL="${tmpstr#Python }"
63 liquidx 1.18 __python_version_extract $PYVER_ALL
64 liquidx 1.1 }
65    
66 arfrever 1.60 # @FUNCTION: PYTHON
67 arfrever 1.71 # @USAGE: [-a|--absolute-path] [--] <Python_ABI="${PYTHON_ABI}">
68 arfrever 1.56 # @DESCRIPTION:
69     # Get Python interpreter filename for specified Python ABI. If Python_ABI argument
70     # is ommitted, then PYTHON_ABI environment variable must be set and is used.
71 arfrever 1.60 PYTHON() {
72 arfrever 1.56 local absolute_path="0" slot=
73    
74     while (($#)); do
75     case "$1" in
76     -a|--absolute-path)
77     absolute_path="1"
78     ;;
79 arfrever 1.71 --)
80     break
81     ;;
82 arfrever 1.56 -*)
83     die "${FUNCNAME}(): Unrecognized option $1"
84     ;;
85     *)
86     break
87     ;;
88     esac
89     shift
90     done
91    
92     if [[ "$#" -eq "0" ]]; then
93     if [[ -n "${PYTHON_ABI}" ]]; then
94     slot="${PYTHON_ABI}"
95     else
96     die "${FUNCNAME}(): Invalid usage"
97     fi
98     elif [[ "$#" -eq "1" ]]; then
99     slot="$1"
100     else
101     die "${FUNCNAME}(): Invalid usage"
102     fi
103    
104     if [[ "${absolute_path}" == "1" ]]; then
105     echo -n "/usr/bin/python${slot}"
106     else
107     echo -n "python${slot}"
108     fi
109     }
110    
111     # @FUNCTION: validate_PYTHON_ABIS
112     # @DESCRIPTION:
113 arfrever 1.76 # Ensure that PYTHON_ABIS variable has valid value.
114 arfrever 1.56 validate_PYTHON_ABIS() {
115 arfrever 1.66 # Ensure that some functions cannot be accidentally successfully used in EAPI <= 2 without setting SUPPORT_PYTHON_ABIS variable.
116     if has "${EAPI:-0}" 0 1 2 && [[ -z "${SUPPORT_PYTHON_ABIS}" ]]; then
117     die "${FUNCNAME}() cannot be used in this EAPI without setting SUPPORT_PYTHON_ABIS variable"
118     fi
119    
120 arfrever 1.59 # Ensure that /usr/bin/python and /usr/bin/python-config are valid.
121 arfrever 1.63 if [[ "$(readlink /usr/bin/python)" != "python-wrapper" ]]; then
122 arfrever 1.66 die "'/usr/bin/python' isn't valid symlink"
123 arfrever 1.57 fi
124     if [[ "$(</usr/bin/python-config)" != *"Gentoo python-config wrapper script"* ]]; then
125 arfrever 1.66 die "'/usr/bin/python-config' isn't valid script"
126 arfrever 1.57 fi
127    
128 arfrever 1.56 # USE_${ABI_TYPE^^} and RESTRICT_${ABI_TYPE^^}_ABIS variables hopefully will be included in EAPI >= 4.
129 arfrever 1.70 if [[ "$(declare -p PYTHON_ABIS 2> /dev/null)" != "declare -x PYTHON_ABIS="* ]] && has "${EAPI:-0}" 0 1 2 3; then
130 arfrever 1.75 local ABI python2_supported_versions python3_supported_versions restricted_ABI support_ABI supported_PYTHON_ABIS=
131 arfrever 1.56 PYTHON_ABI_SUPPORTED_VALUES="2.4 2.5 2.6 2.7 3.0 3.1 3.2"
132 arfrever 1.75 python2_supported_versions="2.4 2.5 2.6 2.7"
133     python3_supported_versions="3.0 3.1 3.2"
134 arfrever 1.68
135 arfrever 1.70 if [[ "$(declare -p USE_PYTHON 2> /dev/null)" == "declare -x USE_PYTHON="* ]]; then
136 arfrever 1.75 local python2_enabled="0" python3_enabled="0"
137    
138 arfrever 1.68 if [[ -z "${USE_PYTHON}" ]]; then
139     die "USE_PYTHON variable is empty"
140 arfrever 1.56 fi
141 arfrever 1.68
142     for ABI in ${USE_PYTHON}; do
143     if ! has "${ABI}" ${PYTHON_ABI_SUPPORTED_VALUES}; then
144     die "USE_PYTHON variable contains invalid value '${ABI}'"
145     fi
146 arfrever 1.75
147     if has "${ABI}" ${python2_supported_versions}; then
148     python2_enabled="1"
149     fi
150     if has "${ABI}" ${python3_supported_versions}; then
151     python3_enabled="1"
152     fi
153    
154 arfrever 1.68 support_ABI="1"
155 arfrever 1.66 for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
156     if python -c "from fnmatch import fnmatch; exit(not fnmatch('${ABI}', '${restricted_ABI}'))"; then
157     support_ABI="0"
158     break
159     fi
160     done
161 arfrever 1.68 [[ "${support_ABI}" == "1" ]] && supported_PYTHON_ABIS+=" ${ABI}"
162     done
163     export PYTHON_ABIS="${supported_PYTHON_ABIS# }"
164    
165     if [[ -z "${PYTHON_ABIS//[${IFS}]/}" ]]; then
166 arfrever 1.74 die "USE_PYTHON variable doesn't enable any version of Python supported by ${CATEGORY}/${PF}"
167 arfrever 1.66 fi
168 arfrever 1.75
169     if [[ "${python2_enabled}" == "0" ]]; then
170     ewarn "USE_PYTHON variable doesn't enable any version of Python 2. This configuration is unsupported."
171     fi
172     if [[ "${python3_enabled}" == "0" ]]; then
173     ewarn "USE_PYTHON variable doesn't enable any version of Python 3. This configuration is unsupported."
174     fi
175 arfrever 1.68 else
176 arfrever 1.76 local python_version python2_version= python3_version= support_python_major_version
177    
178     python_version="$(/usr/bin/python -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')"
179 arfrever 1.74
180     if has_version "=dev-lang/python-2*"; then
181     if [[ "$(readlink /usr/bin/python2)" != "python2."* ]]; then
182     die "'/usr/bin/python2' isn't valid symlink"
183     fi
184    
185     python2_version="$(/usr/bin/python2 -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')"
186    
187     for ABI in ${python2_supported_versions}; do
188     support_python_major_version="1"
189     for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
190     if python -c "from fnmatch import fnmatch; exit(not fnmatch('${ABI}', '${restricted_ABI}'))"; then
191     support_python_major_version="0"
192     fi
193     done
194     [[ "${support_python_major_version}" == "1" ]] && break
195     done
196     if [[ "${support_python_major_version}" == "1" ]]; then
197     for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
198     if python -c "from fnmatch import fnmatch; exit(not fnmatch('${python2_version}', '${restricted_ABI}'))"; then
199     die "Active version of Python 2 isn't supported by ${CATEGORY}/${PF}"
200     fi
201     done
202     else
203     python2_version=""
204     fi
205     fi
206 arfrever 1.56
207 arfrever 1.74 if has_version "=dev-lang/python-3*"; then
208     if [[ "$(readlink /usr/bin/python3)" != "python3."* ]]; then
209     die "'/usr/bin/python3' isn't valid symlink"
210 arfrever 1.68 fi
211 arfrever 1.74
212     python3_version="$(/usr/bin/python3 -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')"
213    
214     for ABI in ${python3_supported_versions}; do
215     support_python_major_version="1"
216     for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
217     if python -c "from fnmatch import fnmatch; exit(not fnmatch('${ABI}', '${restricted_ABI}'))"; then
218     support_python_major_version="0"
219     fi
220     done
221     [[ "${support_python_major_version}" == "1" ]] && break
222     done
223     if [[ "${support_python_major_version}" == "1" ]]; then
224     for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do
225     if python -c "from fnmatch import fnmatch; exit(not fnmatch('${python3_version}', '${restricted_ABI}'))"; then
226     die "Active version of Python 3 isn't supported by ${CATEGORY}/${PF}"
227     fi
228     done
229     else
230     python3_version=""
231     fi
232     fi
233    
234 arfrever 1.76 if ! has "${python_version}" "${python2_version}" "${python3_version}"; then
235     eerror "Python wrapper is configured incorrectly or /usr/bin/python2 or /usr/bin/python3 symlink"
236     eerror "is set incorrectly. Use \`eselect python\` to fix configuration."
237     die "Incorrect configuration of Python"
238     fi
239    
240 arfrever 1.74 PYTHON_ABIS="${python2_version} ${python3_version}"
241     PYTHON_ABIS="${PYTHON_ABIS# }"
242     export PYTHON_ABIS="${PYTHON_ABIS% }"
243 arfrever 1.68 fi
244 arfrever 1.56 fi
245 arfrever 1.66
246     local PYTHON_ABI
247     for PYTHON_ABI in ${PYTHON_ABIS}; do
248 arfrever 1.71 # Ensure that appropriate Python version is installed.
249     if ! has_version "dev-lang/python:${PYTHON_ABI}"; then
250     die "dev-lang/python:${PYTHON_ABI} isn't installed"
251     fi
252    
253     # Ensure that EPYTHON variable is respected.
254 arfrever 1.66 if [[ "$(EPYTHON="$(PYTHON)" python -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')" != "${PYTHON_ABI}" ]]; then
255     die "'python' doesn't respect EPYTHON variable"
256     fi
257     done
258 arfrever 1.56 }
259    
260     # @FUNCTION: python_copy_sources
261 arfrever 1.71 # @USAGE: [--no-link] [--] [directory]
262 arfrever 1.56 # @DESCRIPTION:
263     # Copy unpacked sources of given package for each Python ABI.
264     python_copy_sources() {
265 arfrever 1.71 local dir dirs=() no_link="0" PYTHON_ABI
266    
267     while (($#)); do
268     case "$1" in
269     --no-link)
270     no_link="1"
271     ;;
272     --)
273     break
274     ;;
275     -*)
276     die "${FUNCNAME}(): Unrecognized option '$1'"
277     ;;
278     *)
279     break
280     ;;
281     esac
282     shift
283     done
284 arfrever 1.56
285     if [[ "$#" -eq "0" ]]; then
286     if [[ "${WORKDIR}" == "${S}" ]]; then
287     die "${FUNCNAME}() cannot be used"
288     fi
289     dirs="${S}"
290     else
291     dirs="$@"
292     fi
293    
294     validate_PYTHON_ABIS
295     for PYTHON_ABI in ${PYTHON_ABIS}; do
296     for dir in "${dirs[@]}"; do
297 arfrever 1.71 if [[ "${no_link}" == "1" ]]; then
298     cp -pr "${dir}" "${dir}-${PYTHON_ABI}" > /dev/null || die "Copying of sources failed"
299     else
300     cp -lpr "${dir}" "${dir}-${PYTHON_ABI}" > /dev/null || die "Copying of sources failed"
301     fi
302 arfrever 1.56 done
303     done
304     }
305    
306     # @FUNCTION: python_set_build_dir_symlink
307     # @USAGE: [directory="build"]
308     # @DESCRIPTION:
309     # Create build directory symlink.
310     python_set_build_dir_symlink() {
311     local dir="$1"
312    
313 arfrever 1.66 [[ -z "${PYTHON_ABI}" ]] && die "PYTHON_ABI variable not set"
314 arfrever 1.56 [[ -z "${dir}" ]] && dir="build"
315    
316     # Don't delete preexistent directories.
317     rm -f "${dir}" || die "Deletion of '${dir}' failed"
318     ln -s "${dir}-${PYTHON_ABI}" "${dir}" || die "Creation of '${dir}' directory symlink failed"
319     }
320    
321     # @FUNCTION: python_execute_function
322 arfrever 1.71 # @USAGE: [--action-message message] [-d|--default-function] [--failure-message message] [--nonfatal] [-q|--quiet] [-s|--separate-build-dirs] [--] <function> [arguments]
323 arfrever 1.56 # @DESCRIPTION:
324 arfrever 1.60 # Execute specified function for each value of PYTHON_ABIS, optionally passing additional
325     # arguments. The specified function can use PYTHON_ABI and BUILDDIR variables.
326 arfrever 1.56 python_execute_function() {
327 arfrever 1.73 local action action_message action_message_template= default_function="0" failure_message failure_message_template= function nonfatal="0" previous_directory previous_directory_stack previous_directory_stack_length PYTHON_ABI quiet="0" separate_build_dirs="0"
328 arfrever 1.56
329     while (($#)); do
330     case "$1" in
331     --action-message)
332     action_message_template="$2"
333     shift
334     ;;
335 arfrever 1.58 -d|--default-function)
336     default_function="1"
337     ;;
338 arfrever 1.56 --failure-message)
339     failure_message_template="$2"
340     shift
341     ;;
342     --nonfatal)
343     nonfatal="1"
344     ;;
345     -q|--quiet)
346     quiet="1"
347     ;;
348     -s|--separate-build-dirs)
349     separate_build_dirs="1"
350     ;;
351 arfrever 1.71 --)
352     break
353     ;;
354 arfrever 1.56 -*)
355 arfrever 1.67 die "${FUNCNAME}(): Unrecognized option '$1'"
356 arfrever 1.56 ;;
357     *)
358     break
359     ;;
360     esac
361     shift
362     done
363    
364 arfrever 1.58 if [[ "${default_function}" == "0" ]]; then
365     if [[ "$#" -eq "0" ]]; then
366     die "${FUNCNAME}(): Missing function name"
367     fi
368     function="$1"
369     shift
370 arfrever 1.67
371     if [[ -z "$(type -t "${function}")" ]]; then
372     die "${FUNCNAME}(): '${function}' function isn't defined"
373     fi
374 arfrever 1.58 else
375     if [[ "$#" -ne "0" ]]; then
376 arfrever 1.67 die "${FUNCNAME}(): '--default-function' option and function name cannot be specified simultaneously"
377 arfrever 1.58 fi
378     if has "${EAPI:-0}" 0 1; then
379 arfrever 1.67 die "${FUNCNAME}(): '--default-function' option cannot be used in this EAPI"
380 arfrever 1.58 fi
381    
382     if [[ "${EBUILD_PHASE}" == "configure" ]]; then
383 arfrever 1.61 if has "${EAPI}" 2; then
384     python_default_function() {
385     econf
386     }
387     else
388     python_default_function() {
389     nonfatal econf
390     }
391     fi
392 arfrever 1.58 elif [[ "${EBUILD_PHASE}" == "compile" ]]; then
393     python_default_function() {
394     emake
395     }
396     elif [[ "${EBUILD_PHASE}" == "test" ]]; then
397     python_default_function() {
398     if emake -j1 -n check &> /dev/null; then
399     emake -j1 check
400     elif emake -j1 -n test &> /dev/null; then
401     emake -j1 test
402     fi
403     }
404     elif [[ "${EBUILD_PHASE}" == "install" ]]; then
405     python_default_function() {
406     emake DESTDIR="${D}" install
407     }
408     else
409     die "${FUNCNAME}(): --default-function option cannot be used in this ebuild phase"
410     fi
411     function="python_default_function"
412 arfrever 1.56 fi
413    
414     if [[ "${quiet}" == "0" ]]; then
415     [[ "${EBUILD_PHASE}" == "setup" ]] && action="Setting up"
416     [[ "${EBUILD_PHASE}" == "unpack" ]] && action="Unpacking"
417     [[ "${EBUILD_PHASE}" == "prepare" ]] && action="Preparation"
418     [[ "${EBUILD_PHASE}" == "configure" ]] && action="Configuration"
419     [[ "${EBUILD_PHASE}" == "compile" ]] && action="Building"
420     [[ "${EBUILD_PHASE}" == "test" ]] && action="Testing"
421     [[ "${EBUILD_PHASE}" == "install" ]] && action="Installation"
422     [[ "${EBUILD_PHASE}" == "preinst" ]] && action="Preinstallation"
423     [[ "${EBUILD_PHASE}" == "postinst" ]] && action="Postinstallation"
424     [[ "${EBUILD_PHASE}" == "prerm" ]] && action="Preuninstallation"
425     [[ "${EBUILD_PHASE}" == "postrm" ]] && action="Postuninstallation"
426     fi
427    
428     local RED GREEN BLUE NORMAL
429     if [[ "${NOCOLOR:-false}" =~ ^(false|no)$ ]]; then
430     RED=$'\e[1;31m'
431     GREEN=$'\e[1;32m'
432     BLUE=$'\e[1;34m'
433     NORMAL=$'\e[0m'
434     else
435     RED=
436     GREEN=
437     BLUE=
438     NORMAL=
439     fi
440    
441     validate_PYTHON_ABIS
442     for PYTHON_ABI in ${PYTHON_ABIS}; do
443     if [[ "${quiet}" == "0" ]]; then
444     if [[ -n "${action_message_template}" ]]; then
445     action_message="$(eval echo -n "${action_message_template}")"
446     else
447     action_message="${action} of ${CATEGORY}/${PF} with Python ${PYTHON_ABI}..."
448     fi
449     echo " ${GREEN}*${NORMAL} ${BLUE}${action_message}${NORMAL}"
450     fi
451 arfrever 1.66
452 arfrever 1.56 if [[ "${separate_build_dirs}" == "1" ]]; then
453 arfrever 1.60 export BUILDDIR="${S}-${PYTHON_ABI}"
454     pushd "${BUILDDIR}" > /dev/null || die "pushd failed"
455     else
456     export BUILDDIR="${S}"
457 arfrever 1.56 fi
458 arfrever 1.66
459 arfrever 1.73 previous_directory="$(pwd)"
460     previous_directory_stack="$(dirs -p)"
461     previous_directory_stack_length="$(dirs -p | wc -l)"
462 arfrever 1.72
463 arfrever 1.66 if ! has "${EAPI}" 0 1 2 && has "${PYTHON_ABI}" ${FAILURE_TOLERANT_PYTHON_ABIS}; then
464     EPYTHON="$(PYTHON)" nonfatal "${function}" "$@"
465     else
466     EPYTHON="$(PYTHON)" "${function}" "$@"
467     fi
468    
469     if [[ "$?" != "0" ]]; then
470 arfrever 1.56 if [[ -n "${failure_message_template}" ]]; then
471     failure_message="$(eval echo -n "${failure_message_template}")"
472     else
473     failure_message="${action} failed with Python ${PYTHON_ABI} in ${function}() function"
474     fi
475 arfrever 1.66
476 arfrever 1.69 if [[ "${nonfatal}" == "1" ]]; then
477     if [[ "${quiet}" == "0" ]]; then
478     ewarn "${RED}${failure_message}${NORMAL}"
479     fi
480     elif has "${PYTHON_ABI}" ${FAILURE_TOLERANT_PYTHON_ABIS}; then
481 arfrever 1.70 if [[ "${EBUILD_PHASE}" != "test" ]] || ! has test-fail-continue ${FEATURES}; then
482     local ABI enabled_PYTHON_ABIS=
483     for ABI in ${PYTHON_ABIS}; do
484     [[ "${ABI}" != "${PYTHON_ABI}" ]] && enabled_PYTHON_ABIS+=" ${ABI}"
485     done
486     export PYTHON_ABIS="${enabled_PYTHON_ABIS# }"
487     fi
488 arfrever 1.56 if [[ "${quiet}" == "0" ]]; then
489     ewarn "${RED}${failure_message}${NORMAL}"
490     fi
491 arfrever 1.69 if [[ -z "${PYTHON_ABIS}" ]]; then
492     die "${function}() function failed with all enabled versions of Python"
493     fi
494 arfrever 1.56 else
495     die "${failure_message}"
496     fi
497     fi
498 arfrever 1.66
499 arfrever 1.73 # Ensure that directory stack hasn't been decreased.
500     if [[ "$(dirs -p | wc -l)" -lt "${previous_directory_stack_length}" ]]; then
501 arfrever 1.72 die "Directory stack decreased illegally"
502     fi
503    
504 arfrever 1.73 # Avoid side effects of earlier returning from the specified function.
505     while [[ "$(dirs -p | wc -l)" -gt "${previous_directory_stack_length}" ]]; do
506 arfrever 1.72 popd > /dev/null || die "popd failed"
507     done
508    
509 arfrever 1.73 # Ensure that the bottom part of directory stack hasn't been changed. Restore
510     # previous directory (from before running of the specified function) before
511     # comparison of directory stacks to avoid mismatch of directory stacks after
512     # potential using of 'cd' to change current directory. Restoration of previous
513     # directory allows to safely use 'cd' to change current directory in the
514     # specified function without changing it back to original directory.
515     cd "${previous_directory}"
516     if [[ "$(dirs -p)" != "${previous_directory_stack}" ]]; then
517     die "Directory stack changed illegally"
518     fi
519    
520 arfrever 1.56 if [[ "${separate_build_dirs}" == "1" ]]; then
521     popd > /dev/null || die "popd failed"
522     fi
523 arfrever 1.60 unset BUILDDIR
524 arfrever 1.56 done
525 arfrever 1.58
526     if [[ "${default_function}" == "1" ]]; then
527     unset -f python_default_function
528     fi
529 arfrever 1.56 }
530    
531    
532 betelgeuse 1.55 # @ECLASS-VARIABLE: PYTHON_USE_WITH
533     # @DESCRIPTION:
534     # Set this to a space separated list of use flags
535     # the python slot in use must be built with.
536    
537     # @ECLASS-VARIABLE: PYTHON_USE_WITH_OR
538     # @DESCRIPTION:
539     # Set this to a space separated list of use flags
540     # of which one must be turned on for the slot of
541     # in use.
542    
543     # @ECLASS-VARIABLE: PYTHON_USE_WITH_OPT
544     # @DESCRIPTION:
545     # Set this if you need to make either PYTHON_USE_WITH or
546     # PYTHON_USE_WITH_OR atoms conditional under a use flag.
547    
548     # @FUNCTION: python_pkg_setup
549     # @DESCRIPTION:
550     # Makes sure PYTHON_USE_WITH or PYTHON_USE_WITH_OR listed use flags
551     # are respected. Only exported if one of those variables is set.
552 arfrever 1.67 if ! has "${EAPI:-0}" 0 1 && [[ -n ${PYTHON_USE_WITH} || -n ${PYTHON_USE_WITH_OR} ]]; then
553 arfrever 1.74 python_pkg_setup() {
554     python_pkg_setup_fail() {
555     eerror "${1}"
556     die "${1}"
557     }
558 betelgeuse 1.55
559     [[ ${PYTHON_USE_WITH_OPT} ]] && use !${PYTHON_USE_WITH_OPT} && return
560    
561 arfrever 1.74 python_pkg_setup_check_USE_flags() {
562     local pyatom use
563     if [[ -n "${PYTHON_ABI}" ]]; then
564     pyatom="dev-lang/python:${PYTHON_ABI}"
565     else
566     python_version
567     pyatom="dev-lang/python:${PYVER}"
568     fi
569    
570 arfrever 1.76 # Workaround for older versions of Portage.
571     # has_version() calls portageq which is implemented in Python.
572     if has_version "=dev-lang/python-2*"; then
573     local EPYTHON
574     export EPYTHON="$(readlink /usr/bin/python2)"
575     fi
576    
577 arfrever 1.74 for use in ${PYTHON_USE_WITH}; do
578     if ! has_version "${pyatom}[${use}]"; then
579     python_pkg_setup_fail "Please rebuild ${pyatom} with the following USE flags enabled: ${PYTHON_USE_WITH}"
580     fi
581     done
582 betelgeuse 1.55
583 arfrever 1.74 for use in ${PYTHON_USE_WITH_OR}; do
584     if has_version "${pyatom}[${use}]"; then
585     return
586     fi
587     done
588 betelgeuse 1.55
589 arfrever 1.74 if [[ ${PYTHON_USE_WITH_OR} ]]; then
590     python_pkg_setup_fail "Please rebuild ${pyatom} with at least one of the following USE flags enabled: ${PYTHON_USE_WITH_OR}"
591 betelgeuse 1.55 fi
592 arfrever 1.74 }
593 betelgeuse 1.55
594 arfrever 1.74 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
595     python_execute_function -q python_pkg_setup_check_USE_flags
596     else
597     python_pkg_setup_check_USE_flags
598 betelgeuse 1.55 fi
599     }
600    
601     EXPORT_FUNCTIONS pkg_setup
602    
603 arfrever 1.74 if [[ -n "${PYTHON_USE_WITH}" ]]; then
604 betelgeuse 1.55 PYTHON_USE_WITH_ATOM="${PYTHON_ATOM}[${PYTHON_USE_WITH/ /,}]"
605 arfrever 1.74 elif [[ -n "${PYTHON_USE_WITH_OR}" ]]; then
606 betelgeuse 1.55 PYTHON_USE_WITH_ATOM="|| ( "
607     for use in ${PYTHON_USE_WITH_OR}; do
608 arfrever 1.74 PYTHON_USE_WITH_ATOM+=" ${PYTHON_ATOM}[${use}]"
609 betelgeuse 1.55 done
610 arfrever 1.74 unset use
611     PYTHON_USE_WITH_ATOM+=" )"
612 betelgeuse 1.55 fi
613 arfrever 1.74 if [[ -n "${PYTHON_USE_WITH_OPT}" ]]; then
614 betelgeuse 1.55 PYTHON_USE_WITH_ATOM="${PYTHON_USE_WITH_OPT}? ( ${PYTHON_USE_WITH_ATOM} )"
615     fi
616 arfrever 1.74 DEPEND+=" ${PYTHON_USE_WITH_ATOM}"
617     RDEPEND+=" ${PYTHON_USE_WITH_ATOM}"
618 betelgeuse 1.55 fi
619    
620 arfrever 1.67 # @ECLASS-VARIABLE: PYTHON_DEFINE_DEFAULT_FUNCTIONS
621     # @DESCRIPTION:
622     # Set this to define default functions for the following ebuild phases:
623     # src_prepare, src_configure, src_compile, src_test, src_install.
624     if ! has "${EAPI:-0}" 0 1 && [[ -n "${PYTHON_DEFINE_DEFAULT_FUNCTIONS}" ]]; then
625     python_src_prepare() {
626     python_copy_sources
627     }
628    
629     for python_default_function in src_configure src_compile src_test src_install; do
630     eval "python_${python_default_function}() { python_execute_function -d -s; }"
631     done
632     unset python_default_function
633    
634     EXPORT_FUNCTIONS src_prepare src_configure src_compile src_test src_install
635     fi
636    
637 hawking 1.46 # @FUNCTION: python_disable_pyc
638     # @DESCRIPTION:
639 arfrever 1.66 # Tell Python not to automatically recompile modules to .pyc/.pyo
640 hawking 1.46 # even if the timestamps/version stamps don't match. This is done
641     # to protect sandbox.
642     python_disable_pyc() {
643 arfrever 1.66 export PYTHONDONTWRITEBYTECODE="1"
644 hawking 1.46 }
645    
646     # @FUNCTION: python_enable_pyc
647     # @DESCRIPTION:
648 arfrever 1.66 # Tell Python to automatically recompile modules to .pyc/.pyo if the
649     # timestamps/version stamps have changed.
650 hawking 1.46 python_enable_pyc() {
651 hawking 1.53 unset PYTHONDONTWRITEBYTECODE
652 hawking 1.46 }
653    
654     python_disable_pyc
655    
656 hawking 1.52 # @FUNCTION: python_need_rebuild
657     # @DESCRIPTION: Run without arguments, specifies that the package should be
658     # rebuilt after a python upgrade.
659     python_need_rebuild() {
660     python_version
661     export PYTHON_NEED_REBUILD=${PYVER}
662     }
663    
664 arfrever 1.56 # @FUNCTION: python_get_includedir
665     # @DESCRIPTION:
666     # Run without arguments, returns the Python include directory.
667     python_get_includedir() {
668     if [[ -n "${PYTHON_ABI}" ]]; then
669     echo "/usr/include/python${PYTHON_ABI}"
670     else
671     python_version
672     echo "/usr/include/python${PYVER}"
673     fi
674     }
675    
676 pythonhead 1.43 # @FUNCTION: python_get_libdir
677     # @DESCRIPTION:
678 arfrever 1.56 # Run without arguments, returns the Python library directory.
679 pythonhead 1.43 python_get_libdir() {
680 arfrever 1.56 if [[ -n "${PYTHON_ABI}" ]]; then
681     echo "/usr/$(get_libdir)/python${PYTHON_ABI}"
682     else
683     python_version
684     echo "/usr/$(get_libdir)/python${PYVER}"
685     fi
686 pythonhead 1.42 }
687    
688 pythonhead 1.43 # @FUNCTION: python_get_sitedir
689     # @DESCRIPTION:
690 arfrever 1.56 # Run without arguments, returns the Python site-packages directory.
691 pythonhead 1.43 python_get_sitedir() {
692     echo "$(python_get_libdir)/site-packages"
693 pythonhead 1.42 }
694    
695 dev-zero 1.33 # @FUNCTION: python_tkinter_exists
696     # @DESCRIPTION:
697     # Run without arguments, checks if python was compiled with Tkinter
698     # support. If not, prints an error message and dies.
699 liquidx 1.1 python_tkinter_exists() {
700     if ! python -c "import Tkinter" >/dev/null 2>&1; then
701     eerror "You need to recompile python with Tkinter support."
702 kloeri 1.30 eerror "Try adding: 'dev-lang/python tk'"
703 liquidx 1.27 eerror "in to /etc/portage/package.use"
704 liquidx 1.1 echo
705     die "missing tkinter support with installed python"
706     fi
707     }
708    
709 dev-zero 1.33 # @FUNCTION: python_mod_exists
710 arfrever 1.56 # @USAGE: <module>
711 dev-zero 1.33 # @DESCRIPTION:
712     # Run with the module name as an argument. it will check if a
713     # python module is installed and loadable. it will return
714     # TRUE(0) if the module exists, and FALSE(1) if the module does
715     # not exist.
716 liquidx 1.1 #
717 dev-zero 1.33 # Example:
718 liquidx 1.1 # if python_mod_exists gtk; then
719 liquidx 1.28 # echo "gtk support enabled"
720 liquidx 1.1 # fi
721     python_mod_exists() {
722 zmedico 1.54 [[ "$1" ]] || die "${FUNCNAME} requires an argument!"
723 arfrever 1.56 python -c "import $1" &>/dev/null
724 liquidx 1.1 }
725    
726 dev-zero 1.33 # @FUNCTION: python_mod_compile
727 arfrever 1.56 # @USAGE: <file> [more files ...]
728 dev-zero 1.33 # @DESCRIPTION:
729 hawking 1.35 # Given filenames, it will pre-compile the module's .pyc and .pyo.
730 hawking 1.37 # This function should only be run in pkg_postinst()
731 liquidx 1.1 #
732 dev-zero 1.33 # Example:
733 hawking 1.35 # python_mod_compile /usr/lib/python2.3/site-packages/pygoogle.py
734 liquidx 1.1 #
735     python_mod_compile() {
736 arfrever 1.56 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
737     die "${FUNCNAME}() cannot be used in this EAPI"
738     fi
739    
740 hawking 1.48 local f myroot myfiles=()
741 hawking 1.37
742     # Check if phase is pkg_postinst()
743     [[ ${EBUILD_PHASE} != postinst ]] &&\
744 hawking 1.39 die "${FUNCNAME} should only be run in pkg_postinst()"
745 hawking 1.37
746 liquidx 1.5 # allow compiling for older python versions
747 hawking 1.48 if [[ "${PYTHON_OVERRIDE_PYVER}" ]]; then
748 liquidx 1.5 PYVER=${PYTHON_OVERRIDE_PYVER}
749 pythonhead 1.7 else
750 liquidx 1.5 python_version
751     fi
752 pythonhead 1.7
753 hawking 1.35 # strip trailing slash
754     myroot="${ROOT%/}"
755    
756     # respect ROOT
757 hawking 1.51 for f in "$@"; do
758 hawking 1.48 [[ -f "${myroot}/${f}" ]] && myfiles+=("${myroot}/${f}")
759 hawking 1.35 done
760    
761 hawking 1.48 if ((${#myfiles[@]})); then
762     python${PYVER} ${myroot}/usr/$(get_libdir)/python${PYVER}/py_compile.py "${myfiles[@]}"
763 arfrever 1.63 python${PYVER} -O ${myroot}/usr/$(get_libdir)/python${PYVER}/py_compile.py "${myfiles[@]}" &> /dev/null
764 liquidx 1.1 else
765 hawking 1.35 ewarn "No files to compile!"
766 pythonhead 1.7 fi
767 liquidx 1.1 }
768    
769 dev-zero 1.33 # @FUNCTION: python_mod_optimize
770 arfrever 1.56 # @USAGE: [options] [directory|file]
771 dev-zero 1.33 # @DESCRIPTION:
772 arfrever 1.56 # If no arguments supplied, it will recompile not recursively all modules
773     # under sys.path (eg. /usr/lib/python2.6, /usr/lib/python2.6/site-packages).
774 liquidx 1.1 #
775 dev-zero 1.33 # If supplied with arguments, it will recompile all modules recursively
776 arfrever 1.56 # in the supplied directory.
777     # This function should only be run in pkg_postinst().
778 dev-zero 1.33 #
779 arfrever 1.56 # Options passed to this function are passed to compileall.py.
780 hawking 1.39 #
781 dev-zero 1.33 # Example:
782 arfrever 1.56 # python_mod_optimize ctypesgencore
783 liquidx 1.1 python_mod_optimize() {
784 arfrever 1.56 # Check if phase is pkg_postinst().
785     [[ ${EBUILD_PHASE} != "postinst" ]] && die "${FUNCNAME} should only be run in pkg_postinst()"
786    
787     if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
788     local dir file options=() other_dirs=() other_files=() PYTHON_ABI return_code root site_packages_absolute_dirs=() site_packages_dirs=() site_packages_absolute_files=() site_packages_files=()
789 hawking 1.37
790 arfrever 1.56 # Strip trailing slash from ROOT.
791     root="${ROOT%/}"
792    
793     # Respect ROOT and options passed to compileall.py.
794     while (($#)); do
795     case "$1" in
796     -l|-f|-q)
797     options+=("$1")
798     ;;
799     -d|-x)
800     options+=("$1" "$2")
801     shift
802     ;;
803     -*)
804     ewarn "${FUNCNAME}: Ignoring compile option $1"
805     ;;
806     *)
807     if [[ "$1" =~ ^/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then
808     die "${FUNCNAME} doesn't support absolute paths of directories/files in site-packages directories"
809     elif [[ "$1" =~ ^/ ]]; then
810     if [[ -d "${root}/$1" ]]; then
811     other_dirs+=("${root}/$1")
812     elif [[ -f "${root}/$1" ]]; then
813     other_files+=("${root}/$1")
814     elif [[ -e "${root}/$1" ]]; then
815     ewarn "'${root}/$1' is not a file or a directory!"
816     else
817     ewarn "'${root}/$1' doesn't exist!"
818     fi
819     else
820     for PYTHON_ABI in ${PYTHON_ABIS}; do
821 arfrever 1.62 if [[ -d "${root}$(python_get_sitedir)/$1" ]]; then
822 arfrever 1.56 site_packages_dirs+=("$1")
823     break
824 arfrever 1.62 elif [[ -f "${root}$(python_get_sitedir)/$1" ]]; then
825 arfrever 1.56 site_packages_files+=("$1")
826     break
827 arfrever 1.62 elif [[ -e "${root}$(python_get_sitedir)/$1" ]]; then
828 arfrever 1.56 ewarn "'$1' is not a file or a directory!"
829     else
830     ewarn "'$1' doesn't exist!"
831     fi
832     done
833     fi
834     ;;
835     esac
836     shift
837     done
838 hawking 1.37
839 arfrever 1.56 # Set additional options.
840     options+=("-q")
841 liquidx 1.13
842 arfrever 1.56 for PYTHON_ABI in ${PYTHON_ABIS}; do
843     if ((${#site_packages_dirs[@]})) || ((${#site_packages_files[@]})); then
844     return_code="0"
845     ebegin "Compilation and optimization of Python modules for Python ${PYTHON_ABI}"
846     if ((${#site_packages_dirs[@]})); then
847     for dir in "${site_packages_dirs[@]}"; do
848 arfrever 1.62 site_packages_absolute_dirs+=("${root}$(python_get_sitedir)/${dir}")
849 arfrever 1.56 done
850 arfrever 1.62 "$(PYTHON)" "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${site_packages_absolute_dirs[@]}" || return_code="1"
851 arfrever 1.63 "$(PYTHON)" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${site_packages_absolute_dirs[@]}" &> /dev/null || return_code="1"
852 arfrever 1.56 fi
853     if ((${#site_packages_files[@]})); then
854     for file in "${site_packages_files[@]}"; do
855 arfrever 1.62 site_packages_absolute_files+=("${root}$(python_get_sitedir)/${file}")
856 arfrever 1.56 done
857 arfrever 1.62 "$(PYTHON)" "${root}$(python_get_libdir)/py_compile.py" "${site_packages_absolute_files[@]}" || return_code="1"
858 arfrever 1.63 "$(PYTHON)" -O "${root}$(python_get_libdir)/py_compile.py" "${site_packages_absolute_files[@]}" &> /dev/null || return_code="1"
859 hawking 1.49 fi
860 arfrever 1.56 eend "${return_code}"
861     fi
862     unset site_packages_absolute_dirs site_packages_absolute_files
863     done
864    
865     # Don't use PYTHON_ABI in next calls to python_get_libdir().
866     unset PYTHON_ABI
867 hawking 1.36
868 arfrever 1.56 if ((${#other_dirs[@]})) || ((${#other_files[@]})); then
869     return_code="0"
870     ebegin "Compilation and optimization of Python modules placed outside of site-packages directories for Python ${PYVER}..."
871     if ((${#other_dirs[@]})); then
872 arfrever 1.62 python${PYVER} "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" || return_code="1"
873 arfrever 1.63 python${PYVER} -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" &> /dev/null || return_code="1"
874 arfrever 1.56 fi
875     if ((${#other_files[@]})); then
876 arfrever 1.62 python${PYVER} "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" || return_code="1"
877 arfrever 1.63 python${PYVER} -O "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" &> /dev/null || return_code="1"
878 arfrever 1.56 fi
879     eend "${return_code}"
880     fi
881 pythonhead 1.7 else
882 arfrever 1.63 local myroot mydirs=() myfiles=() myopts=() return_code="0"
883 arfrever 1.56
884     # strip trailing slash
885     myroot="${ROOT%/}"
886    
887     # respect ROOT and options passed to compileall.py
888     while (($#)); do
889     case "$1" in
890     -l|-f|-q)
891     myopts+=("$1")
892     ;;
893     -d|-x)
894     myopts+=("$1" "$2")
895     shift
896     ;;
897     -*)
898     ewarn "${FUNCNAME}: Ignoring compile option $1"
899     ;;
900     *)
901     if [[ -d "${myroot}"/$1 ]]; then
902     mydirs+=("${myroot}/$1")
903     elif [[ -f "${myroot}"/$1 ]]; then
904     # Files are passed to python_mod_compile which is ROOT-aware
905     myfiles+=("$1")
906     elif [[ -e "${myroot}/$1" ]]; then
907     ewarn "${myroot}/$1 is not a file or directory!"
908     else
909     ewarn "${myroot}/$1 doesn't exist!"
910     fi
911     ;;
912     esac
913     shift
914     done
915    
916     # allow compiling for older python versions
917     if [ -n "${PYTHON_OVERRIDE_PYVER}" ]; then
918     PYVER=${PYTHON_OVERRIDE_PYVER}
919     else
920     python_version
921     fi
922    
923     # set additional opts
924     myopts+=(-q)
925 pythonhead 1.7
926 arfrever 1.56 ebegin "Byte compiling python modules for python-${PYVER} .."
927     if ((${#mydirs[@]})); then
928     python${PYVER} \
929     "${myroot}"/usr/$(get_libdir)/python${PYVER}/compileall.py \
930 arfrever 1.63 "${myopts[@]}" "${mydirs[@]}" || return_code="1"
931 arfrever 1.56 python${PYVER} -O \
932     "${myroot}"/usr/$(get_libdir)/python${PYVER}/compileall.py \
933 arfrever 1.63 "${myopts[@]}" "${mydirs[@]}" &> /dev/null || return_code="1"
934 arfrever 1.56 fi
935 pythonhead 1.7
936 arfrever 1.56 if ((${#myfiles[@]})); then
937     python_mod_compile "${myfiles[@]}"
938     fi
939 hawking 1.36
940 arfrever 1.63 eend "${return_code}"
941 hawking 1.36 fi
942 liquidx 1.1 }
943    
944 dev-zero 1.33 # @FUNCTION: python_mod_cleanup
945 arfrever 1.56 # @USAGE: [directory]
946 dev-zero 1.33 # @DESCRIPTION:
947     # Run with optional arguments, where arguments are directories of
948 arfrever 1.56 # python modules. If none given, it will look in /usr/lib/python[0-9].[0-9].
949 dev-zero 1.33 #
950 arfrever 1.56 # It will recursively scan all compiled Python modules in the directories and
951     # determine if they are orphaned (i.e. their corresponding .py files are missing.)
952     # If they are, then it will remove their corresponding .pyc and .pyo files.
953 hawking 1.37 #
954 arfrever 1.56 # This function should only be run in pkg_postrm().
955 liquidx 1.1 python_mod_cleanup() {
956 arfrever 1.56 local PYTHON_ABI SEARCH_PATH=() root src_py
957 liquidx 1.16
958 arfrever 1.56 # Check if phase is pkg_postrm().
959     [[ ${EBUILD_PHASE} != "postrm" ]] && die "${FUNCNAME} should only be run in pkg_postrm()"
960 hawking 1.37
961 arfrever 1.56 # Strip trailing slash from ROOT.
962     root="${ROOT%/}"
963 liquidx 1.1
964 hawking 1.50 if (($#)); then
965 arfrever 1.56 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
966     while (($#)); do
967     if [[ "$1" =~ ^/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then
968     die "${FUNCNAME} doesn't support absolute paths of directories/files in site-packages directories"
969     elif [[ "$1" =~ ^/ ]]; then
970     SEARCH_PATH+=("${root}/${1#/}")
971     else
972     for PYTHON_ABI in ${PYTHON_ABIS}; do
973 arfrever 1.62 SEARCH_PATH+=("${root}$(python_get_sitedir)/$1")
974 arfrever 1.56 done
975     fi
976     shift
977     done
978     else
979     SEARCH_PATH=("${@#/}")
980     SEARCH_PATH=("${SEARCH_PATH[@]/#/${root}/}")
981     fi
982 liquidx 1.5 else
983 arfrever 1.56 SEARCH_PATH=("${root}"/usr/lib*/python*/site-packages)
984 liquidx 1.5 fi
985 pythonhead 1.7
986 hawking 1.50 for path in "${SEARCH_PATH[@]}"; do
987 arfrever 1.62 [[ ! -d "${path}" ]] && continue
988 liquidx 1.11 einfo "Cleaning orphaned Python bytecode from ${path} .."
989 zmedico 1.54 find "${path}" -name '*.py[co]' -print0 | while read -rd ''; do
990 hawking 1.50 src_py="${REPLY%[co]}"
991 arfrever 1.62 [[ -f "${src_py}" || (! -f "${src_py}c" && ! -f "${src_py}o") ]] && continue
992 hawking 1.50 einfo "Purging ${src_py}[co]"
993     rm -f "${src_py}"[co]
994 zmedico 1.54 done
995 hawking 1.50
996 arfrever 1.56 # Attempt to remove directories that may be empty.
997 zmedico 1.54 find "${path}" -type d | sort -r | while read -r dir; do
998 arfrever 1.62 rmdir "${dir}" 2>/dev/null && einfo "Removing empty directory ${dir}"
999 zmedico 1.54 done
1000 pythonhead 1.7 done
1001 liquidx 1.1 }

  ViewVC Help
Powered by ViewVC 1.1.20