forked from irmen/bouldercaves
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_zipapp.sh
executable file
·51 lines (41 loc) · 1.19 KB
/
make_zipapp.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/sh
OUTFILE="bouldercaves.pyz"
OUTFILESYNTH="bouldercaves-synth.pyz"
TMPFILE="@bouldercaves.zip"
echo
echo Creating self-contained executable Python zip file applications
echo ---------------------------------------------------------------
echo
find . -name '*.pyc' -exec rm {} \;
find . -name __pycache__ -exec rm -r {} \;
rm -f ${TMPFILE} *.pyz
# create the zipapp including the sound files
echo with samples...
cat <<EOT > __main__.py
import sys
from bouldercaves import game
game.start(sys.argv[1:])
EOT
7z a -tzip -mx=9 ${TMPFILE} bouldercaves __main__.py > /dev/null
echo "#!/usr/bin/env python3" > ${OUTFILE}
cat ${TMPFILE} >> ${OUTFILE}
chmod u+x ${OUTFILE}
rm ${TMPFILE}
# create the zipapp without any sound files, relying on the synth alone
echo without samples...
cat <<EOT > __main__.py
import sys
from bouldercaves import game
game.start(["--synth"] + sys.argv[1:])
EOT
7z a -tzip -mx=9 ${TMPFILE} '-xr!bouldercaves/sounds/*' bouldercaves __main__.py > /dev/null
echo "#!/usr/bin/env python3" > ${OUTFILESYNTH}
cat ${TMPFILE} >> ${OUTFILESYNTH}
chmod u+x ${OUTFILESYNTH}
rm ${TMPFILE}
rm __main__.py
echo
echo Done, output files are:
echo -----------------------
ls -shk -c1 *.pyz
echo