summaryrefslogtreecommitdiff
path: root/lang/python3/files/python3-package-install.sh
diff options
context:
space:
mode:
authorAlexandru Ardelean <ardeleanalex@gmail.com>2017-03-02 18:02:14 +0200
committerAlexandru Ardelean <ardeleanalex@gmail.com>2017-03-09 18:43:47 +0200
commitae350d938785bb72161dc21f94ea947ee3d9bf1b (patch)
treee23b144f997873ca39d02048313016396e62587b /lang/python3/files/python3-package-install.sh
parent20685f522067271662c8c425a12e4822de08093d (diff)
python3: split source packages away from compiled packages
Same as for python. Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Diffstat (limited to 'lang/python3/files/python3-package-install.sh')
-rw-r--r--lang/python3/files/python3-package-install.sh33
1 files changed, 32 insertions, 1 deletions
diff --git a/lang/python3/files/python3-package-install.sh b/lang/python3/files/python3-package-install.sh
index c3de0cc95..cc1005189 100644
--- a/lang/python3/files/python3-package-install.sh
+++ b/lang/python3/files/python3-package-install.sh
@@ -34,5 +34,36 @@ process_filespec() {
)
}
-process_filespec "$1" "$2" "$3"
+src_dir="$1"
+dst_dir="$2"
+python="$3"
+mode="$4"
+filespec="$5"
+process_filespec "$src_dir" "$dst_dir" "$filespec" || {
+ echo "process filespec error-ed"
+ exit 1
+}
+
+if [ "$mode" == "sources" ] ; then
+ # Copy only python source files
+ find $dst_dir -not -name "*\.py" | xargs rm -f
+ # Delete empty folders (if the case)
+ find $dst_dir/usr -type d | xargs rmdir &> /dev/null
+ rmdir $dst_dir/usr &> /dev/null
+ exit 0
+fi
+
+# XXX [So that you won't goof as I did]
+# Note: Yes, I tried to use the -O & -OO flags here.
+# However the generated byte-codes were not portable.
+# So, we just stuck to un-optimized byte-codes,
+# which is still way better/faster than running
+# Python sources all the time.
+$python -m compileall -b -d '/' $dst_dir || {
+ echo "python -m compileall err-ed"
+ exit 1
+}
+# Delete source files and pyc [ un-optimized bytecode files ]
+# We may want to make this optimization thing configurable later, but not sure atm
+find $dst_dir -name "*\.py" | xargs rm -f