Blob Blame History Raw
#!/bin/sh

# pycgen:    a build-time utiltiy script
# objective: generate the correcponding python byte-code (.pyc)
#            object files for one or more source python (.py)
#            scripts.

if [ -z "$PYCGEN_PYTHON" ]; then
	pycompile='python'
else
	pycompile="$PYCGEN_PYTHON"
fi

refdir=$(pwd)

for pysrc in $@; do
	basename=$(basename "$pysrc");
	dstdir=$(dirname "$pysrc")

	if [ -z "$dstdir" ]; then
		dstdir='.'
	fi

	cd "$dstdir"                           || exit 2
	"$pycompile" -m py_compile "$basename" || exit 2
	cd "$refdir"
done

exit 0