Blame project/pycgen.sh

b4ba4d
#!/bin/sh
b4ba4d
b4ba4d
# pycgen:    a build-time utiltiy script
b4ba4d
# objective: generate the correcponding python byte-code (.pyc)
b4ba4d
#            object files for one or more source python (.py)
b4ba4d
#            scripts.
b4ba4d
b4ba4d
if [ -z "$PYCGEN_PYTHON" ]; then
b4ba4d
	pycompile='python'
b4ba4d
else
b4ba4d
	pycompile="$PYCGEN_PYTHON"
b4ba4d
fi
b4ba4d
b4ba4d
refdir=$(pwd)
b4ba4d
b4ba4d
for pysrc in $@; do
b4ba4d
	basename=$(basename "$pysrc");
b4ba4d
	dstdir=$(dirname "$pysrc")
b4ba4d
b4ba4d
	if [ -z "$dstdir" ]; then
b4ba4d
		dstdir='.'
b4ba4d
	fi
b4ba4d
b4ba4d
	cd "$dstdir"                           || exit 2
b4ba4d
	"$pycompile" -m py_compile "$basename" || exit 2
b4ba4d
	cd "$refdir"
b4ba4d
done
b4ba4d
b4ba4d
exit 0