summaryrefslogtreecommitdiff
path: root/project/pycgen.sh
diff options
context:
space:
mode:
Diffstat (limited to 'project/pycgen.sh')
-rwxr-xr-xproject/pycgen.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/project/pycgen.sh b/project/pycgen.sh
new file mode 100755
index 0000000..e9e0a15
--- /dev/null
+++ b/project/pycgen.sh
@@ -0,0 +1,29 @@
+#!/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