]> git.ipfire.org Git - people/amarx/ipfire-3.x.git/blob - pkgs/build-essentials/buildsystem-tools/py-compile
avahi: Update to 0.6.30.
[people/amarx/ipfire-3.x.git] / pkgs / build-essentials / buildsystem-tools / py-compile
1 #!/bin/sh
2
3 PYTHON=$(which python 2>/dev/null)
4
5 if [ -z "${PYTHON}" ]; then
6 # Python is not present. Fail silently.
7 exit 0
8 fi
9
10 files=""
11 for i in $*; do
12 if [ -e ${i}c ] && [ -e ${i}o ]; then
13 continue # all files we want are already there
14 fi
15 files="$files $i"
16 done
17
18 if [ -z "${files}" ]; then
19 # No files need to be proceeded.
20 exit 0
21 fi
22
23 $PYTHON -c "
24 import sys, os, string, py_compile
25
26 files = '''$files'''
27 print 'Byte-compiling python modules...'
28 for file in string.split(files):
29 if not os.path.exists(file) or not (len(file) >= 3 and file[-3:] == '.py'):
30 continue
31 print file,
32 sys.stdout.flush()
33 py_compile.compile(file)
34 print" || exit $?
35
36 # this will fail for python < 1.5, but that doesn't matter ...
37 $PYTHON -O -c "
38 import sys, os, string, py_compile
39
40 files = '''$files'''
41 print 'Byte-compiling python modules (optimised versions) ...'
42 for file in string.split(files):
43 if not os.path.exists(file) or not (len(file) >= 3 and file[-3:] == '.py'):
44 continue
45 print file,
46 sys.stdout.flush()
47 py_compile.compile(file)
48 print" 2>/dev/null || :