diff options
author | midipix <writeonce@midipix.org> | 2018-12-04 14:36:15 -0500 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2018-12-06 20:58:23 -0500 |
commit | b4ba4d03690069a068f1a7b7852524655ac743af (patch) | |
tree | 9e321384b4567586e253ffc7061a99c47ea22553 /project/pycgen.sh | |
parent | 85773dcd2c06f26a7477508625ebea362ed51977 (diff) | |
download | sbpython2-b4ba4d03690069a068f1a7b7852524655ac743af.tar.bz2 sbpython2-b4ba4d03690069a068f1a7b7852524655ac743af.tar.xz |
project: added the pycopy.sh and pycgen.sh build-time utility scripts.
Diffstat (limited to 'project/pycgen.sh')
-rwxr-xr-x | project/pycgen.sh | 29 |
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 |