-
-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·203 lines (180 loc) · 5.81 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·203 lines (180 loc) · 5.81 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#!/bin/bash
set -e
# Pick a version from https://github.com/indygreg/python-build-standalone/releases
# Assets look like cpython-${PYTHON_VERSION}+${PYTHON_BUILD_DATE}-...
# Must be >=3.10 to support PREVIOUS.
PYTHON_VERSION=3.11.9
PYTHON_BUILD_DATE=20240726
# Call with os and arch.
# Or set $OSTYPE and $RUN_ARCH and call with nothing.
# OSTYPEs are aliased as follows:
# linux: linux-gnu*
# windows: msys*
# mac: darwin*
# Architecture values accepted are x64, x86, and arm64.
# Some brutal aliasing:
# arm64: arm64, aarch64
# x64: x64, amd64, x86_64
# Implemented permutations:
# linux x64,arm64
# windows x64,x86
# mac x64
os="$1"
if [[ "$os" = "" ]]; then
os="$OSTYPE"
fi
arch="$2"
if [[ "$arch" = "" ]]; then
arch="$RUN_ARCH"
fi
if [[ "$arch" = "" ]]; then
arch="x64"
fi
if [[ "$arch" = "amd64" ]]; then
arch="x64"
fi
if [[ "$arch" = "x86_64" ]]; then
arch="x64"
fi
if [[ "$arch" = "aarch64" ]]; then
arch="arm64"
fi
if [[ "$os" = "linux-gnu"* ]]; then
os="linux"
fi
if [[ "$os" = "linux-musl"* ]]; then
os="linux"
fi
if [[ "$os" = "msys"* || "$os" = "cygwin"* ]]; then
os="windows"
fi
if [[ "$os" = "darwin"* ]]; then
os="mac"
fi
function not_implemented {
echo "Combination of OS [$os] and architecture [$arch] not implemented yet"
exit 1
}
function fetch_python {
download="$1"
if [[ ! -e core/cpython.tar.gz ]]; then
curl -L https://github.com/indygreg/python-build-standalone/releases/download/$download -o core/cpython.tar.gz
fi
}
function unpack_python {
cd core
tar xfz cpython.tar.gz
cd ..
}
function fetch_msapi {
if [[ ! -e core/api.zip ]]; then
# version of a needed dll reconstructed for blender based on wine
curl -L https://github.com/nalexandru/api-ms-win-core-path-HACK/releases/download/0.3.1/api-ms-win-core-path-blender-0.3.1.zip -o core/api.zip
fi
}
function unpack_msapi {
if [[ "$arch" = "x86" ]]; then
cd core
unzip api.zip
cp api-ms-win-core-path-blender/x86/*.dll python/
cd ..
elif [[ "$arch" = "x64" ]]; then
cd core
unzip api.zip
cp api-ms-win-core-path-blender/x64/*.dll python/
cd ..
else
not_implemented
fi
}
function python_for_linux {
if [[ "$arch" = "x64" ]]; then
fetch_python ${PYTHON_BUILD_DATE}/cpython-${PYTHON_VERSION}+${PYTHON_BUILD_DATE}-x86_64_v3-unknown-linux-gnu-install_only.tar.gz
elif [[ "$arch" = "arm64" ]]; then
fetch_python ${PYTHON_BUILD_DATE}/cpython-${PYTHON_VERSION}+${PYTHON_BUILD_DATE}-aarch64-unknown-linux-gnu-install_only.tar.gz
else
not_implemented
fi
unpack_python
}
function python_for_windows {
if [[ "$arch" = "x64" ]]; then
fetch_python ${PYTHON_BUILD_DATE}/cpython-${PYTHON_VERSION}+${PYTHON_BUILD_DATE}-x86_64-pc-windows-msvc-shared-install_only.tar.gz
elif [[ "$arch" = "x86" ]]; then
fetch_python ${PYTHON_BUILD_DATE}/cpython-${PYTHON_VERSION}+${PYTHON_BUILD_DATE}-i686-pc-windows-msvc-shared-install_only.tar.gz
else
not_implemented
fi
fetch_msapi
unpack_python
unpack_msapi
}
function python_for_mac {
if [[ "$arch" = "x64" ]]; then
fetch_python ${PYTHON_BUILD_DATE}/cpython-${PYTHON_VERSION}+${PYTHON_BUILD_DATE}-x86_64-apple-darwin-install_only.tar.gz
elif [[ "$arch" = "arm64" ]]; then
fetch_python ${PYTHON_BUILD_DATE}/cpython-${PYTHON_VERSION}+${PYTHON_BUILD_DATE}-aarch64-apple-darwin-install_only.tar.gz
else
not_implemented
fi
unpack_python
}
set -x
echo "======================================================================="
echo "Fix paths for static resources that are node_module symlinks in core"
# Rebuilt from scratch every time: relinking alone leaves a link behind under its
# old name when one of these is renamed, and core/static_ext is packaged as-is.
rm -rf core/static_ext
mkdir -p core/static_ext
ln -sfn ../../node_modules/bootstrap-datepicker core/static_ext/bootstrap-datepicker
ln -sfn ../../node_modules/jquery core/static_ext/jquery
ln -sfn ../../node_modules/jquery-ui core/static_ext/jquery-ui
ln -sfn ../../node_modules/highlight.js/styles/default.css core/static_ext/hljs.default.css
echo ""
echo "======================================================================="
echo "Configure Grist to include external Electron code during build"
# We basically want core/ext to be a link to ext, for a lightly
# customized build of Grist. But there are two relative symlinks in ext to
# version information that now confuse the electron builder. So we make
# core/ext a real directory and place symlinks within it. Electron builder
# appears to cope okay with this. Links are absolute and unnested to make
# Windows happy.
rm -rf core/ext
mkdir core/ext
for source in ext/*; do
f=$(basename "$source")
ln -s "$(realpath "$source")" "core/ext/$f"
done
echo ""
echo "======================================================================="
echo "Make a self-contained version of Python available"
if [[ ! -e core/python ]]; then
python_for_$os || {
echo "Did not install self-contained Python for $os:$arch, will use end-user's system python3"
}
if [[ -e core/python/bin/python3 ]]; then
core/python/bin/python3 --version
fi
fi
echo ""
echo "======================================================================="
echo "Tweak typescript project layout"
# Make some links to make a valid typescript project and make editors happier to autocomplete
for d in buildtools app stubs; do
if [[ ! -e $d ]]; then
ln -s core/$d $d
fi
done
if [[ ! -e tsconfig.json ]]; then
ln -s core/tsconfig-ext.json tsconfig.json
fi
echo ""
echo "======================================================================="
echo "Get Pyodide ready"
cd core/sandbox/pyodide
# work around an awkward bug with sh + make + windows + runners
# https://github.com/actions/runner-images/issues/7253
bash ./setup.sh
make fetch_packages
# need at least one file for the directory to get unpacked by pyodide
touch _build/cache/EMPTY