Created
July 29, 2016 13:16
-
-
Save reimai/6ba8b1139a6f64caf0b53e4fb470bfba to your computer and use it in GitHub Desktop.
pack several python scripts to an executable archive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# packs python scripts to an executable, the first script must be the main script | |
# example: pyzip quotes find_quotes.py dx.py | |
name=$(basename "$0") | |
usage="$name name_of_executable main_script.py [other python scripts]" | |
executable=${1?usage} | |
main_script=${2?usage} | |
scripts=${@:3} | |
tmp="$$" | |
mkdir "$tmp" | |
cp $main_script "$tmp/__main__.py" | |
for s in $scripts; do | |
cp $s "$tmp/" | |
done | |
zip --junk-paths "$tmp/$executable.zip" $tmp/*.py | |
echo '#!/usr/bin/env python' | cat - "$tmp/$executable.zip" > "$executable" | |
rm -r "$tmp" | |
chmod +x "$executable" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment