@gen3/workspaces 0.12.63 → 0.12.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/dist/dts/components/MicroContainerPanel.stories.d.ts +6 -2
- package/dist/dts/components/MicroContainerPanel.stories.d.ts.map +1 -1
- package/dist/dts/components/MicroContainerPanel.stories.js +1 -1
- package/dist/dts/components/MicroContainerPanel.stories.js.map +1 -1
- package/dist/dts/components/MicroContainerReduxPanel.d.ts +3 -5
- package/dist/dts/components/MicroContainerReduxPanel.d.ts.map +1 -1
- package/dist/dts/components/MicroContainerReduxPanel.js +32 -6
- package/dist/dts/components/MicroContainerReduxPanel.js.map +1 -1
- package/dist/dts/pages/WorkspacesCenter/data.d.ts.map +1 -1
- package/dist/dts/pages/WorkspacesCenter/data.js +4 -1
- package/dist/dts/pages/WorkspacesCenter/data.js.map +1 -1
- package/dist/dts/providers/types.d.ts +1 -1
- package/dist/dts/providers/types.d.ts.map +1 -1
- package/dist/dts/providers/useMicroContainerRedux.d.ts.map +1 -1
- package/dist/dts/providers/useMicroContainerRedux.js +8 -2
- package/dist/dts/providers/useMicroContainerRedux.js.map +1 -1
- package/dist/dts/workspace/WorkspaceCenter.d.ts.map +1 -1
- package/dist/dts/workspace/WorkspaceCenter.js +1 -1
- package/dist/dts/workspace/WorkspaceCenter.js.map +1 -1
- package/dist/dts/workspace/WorkspaceLayout/WorkspaceLayout.d.ts.map +1 -1
- package/dist/dts/workspace/WorkspaceLayout/WorkspaceLayout.js +1 -1
- package/dist/dts/workspace/WorkspaceLayout/WorkspaceLayout.js.map +1 -1
- package/dist/dts/workspace/tiers/RemoteComputeWorkspace.d.ts +1 -0
- package/dist/dts/workspace/tiers/RemoteComputeWorkspace.d.ts.map +1 -1
- package/dist/dts/workspace/tiers/RemoteComputeWorkspace.js +2 -2
- package/dist/dts/workspace/tiers/RemoteComputeWorkspace.js.map +1 -1
- package/dist/dts/workspace/tiers/types.d.ts +2 -0
- package/dist/dts/workspace/tiers/types.d.ts.map +1 -1
- package/dist/index/cjs/index.js +97 -25
- package/dist/index/cjs/index.js.map +1 -1
- package/dist/index/esm/index.js +98 -26
- package/dist/index/esm/index.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/jupyterlite-builds/free-private/jupyter_lite_config.json +5 -19
- package/dist/jupyterlite-builds/free-private/requirements.txt +1 -1
- package/dist/jupyterlite-builds/scripts/build-gen3sdk-lite.sh +428 -0
- package/dist/jupyterlite-builds/scripts/build-jupyterlite.sh +150 -33
- package/dist/jupyterlite-builds/scripts/setup-env.sh +81 -0
- package/dist/jupyterlite-builds/scripts/sync-jupyter-assets-into-package.sh +19 -2
- package/dist/jupyterlite-builds/scripts/validate-jupyterlite-assets.sh +3 -0
- package/jupyterlite-builds/free-private/jupyter_lite_config.json +5 -19
- package/jupyterlite-builds/free-private/requirements.txt +1 -1
- package/package.json +7 -4
- package/scripts/build-gen3sdk-lite.sh +428 -0
- package/scripts/build-jupyterlite.sh +150 -33
- package/scripts/patch-pyidode-lock.py +100 -0
- package/scripts/setup-env.sh +81 -0
- package/scripts/sync-jupyter-assets-into-package.sh +19 -2
- package/scripts/validate-jupyterlite-assets.sh +3 -0
- package/dist/jupyterlite-builds/free-private/.cache/pyodide-lock/_work/constraints.txt +0 -354
- package/dist/jupyterlite-builds/free-private/.cache/pyodide-lock/_work/excludes.txt +0 -3
- package/dist/jupyterlite-builds/free-private/.cache/pyodide-lock/_work/requirements.in +0 -11
- package/dist/jupyterlite-builds/free-private/.cache/pyodide-lock/pyodide-lock.json +0 -1
- package/dist/jupyterlite-builds/free-private/.cache/pyodide-lock/remote-pyodide-lock.json +0 -1
- package/dist/jupyterlite-builds/free-private/dist/cdislogging-1.2.0-py3-none-any.whl +0 -0
- package/dist/jupyterlite-builds/free-private/dist/dictionaryutils-4.0.0-py3-none-any.whl +0 -0
- package/dist/jupyterlite-builds/free-private/dist/drsclient-0.4.0-py3-none-any.whl +0 -0
- package/dist/jupyterlite-builds/free-private/dist/fastavro-1.12.2-cp313-cp313-pyemscripten_2025_0_wasm32.whl +0 -0
- package/dist/jupyterlite-builds/free-private/dist/gen3-4.28.2-py3-none-any.whl +0 -0
- package/dist/jupyterlite-builds/free-private/dist/gen3datamodel-4.0.1-py3-none-any.whl +0 -0
- package/dist/jupyterlite-builds/free-private/dist/pypfb-0.6.2-py3-none-any.whl +0 -0
- package/dist/jupyterlite-builds/free-private/dist/python_json_logger-4.2.0-py3-none-any.whl +0 -0
- package/jupyterlite-builds/free-private/dist/cdislogging-1.2.0-py3-none-any.whl +0 -0
- package/jupyterlite-builds/free-private/dist/dictionaryutils-4.0.0-py3-none-any.whl +0 -0
- package/jupyterlite-builds/free-private/dist/drsclient-0.4.0-py3-none-any.whl +0 -0
- package/jupyterlite-builds/free-private/dist/fastavro-1.12.2-cp313-cp313-pyemscripten_2025_0_wasm32.whl +0 -0
- package/jupyterlite-builds/free-private/dist/gen3-4.28.2-py3-none-any.whl +0 -0
- package/jupyterlite-builds/free-private/dist/gen3datamodel-4.0.1-py3-none-any.whl +0 -0
- package/jupyterlite-builds/free-private/dist/pypfb-0.6.2-py3-none-any.whl +0 -0
- package/jupyterlite-builds/free-private/dist/python_json_logger-4.2.0-py3-none-any.whl +0 -0
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# =============================================================================
|
|
3
|
+
# build-gen3sdk-lite.sh — Build Gen3 SDK and dependencies as pure-Python wheels
|
|
4
|
+
#
|
|
5
|
+
# All packages in REPOS are pure Python (fastavro has Python fallbacks for its
|
|
6
|
+
# C extensions). They are therefore built with `pip wheel` and retagged to
|
|
7
|
+
# py3-none-any, which loads under any Pyodide/Python version.
|
|
8
|
+
#
|
|
9
|
+
# If a package with genuine C extensions is added to REPOS, the pure-Python
|
|
10
|
+
# assertion below will fail the build rather than silently shipping a wheel
|
|
11
|
+
# that cannot load in the browser.
|
|
12
|
+
#
|
|
13
|
+
# Prerequisites:
|
|
14
|
+
# - uv (https://docs.astral.sh/uv/getting-started/installation/)
|
|
15
|
+
# - git
|
|
16
|
+
#
|
|
17
|
+
# Usage:
|
|
18
|
+
# ./build-gen3sdk-lite.sh # full build (setup + all packages)
|
|
19
|
+
# ./build-gen3sdk-lite.sh --setup # environment setup only
|
|
20
|
+
# ./build-gen3sdk-lite.sh --build # build wheels only (assumes setup done)
|
|
21
|
+
# ./build-gen3sdk-lite.sh --clean # remove build artifacts
|
|
22
|
+
# =============================================================================
|
|
23
|
+
set -euo pipefail
|
|
24
|
+
|
|
25
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
26
|
+
|
|
27
|
+
# ── Parse flags (strip before positional args are consumed) ──────────────────
|
|
28
|
+
NO_EXTRAS=false
|
|
29
|
+
POSITIONAL_ARGS=()
|
|
30
|
+
for _arg in "$@"; do
|
|
31
|
+
case "$_arg" in
|
|
32
|
+
--no-extras) NO_EXTRAS=true ;;
|
|
33
|
+
*) POSITIONAL_ARGS+=("$_arg") ;;
|
|
34
|
+
esac
|
|
35
|
+
done
|
|
36
|
+
set -- "${POSITIONAL_ARGS[@]+"${POSITIONAL_ARGS[@]}"}"
|
|
37
|
+
|
|
38
|
+
# ── Path constants (always defined, no external dependency) ──────────────────
|
|
39
|
+
ROOT_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
|
40
|
+
SRC_DIR="$ROOT_DIR/free-private"
|
|
41
|
+
|
|
42
|
+
# Resolves a possibly-relative path against INIT_CWD (or $PWD) rather than
|
|
43
|
+
# whatever directory happens to be current when this runs. See setup-env.sh
|
|
44
|
+
# for why: it's what keeps a relative build_dir out of dist/ or node_modules.
|
|
45
|
+
_resolve_against_init_cwd() {
|
|
46
|
+
local path="$1"
|
|
47
|
+
local base="${INIT_CWD:-$(pwd)}"
|
|
48
|
+
case "$path" in
|
|
49
|
+
/*) printf '%s' "$path" ;;
|
|
50
|
+
*) printf '%s/%s' "$base" "$path" ;;
|
|
51
|
+
esac
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
BUILD_DIR="$(_resolve_against_init_cwd "${2:-builds}")"
|
|
55
|
+
mkdir -p "$BUILD_DIR"
|
|
56
|
+
BUILD_DIR="$(cd "$BUILD_DIR" && pwd)"
|
|
57
|
+
|
|
58
|
+
VENV_DIR="$BUILD_DIR/.venv"
|
|
59
|
+
WORK_DIR="$BUILD_DIR/work"
|
|
60
|
+
SOURCES_DIR="$BUILD_DIR/sources"
|
|
61
|
+
OUTPUT_DIR="$BUILD_DIR/pypi"
|
|
62
|
+
LOG_DIR="$BUILD_DIR/logs"
|
|
63
|
+
|
|
64
|
+
export BUILD_DIR # setup-env.sh reads this
|
|
65
|
+
|
|
66
|
+
# Browser Python version, used for `pip download` of pure-Python extras.
|
|
67
|
+
# Must match jupyterlite_pyodide_kernel.constants.PYODIDE_PYTHON_VERSION.
|
|
68
|
+
# Check with:
|
|
69
|
+
# python -c "from jupyterlite_pyodide_kernel.constants import \
|
|
70
|
+
# PYODIDE_PYTHON_VERSION; print(PYODIDE_PYTHON_VERSION)"
|
|
71
|
+
BROWSER_PYTHON_TAG="${BROWSER_PYTHON_TAG:-314}"
|
|
72
|
+
|
|
73
|
+
# ── Colours / helpers (available immediately, before setup-env.sh) ───────────
|
|
74
|
+
RED='\033[0;31m'
|
|
75
|
+
GREEN='\033[0;32m'
|
|
76
|
+
YELLOW='\033[1;33m'
|
|
77
|
+
CYAN='\033[0;36m'
|
|
78
|
+
NC='\033[0m'
|
|
79
|
+
|
|
80
|
+
info() { echo -e "${CYAN}[INFO]${NC} $*"; }
|
|
81
|
+
success() { echo -e "${GREEN}[OK]${NC} $*"; }
|
|
82
|
+
warn() { echo -e "${YELLOW}[WARN]${NC} $*"; }
|
|
83
|
+
fail() { echo -e "${RED}[FAIL]${NC} $*"; exit 1; }
|
|
84
|
+
|
|
85
|
+
elapsed() {
|
|
86
|
+
local t=$1
|
|
87
|
+
printf '%dm%ds' $((t/60)) $((t%60))
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
# Portable in-place sed. GNU sed reads `-i ''` as the script and the following
|
|
91
|
+
# expression as a filename; BSD/macOS sed requires the empty suffix. Detect once.
|
|
92
|
+
if sed --version >/dev/null 2>&1; then
|
|
93
|
+
sedi() { sed -i "$@"; } # GNU
|
|
94
|
+
else
|
|
95
|
+
sedi() { sed -i '' "$@"; } # BSD / macOS
|
|
96
|
+
fi
|
|
97
|
+
|
|
98
|
+
# Apply a sed substitution and fail loudly if it changed nothing. `sed` exits 0
|
|
99
|
+
# on a non-match, which previously let stale patterns pass as "Patched …".
|
|
100
|
+
patch_file() {
|
|
101
|
+
local desc="$1" expr="$2" path="$3"
|
|
102
|
+
[[ -f "$path" ]] || { warn "${desc}: file not found, skipping (${path})"; return 0; }
|
|
103
|
+
local before after
|
|
104
|
+
before="$(cat "$path")"
|
|
105
|
+
sedi "$expr" "$path"
|
|
106
|
+
after="$(cat "$path")"
|
|
107
|
+
if [[ "$before" == "$after" ]]; then
|
|
108
|
+
warn "${desc}: pattern did not match — upstream may have changed"
|
|
109
|
+
return 0
|
|
110
|
+
fi
|
|
111
|
+
info "${desc}"
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
# ── Repositories to build (order matters — independent packages first) ───────
|
|
115
|
+
# Format: "name|git_url|subdir" (subdir is optional)
|
|
116
|
+
REPOS=(
|
|
117
|
+
"cdislogging|https://github.com/uc-cdis/cdislogging.git"
|
|
118
|
+
"python-json-logger|https://github.com/nhairs/python-json-logger.git"
|
|
119
|
+
"fastavro|https://github.com/fastavro/fastavro.git"
|
|
120
|
+
"drsclient|https://github.com/uc-cdis/drsclient.git"
|
|
121
|
+
"indexd|https://github.com/uc-cdis/indexd.git|indexclient"
|
|
122
|
+
"dictionaryutils|https://github.com/uc-cdis/dictionaryutils.git"
|
|
123
|
+
"pypfb|https://github.com/uc-cdis/pypfb.git"
|
|
124
|
+
"gen3sdk-python|https://github.com/uc-cdis/gen3sdk-python.git"
|
|
125
|
+
"gen3users|https://github.com/uc-cdis/gen3users.git"
|
|
126
|
+
"gen3dictionary|https://github.com/uc-cdis/datadictionary.git"
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
# ── Source shared environment (venv + Python + core tooling) ────────────────
|
|
130
|
+
source_shared_env() {
|
|
131
|
+
# shellcheck disable=SC1091
|
|
132
|
+
source "${SCRIPT_DIR}/setup-env.sh"
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
# ── Environment setup ───────────────────────────────────────────────────────
|
|
136
|
+
setup_environment() {
|
|
137
|
+
source_shared_env
|
|
138
|
+
mkdir -p "${WORK_DIR}" "${SOURCES_DIR}" "${OUTPUT_DIR}" "${LOG_DIR}"
|
|
139
|
+
|
|
140
|
+
# `wheel` provides `python -m wheel tags`, used to retag to py3-none-any.
|
|
141
|
+
info "Installing wheel …"
|
|
142
|
+
uv pip install wheel 2>&1 | tail -2
|
|
143
|
+
success "Build tooling ready"
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
# ── Clone / update sources ──────────────────────────────────────────────────
|
|
147
|
+
clone_repos() {
|
|
148
|
+
info "Cloning / updating repositories …"
|
|
149
|
+
for entry in "${REPOS[@]}"; do
|
|
150
|
+
IFS='|' read -r name url _subdir <<< "${entry}"
|
|
151
|
+
local dest="${SOURCES_DIR}/${name}"
|
|
152
|
+
if [[ -d "${dest}/.git" ]]; then
|
|
153
|
+
# Sources are patched in place below, so a pull would conflict. Reset to
|
|
154
|
+
# a clean tree first, otherwise the pull fails silently through the pipe.
|
|
155
|
+
info " ${name}: resetting and pulling latest …"
|
|
156
|
+
git -C "${dest}" checkout -- . 2>&1 | tail -1 || true
|
|
157
|
+
git -C "${dest}" pull --ff-only 2>&1 | tail -1
|
|
158
|
+
else
|
|
159
|
+
info " ${name}: cloning …"
|
|
160
|
+
git clone "${url}" "${dest}" 2>&1 | tail -1
|
|
161
|
+
fi
|
|
162
|
+
done
|
|
163
|
+
success "All repositories ready"
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
# ── Source patches ──────────────────────────────────────────────────────────
|
|
167
|
+
apply_patches() {
|
|
168
|
+
# gen3users: old poetry.masonry.api → poetry.core.masonry.api
|
|
169
|
+
patch_file "Patched gen3users: build-backend updated to poetry.core.masonry.api" \
|
|
170
|
+
's|build-backend = "poetry.masonry.api"|build-backend = "poetry.core.masonry.api"|' \
|
|
171
|
+
"${SOURCES_DIR}/gen3users/pyproject.toml"
|
|
172
|
+
|
|
173
|
+
# gen3sdk-python: relax indexclient pin so the locally built 6.3.0 satisfies it
|
|
174
|
+
patch_file "Patched gen3sdk-python: indexclient constraint relaxed to >=2.3.0" \
|
|
175
|
+
's/indexclient = "\^2\.3\.0"/indexclient = ">=2.3.0"/' \
|
|
176
|
+
"${SOURCES_DIR}/gen3sdk-python/pyproject.toml"
|
|
177
|
+
|
|
178
|
+
# dictionaryutils: relax the jsonschema pin.
|
|
179
|
+
#
|
|
180
|
+
# NOTE: upstream pins jsonschema<=4.23.0 deliberately — "limiting to a version
|
|
181
|
+
# where RefResolver is deprecated but still functioning". Relaxing it resolves
|
|
182
|
+
# jsonschema 4.26.0 in the browser, where RefResolver exists only as a
|
|
183
|
+
# module-level __getattr__ shim forwarding to validators._RefResolver. It
|
|
184
|
+
# imports and works today, but this is borrowed time. If dictionaryutils
|
|
185
|
+
# starts failing on import, this patch is the first thing to revert.
|
|
186
|
+
patch_file "Patched dictionaryutils: jsonschema constraint relaxed to >=4.0.0" \
|
|
187
|
+
's/jsonschema = "<=4\.23\.0"/jsonschema = ">=4.0.0"/' \
|
|
188
|
+
"${SOURCES_DIR}/dictionaryutils/pyproject.toml"
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
# fastavro: force setup.py to skip building the Cython/C extensions.
|
|
193
|
+
#
|
|
194
|
+
# FASTAVRO_USE_PYTHON only selects the pure-Python fallback at import time
|
|
195
|
+
# (fastavro/__init__.py) — setup.py itself always builds the _read/_write/
|
|
196
|
+
# etc. extensions unless the interpreter is PyPy, so `pip wheel` still
|
|
197
|
+
# invokes `cc`, which the build image doesn't have.yes Short-circuit the PyPy check instead
|
|
198
|
+
# so ext_modules stays empty and the wheel is genuinely pure Python.
|
|
199
|
+
patch_file "Patched fastavro: setup.py forced to skip C extensions" \
|
|
200
|
+
's/if not hasattr(sys, "pypy_version_info"):/if False: # gen3-lite: force pure-Python build/' \
|
|
201
|
+
"${SOURCES_DIR}/fastavro/setup.py"
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
# ── Build wheels ────────────────────────────────────────────────────────────
|
|
205
|
+
build_wheels() {
|
|
206
|
+
# shellcheck disable=SC1091
|
|
207
|
+
source "${VENV_DIR}/bin/activate"
|
|
208
|
+
|
|
209
|
+
local total=${#REPOS[@]}
|
|
210
|
+
local built=0
|
|
211
|
+
local failed=0
|
|
212
|
+
local failed_names=()
|
|
213
|
+
|
|
214
|
+
apply_patches
|
|
215
|
+
|
|
216
|
+
info "Building ${total} packages …"
|
|
217
|
+
echo ""
|
|
218
|
+
|
|
219
|
+
for entry in "${REPOS[@]}"; do
|
|
220
|
+
IFS='|' read -r name _url subdir <<< "${entry}"
|
|
221
|
+
local src="${SOURCES_DIR}/${name}"
|
|
222
|
+
local build_dir="${src}"
|
|
223
|
+
[[ -n "${subdir}" ]] && build_dir="${src}/${subdir}"
|
|
224
|
+
local logfile="${LOG_DIR}/${name}.log"
|
|
225
|
+
local start_ts
|
|
226
|
+
start_ts=$(date +%s)
|
|
227
|
+
|
|
228
|
+
local label="${name}"
|
|
229
|
+
[[ -n "${subdir}" ]] && label="${name}/${subdir}"
|
|
230
|
+
printf " [%d/%d] %-25s " $((built + failed + 1)) "${total}" "${label}"
|
|
231
|
+
|
|
232
|
+
# Build as a normal wheel, then force the py3-none-any tag. `pip wheel` can
|
|
233
|
+
# emit a platform-specific tag on macOS even for pure Python; retagging
|
|
234
|
+
# makes the result portable and loadable by micropip under any Pyodide ABI.
|
|
235
|
+
local build_cmd='rm -rf dist && pip wheel . --no-deps -w dist/ \
|
|
236
|
+
&& python -m wheel tags --python-tag py3 --abi-tag none --platform-tag any --remove dist/*.whl'
|
|
237
|
+
|
|
238
|
+
# fastavro ships Python fallbacks for every C extension; this env var
|
|
239
|
+
# selects them so no compiler is needed and the wheel stays pure Python.
|
|
240
|
+
[[ "${name}" == "fastavro" ]] && build_cmd="FASTAVRO_USE_PYTHON=1 ${build_cmd}"
|
|
241
|
+
|
|
242
|
+
if (cd "${build_dir}" && eval "${build_cmd}") > "${logfile}" 2>&1; then
|
|
243
|
+
local end_ts
|
|
244
|
+
end_ts=$(date +%s)
|
|
245
|
+
echo -e "${GREEN}OK${NC} ($(elapsed $((end_ts - start_ts))))"
|
|
246
|
+
built=$((built + 1))
|
|
247
|
+
else
|
|
248
|
+
local end_ts
|
|
249
|
+
end_ts=$(date +%s)
|
|
250
|
+
echo -e "${RED}FAILED${NC} ($(elapsed $((end_ts - start_ts)))) — see ${logfile}"
|
|
251
|
+
failed=$((failed + 1))
|
|
252
|
+
failed_names+=("${name}")
|
|
253
|
+
fi
|
|
254
|
+
done
|
|
255
|
+
|
|
256
|
+
echo ""
|
|
257
|
+
|
|
258
|
+
# ── Collect wheels ─────────────────────────────────────────────────────
|
|
259
|
+
info "Collecting .whl files into ${OUTPUT_DIR} …"
|
|
260
|
+
local count=0
|
|
261
|
+
for entry in "${REPOS[@]}"; do
|
|
262
|
+
IFS='|' read -r name _url subdir <<< "${entry}"
|
|
263
|
+
local src="${SOURCES_DIR}/${name}"
|
|
264
|
+
local build_dir="${src}"
|
|
265
|
+
[[ -n "${subdir}" ]] && build_dir="${src}/${subdir}"
|
|
266
|
+
if compgen -G "${build_dir}/dist/*.whl" > /dev/null 2>&1; then
|
|
267
|
+
cp "${build_dir}"/dist/*.whl "${OUTPUT_DIR}/"
|
|
268
|
+
count=$((count + $(ls -1 "${build_dir}"/dist/*.whl 2>/dev/null | wc -l)))
|
|
269
|
+
fi
|
|
270
|
+
done
|
|
271
|
+
|
|
272
|
+
download_extras
|
|
273
|
+
|
|
274
|
+
verify_pure_python
|
|
275
|
+
|
|
276
|
+
# ── Summary ────────────────────────────────────────────────────────────
|
|
277
|
+
echo ""
|
|
278
|
+
echo "========================================="
|
|
279
|
+
echo " Build Summary"
|
|
280
|
+
echo "========================================="
|
|
281
|
+
echo " Succeeded : ${built}"
|
|
282
|
+
echo " Failed : ${failed}"
|
|
283
|
+
echo " Wheels : ${count} built, $(ls -1 "${OUTPUT_DIR}"/*.whl 2>/dev/null | wc -l | tr -d ' ') total in ${OUTPUT_DIR}/"
|
|
284
|
+
if (( failed > 0 )); then
|
|
285
|
+
echo ""
|
|
286
|
+
echo " Failed packages:"
|
|
287
|
+
for n in "${failed_names[@]}"; do
|
|
288
|
+
echo " - ${n} (log: ${LOG_DIR}/${n}.log)"
|
|
289
|
+
done
|
|
290
|
+
fi
|
|
291
|
+
echo "========================================="
|
|
292
|
+
echo ""
|
|
293
|
+
|
|
294
|
+
if (( failed > 0 )); then
|
|
295
|
+
warn "Some packages failed. Check the logs above."
|
|
296
|
+
return 1
|
|
297
|
+
fi
|
|
298
|
+
|
|
299
|
+
success "All wheels built and collected in ${OUTPUT_DIR}/"
|
|
300
|
+
echo ""
|
|
301
|
+
ls -lh "${OUTPUT_DIR}"/*.whl
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
# ── Pure-Python deps not present in the Pyodide distribution ────────────────
|
|
305
|
+
# PyodideLockAddon is disabled (it cannot resolve a vendored local distribution
|
|
306
|
+
# in jupyterlite-pyodide-kernel 0.8.5), so nothing resolves these for us. They
|
|
307
|
+
# reach the browser through PipliteAddon, which indexes everything in
|
|
308
|
+
# OUTPUT_DIR. Without them, micropip falls back to PyPI at runtime.
|
|
309
|
+
download_extras() {
|
|
310
|
+
if [[ "${NO_EXTRAS}" == "true" ]]; then
|
|
311
|
+
info "Skipping pure-Python extras download (--no-extras)"
|
|
312
|
+
warn " gen3's pure-Python deps will be fetched from PyPI in the browser"
|
|
313
|
+
return 0
|
|
314
|
+
fi
|
|
315
|
+
|
|
316
|
+
local deps=(
|
|
317
|
+
"aiofiles"
|
|
318
|
+
"backoff"
|
|
319
|
+
"dataclasses-json<=0.5.9"
|
|
320
|
+
"humanfriendly"
|
|
321
|
+
"importlib-metadata>=8,<9"
|
|
322
|
+
"marshmallow>=3.3.0,<4.0.0"
|
|
323
|
+
"marshmallow-enum"
|
|
324
|
+
"mypy-extensions"
|
|
325
|
+
"python-dateutil"
|
|
326
|
+
"typing-inspect"
|
|
327
|
+
"xmltodict>=0.13.0,<0.14.0"
|
|
328
|
+
"zipp"
|
|
329
|
+
)
|
|
330
|
+
|
|
331
|
+
info "Downloading pure-Python deps missing from the Pyodide distribution …"
|
|
332
|
+
local dep base
|
|
333
|
+
for dep in "${deps[@]}"; do
|
|
334
|
+
# Strip any version specifier to get the distribution name for the glob.
|
|
335
|
+
base="${dep%%[<>=!~]*}"
|
|
336
|
+
if compgen -G "${OUTPUT_DIR}/${base//-/_}-*.whl" > /dev/null 2>&1 || \
|
|
337
|
+
compgen -G "${OUTPUT_DIR}/${base}-*.whl" > /dev/null 2>&1; then
|
|
338
|
+
info " ${base}: already present, skipping"
|
|
339
|
+
continue
|
|
340
|
+
fi
|
|
341
|
+
if pip download "${dep}" \
|
|
342
|
+
--no-deps \
|
|
343
|
+
--only-binary=:all: \
|
|
344
|
+
--python-version "${BROWSER_PYTHON_TAG}" \
|
|
345
|
+
--platform any \
|
|
346
|
+
-d "${OUTPUT_DIR}" \
|
|
347
|
+
--quiet 2>/dev/null; then
|
|
348
|
+
info " ${base}: downloaded"
|
|
349
|
+
else
|
|
350
|
+
warn " ${base}: download failed — will fall back to PyPI in the browser"
|
|
351
|
+
fi
|
|
352
|
+
done
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
# ── Verify every wheel is loadable in the browser ───────────────────────────
|
|
356
|
+
verify_pure_python() {
|
|
357
|
+
info "Verifying all wheels are pure-Python (py3-none-any) …"
|
|
358
|
+
local bad=()
|
|
359
|
+
local whl base
|
|
360
|
+
for whl in "${OUTPUT_DIR}"/*.whl; do
|
|
361
|
+
[[ -f "${whl}" ]] || continue
|
|
362
|
+
base="$(basename "${whl}")"
|
|
363
|
+
case "${base}" in
|
|
364
|
+
*-py3-none-any.whl|*-py2.py3-none-any.whl) ;;
|
|
365
|
+
*) bad+=("${base}") ;;
|
|
366
|
+
esac
|
|
367
|
+
done
|
|
368
|
+
|
|
369
|
+
if (( ${#bad[@]} > 0 )); then
|
|
370
|
+
for base in "${bad[@]}"; do
|
|
371
|
+
warn " not pure-Python: ${base}"
|
|
372
|
+
done
|
|
373
|
+
fail "${#bad[@]} wheel(s) carry a platform tag and cannot load in the browser.
|
|
374
|
+
Either the package has real C extensions (it needs a Pyodide-ABI build
|
|
375
|
+
matching the vendored distribution), or 'python -m wheel tags' did not
|
|
376
|
+
run. Check ${LOG_DIR}/ for the corresponding build log."
|
|
377
|
+
fi
|
|
378
|
+
|
|
379
|
+
success "All $(ls -1 "${OUTPUT_DIR}"/*.whl 2>/dev/null | wc -l | tr -d ' ') wheels are pure-Python"
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
# ── Clean ───────────────────────────────────────────────────────────────────
|
|
383
|
+
clean() {
|
|
384
|
+
info "Cleaning build artifacts …"
|
|
385
|
+
rm -rf "${WORK_DIR}" "${OUTPUT_DIR}" "${LOG_DIR}"
|
|
386
|
+
success "Clean complete"
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
# ── Main ────────────────────────────────────────────────────────────────────
|
|
390
|
+
main() {
|
|
391
|
+
local mode="${1:-all}"
|
|
392
|
+
|
|
393
|
+
case "${mode}" in
|
|
394
|
+
--setup)
|
|
395
|
+
setup_environment
|
|
396
|
+
;;
|
|
397
|
+
--build)
|
|
398
|
+
source_shared_env
|
|
399
|
+
clone_repos
|
|
400
|
+
build_wheels
|
|
401
|
+
;;
|
|
402
|
+
--clean)
|
|
403
|
+
clean
|
|
404
|
+
;;
|
|
405
|
+
--help|-h)
|
|
406
|
+
echo "Usage: $0 [--setup | --build | --clean | --help] [--no-extras] [build_dir]"
|
|
407
|
+
echo ""
|
|
408
|
+
echo " (no flag) Full run: setup environment, clone repos, build wheels"
|
|
409
|
+
echo " --setup Set up Python venv and build tooling"
|
|
410
|
+
echo " --build Clone/update repos and build wheels (requires prior --setup)"
|
|
411
|
+
echo " --clean Remove work/, pypi/, and logs/"
|
|
412
|
+
echo " --help Show this message"
|
|
413
|
+
echo ""
|
|
414
|
+
echo " --no-extras Skip downloading pure-Python deps (aiofiles, backoff, etc.)"
|
|
415
|
+
echo " Only safe if 'import gen3' is not needed"
|
|
416
|
+
echo ""
|
|
417
|
+
echo "Env:"
|
|
418
|
+
echo " BROWSER_PYTHON_TAG Python version for extras download (default 314)"
|
|
419
|
+
;;
|
|
420
|
+
*)
|
|
421
|
+
setup_environment
|
|
422
|
+
clone_repos
|
|
423
|
+
build_wheels
|
|
424
|
+
;;
|
|
425
|
+
esac
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
main "$@"
|
|
@@ -1,18 +1,56 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
+
# =============================================================================
|
|
3
|
+
# build-jupyterlite.sh — Build a JupyterLite site (free or remote tier)
|
|
4
|
+
#
|
|
5
|
+
# Sources setup-env.sh so the venv, Python version, and tooling are identical
|
|
6
|
+
# to those used by build-gen3sdk-lite.sh.
|
|
7
|
+
#
|
|
8
|
+
# Package delivery model (see jupyter_lite_config.json):
|
|
9
|
+
# - PyodideAddon vendors the full Pyodide distribution into static/pyodide,
|
|
10
|
+
# so the runtime and its ~300 wheels are served from our own origin.
|
|
11
|
+
# - PyodideLockAddon is DISABLED. In jupyterlite-pyodide-kernel 0.8.5 its
|
|
12
|
+
# post_build_lock() copies the lock away from the wheels it references,
|
|
13
|
+
# so a vendored local distribution fails with Pep508UrlError. The
|
|
14
|
+
# distribution's own pyodide-lock.json is shipped untouched instead.
|
|
15
|
+
# - Our wheels reach the browser via PipliteAddon, fed by the
|
|
16
|
+
# --piplite-wheels flags below.
|
|
17
|
+
#
|
|
18
|
+
# Usage:
|
|
19
|
+
# ./build-jupyterlite.sh <tier> [build_dir]
|
|
20
|
+
# tier: 'free' or 'remote'
|
|
21
|
+
# =============================================================================
|
|
2
22
|
set -euo pipefail
|
|
3
23
|
|
|
24
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
25
|
+
|
|
4
26
|
usage() {
|
|
5
27
|
echo "Usage: $0 <tier> [build_dir]"
|
|
6
|
-
echo " tier:
|
|
28
|
+
echo " tier: 'free' or 'remote'"
|
|
7
29
|
exit 1
|
|
8
30
|
}
|
|
9
31
|
|
|
32
|
+
# ── Parse flags (strip before positional args are consumed) ──────────────────
|
|
33
|
+
POSITIONAL_ARGS=()
|
|
34
|
+
for _arg in "$@"; do
|
|
35
|
+
case "$_arg" in
|
|
36
|
+
# Accepted and ignored for backwards compatibility. This used to skip
|
|
37
|
+
# downloading CDN wheels and patching pyodide-lock.json; that step is gone
|
|
38
|
+
# because the Pyodide distribution is now vendored at build time.
|
|
39
|
+
--no-extras)
|
|
40
|
+
echo "[WARN] --no-extras is obsolete and has no effect; remove it from package.json"
|
|
41
|
+
;;
|
|
42
|
+
*) POSITIONAL_ARGS+=("$_arg") ;;
|
|
43
|
+
esac
|
|
44
|
+
done
|
|
45
|
+
set -- "${POSITIONAL_ARGS[@]+"${POSITIONAL_ARGS[@]}"}"
|
|
46
|
+
|
|
10
47
|
TIER="${1:-}"
|
|
11
48
|
if [[ "$TIER" != "free" && "$TIER" != "remote" ]]; then
|
|
12
49
|
usage
|
|
13
50
|
fi
|
|
14
51
|
|
|
15
|
-
|
|
52
|
+
# ── Path constants (self-contained, mirrors build-gen3sdk-lite layout) ───────
|
|
53
|
+
ROOT_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
|
16
54
|
|
|
17
55
|
if [[ "$TIER" == "free" ]]; then
|
|
18
56
|
SRC_DIR="$ROOT_DIR/free-private"
|
|
@@ -20,47 +58,126 @@ else
|
|
|
20
58
|
SRC_DIR="$ROOT_DIR/remote-private"
|
|
21
59
|
fi
|
|
22
60
|
|
|
61
|
+
_resolve_against_init_cwd() {
|
|
62
|
+
local path="$1"
|
|
63
|
+
local base="${INIT_CWD:-$(pwd)}"
|
|
64
|
+
case "$path" in
|
|
65
|
+
/*) printf '%s' "$path" ;;
|
|
66
|
+
*) printf '%s/%s' "$base" "$path" ;;
|
|
67
|
+
esac
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
BUILD_DIR="$(_resolve_against_init_cwd "${2:-builds}")"
|
|
71
|
+
mkdir -p "$BUILD_DIR"
|
|
72
|
+
BUILD_DIR="$(cd "$BUILD_DIR" && pwd)"
|
|
73
|
+
|
|
74
|
+
VENV_DIR="$BUILD_DIR/.venv"
|
|
75
|
+
OUTPUT_DIR="$BUILD_DIR/pypi"
|
|
76
|
+
|
|
77
|
+
export BUILD_DIR # setup-env.sh reads this
|
|
78
|
+
|
|
79
|
+
# ── Colours / helpers (available before setup-env.sh) ────────────────────────
|
|
80
|
+
RED='\033[0;31m'
|
|
81
|
+
YELLOW='\033[1;33m'
|
|
82
|
+
CYAN='\033[0;36m'
|
|
83
|
+
GREEN='\033[0;32m'
|
|
84
|
+
NC='\033[0m'
|
|
85
|
+
info() { echo -e "${CYAN}[INFO]${NC} $*"; }
|
|
86
|
+
success() { echo -e "${GREEN}[OK]${NC} $*"; }
|
|
87
|
+
warn() { echo -e "${YELLOW}[WARN]${NC} $*"; }
|
|
88
|
+
fail() { echo -e "${RED}[FAIL]${NC} $*"; exit 1; }
|
|
89
|
+
|
|
90
|
+
# ── Source shared environment (creates/reuses the venv) ─────────────────────
|
|
91
|
+
# shellcheck disable=SC1091
|
|
92
|
+
source "${SCRIPT_DIR}/setup-env.sh"
|
|
93
|
+
|
|
94
|
+
# ── JupyterLite-specific setup ──────────────────────────────────────────────
|
|
23
95
|
CONFIG_FILE="$SRC_DIR/jupyter_lite_config.json"
|
|
24
96
|
REQUIREMENTS_FILE="$SRC_DIR/requirements.txt"
|
|
25
|
-
PYTHON_BIN="${PYTHON_BIN:-$(command -v python3)}"
|
|
26
|
-
BUILD_DIR="${2:-$SRC_DIR/build}"
|
|
27
|
-
VENV_DIR="$BUILD_DIR/.venv"
|
|
28
|
-
VENV_PYTHON="$VENV_DIR/bin/python"
|
|
29
97
|
VENV_JUPYTER_LITE="$VENV_DIR/bin/jupyter-lite"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
98
|
+
PYPI="$OUTPUT_DIR" # wheels built by build-gen3sdk-lite land here
|
|
99
|
+
|
|
100
|
+
[[ -f "$REQUIREMENTS_FILE" ]] || fail "Missing requirements file: $REQUIREMENTS_FILE"
|
|
101
|
+
[[ -f "$CONFIG_FILE" ]] || fail "Missing config file: $CONFIG_FILE"
|
|
102
|
+
|
|
103
|
+
# For the free tier, skip reinstalling requirements when jupyter-lite is already
|
|
104
|
+
# present to preserve exact package versions set up by build-gen3sdk-lite.sh.
|
|
105
|
+
# For the remote tier, always install because its requirements.txt includes
|
|
106
|
+
# jupyterlite-remote-server which the free-tier build never installs.
|
|
107
|
+
#
|
|
108
|
+
if [[ "$TIER" == "free" && -x "$VENV_JUPYTER_LITE" ]]; then
|
|
109
|
+
info "Existing venv already has jupyter-lite — skipping requirements install"
|
|
110
|
+
else
|
|
111
|
+
info "Installing JupyterLite requirements …"
|
|
112
|
+
uv pip install --verbose -r "$REQUIREMENTS_FILE" 2>&1 | tail -5
|
|
113
|
+
success "JupyterLite requirements installed"
|
|
34
114
|
fi
|
|
35
115
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
exit 1
|
|
39
|
-
fi
|
|
116
|
+
[[ -x "$VENV_JUPYTER_LITE" ]] || \
|
|
117
|
+
fail "jupyter-lite executable not found in $VENV_DIR after dependency install."
|
|
40
118
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"$
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
119
|
+
# ── Collect our own wheels for PipliteAddon ─────────────────────────────────
|
|
120
|
+
# With PyodideLockAddon disabled these flags are the ONLY route by which our
|
|
121
|
+
# wheels reach the browser. This only applies to the free tier
|
|
122
|
+
WHEEL_ARGS=()
|
|
123
|
+
WHEEL_COUNT=0
|
|
124
|
+
if [[ "$TIER" == "free" ]]; then
|
|
125
|
+
if [[ -d "$PYPI" ]]; then
|
|
126
|
+
info "Looking for wheels in $PYPI"
|
|
127
|
+
while IFS= read -r -d '' whl; do
|
|
128
|
+
WHEEL_ARGS+=(--piplite-wheels "$whl")
|
|
129
|
+
((WHEEL_COUNT++)) || true
|
|
130
|
+
done < <(find "$PYPI" -maxdepth 1 -name "*.whl" -print0 | sort -z)
|
|
131
|
+
fi
|
|
132
|
+
|
|
133
|
+
if (( WHEEL_COUNT == 0 )); then
|
|
134
|
+
fail "No wheels found in $PYPI — run build-gen3sdk-lite.sh first."
|
|
135
|
+
fi
|
|
136
|
+
else
|
|
137
|
+
info "Skipping custom wheel collection for $TIER tier"
|
|
51
138
|
fi
|
|
52
139
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
--config "$CONFIG_FILE" \
|
|
56
|
-
--lite-dir "$SRC_DIR" \
|
|
57
|
-
--output-dir "$BUILD_DIR/$TIER"
|
|
58
|
-
|
|
140
|
+
# ── Build ───────────────────────────────────────────────────────────────────
|
|
141
|
+
info "Running: jupyter-lite build ($TIER tier, ${WHEEL_COUNT} custom wheels)"
|
|
59
142
|
"$VENV_JUPYTER_LITE" build \
|
|
60
143
|
--config "$CONFIG_FILE" \
|
|
61
144
|
--lite-dir "$SRC_DIR" \
|
|
62
|
-
--output-dir "$BUILD_DIR/$TIER"
|
|
63
|
-
|
|
145
|
+
--output-dir "$BUILD_DIR/$TIER" \
|
|
146
|
+
${WHEEL_ARGS[@]+"${WHEEL_ARGS[@]}"}
|
|
147
|
+
|
|
148
|
+
# ── Verify the site is self-contained ───────────────────────────────────────
|
|
149
|
+
# The whole point of vendoring the distribution is that nothing is fetched from
|
|
150
|
+
# a CDN at runtime. Check it here rather than discovering it as a browser hang.
|
|
151
|
+
LOCK_FILE="$BUILD_DIR/$TIER/static/pyodide/pyodide-lock.json"
|
|
152
|
+
if [[ -f "$LOCK_FILE" ]]; then
|
|
153
|
+
REMOTE_COUNT="$(python3 - "$LOCK_FILE" <<'PYEOF'
|
|
154
|
+
import json, sys
|
|
155
|
+
lock = json.load(open(sys.argv[1]))
|
|
156
|
+
remote = [
|
|
157
|
+
m.get("file_name", "")
|
|
158
|
+
for m in lock.get("packages", {}).values()
|
|
159
|
+
if "://" in m.get("file_name", "")
|
|
160
|
+
]
|
|
161
|
+
print(len(remote))
|
|
162
|
+
for r in remote[:10]:
|
|
163
|
+
print(f" {r}", file=sys.stderr)
|
|
164
|
+
PYEOF
|
|
165
|
+
)"
|
|
166
|
+
if [[ "$REMOTE_COUNT" != "0" ]]; then
|
|
167
|
+
warn "$REMOTE_COUNT package(s) in pyodide-lock.json point at a remote host;"
|
|
168
|
+
warn " the browser will fetch these at runtime (see the sample above)."
|
|
169
|
+
else
|
|
170
|
+
success "pyodide-lock.json is fully local ($(ls -1 "$BUILD_DIR/$TIER/static/pyodide"/*.whl 2>/dev/null | wc -l | tr -d ' ') wheels)"
|
|
171
|
+
fi
|
|
172
|
+
else
|
|
173
|
+
warn "No pyodide-lock.json at $LOCK_FILE — is PyodideAddon.pyodide_url set?"
|
|
174
|
+
fi
|
|
64
175
|
|
|
176
|
+
PIPLITE_DIR="$BUILD_DIR/$TIER/static/pypi"
|
|
177
|
+
if [[ -d "$PIPLITE_DIR" ]]; then
|
|
178
|
+
success "piplite index: $(ls -1 "$PIPLITE_DIR"/*.whl 2>/dev/null | wc -l | tr -d ' ') wheels"
|
|
179
|
+
else
|
|
180
|
+
warn "No piplite index at $PIPLITE_DIR — our wheels did not reach the site."
|
|
181
|
+
fi
|
|
65
182
|
|
|
66
|
-
|
|
183
|
+
success "$TIER-tier JupyterLite build complete: $BUILD_DIR/$TIER"
|