]>
git.ipfire.org Git - people/stevee/pakfire.git/blob - src/scripts/py-compile
3 python_interpreter
="python"
9 python_interpreter
=${1#--python=}
18 if [ -z "${paths}" ]; then
19 echo >&2 "No path specified!"
23 if [ "${python_interpreter:0:1}" != "/" ]; then
24 python_interpreter
=$
(which ${python_interpreter} 2>/dev
/null
)
27 if [ ! -x "${python_interpreter}" ]; then
28 echo >&2 "Python interpreter is not executable: ${python_interpreter}"
33 trap "rm -f ${tempfile}" EXIT
35 cat > ${tempfile} <<EOF
40 for file in sys.argv[1:]:
41 if not os.path.exists(file):
44 py_compile.compile(file, doraise=0)
47 filelist
=$
(find ${paths} -type f
-a -name "*.py" 2>/dev
/null
)
49 # Compile with optimization.
50 ${python_interpreter} -O ${tempfile} ${filelist}
52 # Compile without optimization.
53 ${python_interpreter} ${tempfile} ${filelist}
55 # Hardlink identical files.
56 for pyc
in $
(find ${paths} -type f
-a -name "*.pyc" 2>/dev
/null
); do
57 pyo
="${pyc/.pyc/.pyo}"
59 if cmp -s "${pyc}" "${pyo}"; then
60 ln -f "${pyc}" "${pyo}"