-
Notifications
You must be signed in to change notification settings - Fork 0
/
make-nuitka.sh
69 lines (69 loc) · 2.15 KB
/
make-nuitka.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
# Create executable from python project using Nuitka
echo "Called make-nuitka.sh with arguments:"
for arg in "$@"
do
echo "${arg}"
done
name="${1}"
entrypoint="${2}"
version="${3}"
dist="${4}"
assets="${5}"
description="${6}"
CI="${7}"
if [ -z "${name}" ]; then
name="ezsam"
fi
if [ -z "${entrypoint}" ]; then
entrypoint="src/${name}/gui/app.py"
fi
if [ -z "${version}" ]; then
version="0.0.0"
fi
if [ -z "${dist}" ]; then
dist="dist-nuitka"
fi
if [ -z "${assets}" ]; then
assets="src/ezsam/gui/assets"
fi
if [ -z "${description}" ]; then
description='ezsam - a tool to extract objects from images or video via text prompt - info at https://www.ezsam.org'
fi
tempdir="{TEMP}/ezsam" # Should match ezsam.lib.config.EXECUTABLE_NAME
outfile="${name}"
echo "Creating ${name}-${version} at `date` ..."
python -m nuitka --enable-plugin=tk-inter --onefile --assume-yes-for-downloads --enable-console \
--onefile-tempdir-spec="${tempdir}" \
--include-data-dir="${assets}=${assets}" \
--output-filename="${outfile}" \
--product-version="${version}" \
--file-version="${version}" \
--file-description="${description}" \
--output-dir="${dist}" "${entrypoint}"
# Move one-file executable to different folder and checksum
cd "${dist}"
mkdir -p "onefile"
mv "${outfile}" "onefile/${outfile}"
cd onefile
sha256sum "${outfile}" > "${outfile}.sha256"
cd ..
base=`basename ${entrypoint} .py`
outdir="${name}-${version}"
mv "${base}.dist" "${outdir}" # outdir will be zipped up in CI automatically
if [ -z "${CI}" ]; then
# No CI flag, running locally.
# We have zip executable locally and want to just directly create a useful archive and checksum.
echo "Running post-build tasks for local building at `date` ..."
zip -r "${outdir}.zip" "${outdir}"
sha256sum "${outdir}.zip" > "${outdir}.zip.sha256"
# Now that we have our archive undo move to prevent future runs of Nuikta from failing
mv "${outdir}" "${base}.dist"
else
# In CI, clean up build directories to save space
echo "Running post-build tasks for CI building at `date` ..."
rm -rf "${base}.build"
rm -rf "${base}.onefile-build"
fi
cd ..
echo "Finished creating ${name}-${version} at `date`"