This repository was archived by the owner on Mar 1, 2026. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·107 lines (81 loc) · 2 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·107 lines (81 loc) · 2 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/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
compile_source() {
uv 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
cd dist/ && zip -r "$install_dir/$package_name".ts4script ./control_any_sim
cd ..
}
build_package() {
if ! [[ -d .s4-tools/ ]]; then
git clone https://github.com/simsonianlibrary/s4-shell-tools .s4-tools
fi
cd .s4-tools/
git reset --hard
git checkout 1ff833eb1e4fdd5af59e6886881738c493bf1082
npm i
npx tsc
mkdir -p out
cp -r dist/** out/
cd ..
node .s4-tools/out/S4ShellTools.js build --config package/build.yaml
}
install_dir="."
if [[ $deploy -eq 1 ]]; then
install_dir="$package_name"
mkdir -p "dist/$install_dir/"
fi
compile_source
build_package
cp package/build/ControlAnySim.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