]> git.ipfire.org Git - people/ms/ipfire-3.x.git/blame - pkgs/build-essentials/buildsystem-tools/py-compile
avahi: Update to 0.6.30.
[people/ms/ipfire-3.x.git] / pkgs / build-essentials / buildsystem-tools / py-compile
CommitLineData
235217d2
MT
1#!/bin/sh
2
3PYTHON=$(which python 2>/dev/null)
4
5if [ -z "${PYTHON}" ]; then
6 # Python is not present. Fail silently.
7 exit 0
8fi
9
10files=""
11for 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"
16done
17
18if [ -z "${files}" ]; then
19 # No files need to be proceeded.
20 exit 0
21fi
22
23$PYTHON -c "
24import sys, os, string, py_compile
25
26files = '''$files'''
27print 'Byte-compiling python modules...'
28for 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)
34print" || exit $?
35
36# this will fail for python < 1.5, but that doesn't matter ...
37$PYTHON -O -c "
38import sys, os, string, py_compile
39
40files = '''$files'''
41print 'Byte-compiling python modules (optimised versions) ...'
42for 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)
48print" 2>/dev/null || :