-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
build.sh
executable file
·85 lines (63 loc) · 1.48 KB
/
build.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/env bash
set -euo pipefail
deploy=0
src="src"
package_name="ControlAnySim"
test=0
while [ "${1-}" != "" ]; do
case "$1" in
"--deploy")
deploy=1
;;
"--src")
shift
src="$1"
;;
"--package-name")
shift
package_name="$1"
;;
"--test")
test=1
;;
esac
shift
done
if [[ -f ".env" ]]; then
source .env
fi
rm -rf dist/
current_version=$(git describe --tag)
echo "__version__ = \"${current_version:1}\"" > src/control_any_sim/__init__.py
rye run python3 -m compileall $src/
for file in $(find $src -name '*.pyc')
do
file_new="${file/cpython-*.pyc/pyc}"
file_new="${file_new/__pycache__\//}"
file_new="${file_new/$src/dist}"
mkdir -p $(dirname $file_new)
mv "$file" "$file_new"
done
for cache_dir in $(find $src -name '__pycache__')
do
rm -r $cache_dir
done
install_dir="."
if [[ $deploy -eq 1 ]]; then
install_dir="$package_name"
mkdir -p dist/$install_dir/
fi
cd dist/ && zip -r $install_dir/$package_name.ts4script ./control_any_sim
cd ..
cp package/*.package dist/$install_dir/
cp LICENSE dist/$install_dir/LICENSE.txt
if [[ $deploy -eq 1 ]]; then
cd dist/
zip -r $package_name.zip ./$install_dir
cd ..
fi
git checkout src/control_any_sim/__init__.py
if [[ $test -eq 1 ]]; then
cp -r dist/$install_dir/*.{package,ts4script} "$TS4_MODS_DIR/$package_name/"
"$TS4_BIN"
fi