@gen3/workspaces 0.12.64 → 0.12.66

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.
Files changed (103) hide show
  1. package/TODO.md +6 -7
  2. package/dist/jupyterlite-builds/free-private/jupyter_lite_config.json +5 -19
  3. package/dist/jupyterlite-builds/free-private/requirements.txt +1 -1
  4. package/dist/jupyterlite-builds/remote-private/overrides.json +16 -0
  5. package/dist/jupyterlite-builds/scripts/build-gen3sdk-lite.sh +428 -0
  6. package/dist/jupyterlite-builds/scripts/build-jupyterlite.sh +150 -33
  7. package/dist/jupyterlite-builds/scripts/setup-env.sh +81 -0
  8. package/dist/jupyterlite-builds/scripts/sync-jupyter-assets-into-package.sh +19 -2
  9. package/dist/jupyterlite-builds/scripts/validate-jupyterlite-assets.sh +3 -0
  10. package/jupyterlite-builds/free-private/jupyter_lite_config.json +5 -19
  11. package/jupyterlite-builds/free-private/requirements.txt +1 -1
  12. package/jupyterlite-builds/remote-private/overrides.json +16 -0
  13. package/package.json +5 -3
  14. package/scripts/build-gen3sdk-lite.sh +428 -0
  15. package/scripts/build-jupyterlite.sh +150 -33
  16. package/scripts/patch-pyidode-lock.py +100 -0
  17. package/scripts/setup-env.sh +81 -0
  18. package/scripts/sync-jupyter-assets-into-package.sh +19 -2
  19. package/scripts/validate-jupyterlite-assets.sh +3 -0
  20. package/.jupyterlite.doit.db +0 -0
  21. package/dist/jupyterlite-builds/scripts/build-gen3sdk-lite_v2.sh +0 -310
  22. package/dist/jupyterlite-builds/scripts/build-jupyterlite_v2.sh +0 -111
  23. package/jupyterlite-builds/free-private/.cache/pyodide-lock/_uv_wheels/aiofiles-25.1.0-py3-none-any.whl +0 -0
  24. package/jupyterlite-builds/free-private/.cache/pyodide-lock/_uv_wheels/backoff-2.2.1-py3-none-any.whl +0 -0
  25. package/jupyterlite-builds/free-private/.cache/pyodide-lock/_uv_wheels/cdislogging-1.2.0-py3-none-any.whl +0 -0
  26. package/jupyterlite-builds/free-private/.cache/pyodide-lock/_uv_wheels/comm-0.2.3-py3-none-any.whl +0 -0
  27. package/jupyterlite-builds/free-private/.cache/pyodide-lock/_uv_wheels/dataclasses_json-0.5.9-py3-none-any.whl +0 -0
  28. package/jupyterlite-builds/free-private/.cache/pyodide-lock/_uv_wheels/dictionaryutils-4.0.0-py3-none-any.whl +0 -0
  29. package/jupyterlite-builds/free-private/.cache/pyodide-lock/_uv_wheels/drsclient-0.4.0-py3-none-any.whl +0 -0
  30. package/jupyterlite-builds/free-private/.cache/pyodide-lock/_uv_wheels/fastavro-1.12.2-py3-none-any.whl +0 -0
  31. package/jupyterlite-builds/free-private/.cache/pyodide-lock/_uv_wheels/gen3-4.28.3-py3-none-any.whl +0 -0
  32. package/jupyterlite-builds/free-private/.cache/pyodide-lock/_uv_wheels/gen3dictionary-3.0.0-py3-none-any.whl +0 -0
  33. package/jupyterlite-builds/free-private/.cache/pyodide-lock/_uv_wheels/gen3users-1.1.1-py3-none-any.whl +0 -0
  34. package/jupyterlite-builds/free-private/.cache/pyodide-lock/_uv_wheels/humanfriendly-10.0-py2.py3-none-any.whl +0 -0
  35. package/jupyterlite-builds/free-private/.cache/pyodide-lock/_uv_wheels/importlib_metadata-8.9.0-py3-none-any.whl +0 -0
  36. package/jupyterlite-builds/free-private/.cache/pyodide-lock/_uv_wheels/indexclient-6.3.0-py3-none-any.whl +0 -0
  37. package/jupyterlite-builds/free-private/.cache/pyodide-lock/_uv_wheels/ipykernel-6.9.2-py3-none-any.whl +0 -0
  38. package/jupyterlite-builds/free-private/.cache/pyodide-lock/_uv_wheels/ipython_pygments_lexers-1.1.1-py3-none-any.whl +0 -0
  39. package/jupyterlite-builds/free-private/.cache/pyodide-lock/_uv_wheels/marshmallow-3.26.2-py3-none-any.whl +0 -0
  40. package/jupyterlite-builds/free-private/.cache/pyodide-lock/_uv_wheels/marshmallow_enum-1.5.1-py2.py3-none-any.whl +0 -0
  41. package/jupyterlite-builds/free-private/.cache/pyodide-lock/_uv_wheels/mypy_extensions-1.1.0-py3-none-any.whl +0 -0
  42. package/jupyterlite-builds/free-private/.cache/pyodide-lock/_uv_wheels/piplite-0.8.5-py3-none-any.whl +0 -0
  43. package/jupyterlite-builds/free-private/.cache/pyodide-lock/_uv_wheels/pyodide_http-0.2.2-py3-none-any.whl +0 -0
  44. package/jupyterlite-builds/free-private/.cache/pyodide-lock/_uv_wheels/pyodide_kernel-0.8.5-py3-none-any.whl +0 -0
  45. package/jupyterlite-builds/free-private/.cache/pyodide-lock/_uv_wheels/pypfb-0.6.2-py3-none-any.whl +0 -0
  46. package/jupyterlite-builds/free-private/.cache/pyodide-lock/_uv_wheels/python_dateutil-2.9.0.post0-py2.py3-none-any.whl +0 -0
  47. package/jupyterlite-builds/free-private/.cache/pyodide-lock/_uv_wheels/python_json_logger-4.2.0-py3-none-any.whl +0 -0
  48. package/jupyterlite-builds/free-private/.cache/pyodide-lock/_uv_wheels/typing_inspect-0.9.0-py3-none-any.whl +0 -0
  49. package/jupyterlite-builds/free-private/.cache/pyodide-lock/_uv_wheels/xmltodict-0.13.0-py2.py3-none-any.whl +0 -0
  50. package/jupyterlite-builds/free-private/.cache/pyodide-lock/_uv_wheels/zipp-4.1.0-py3-none-any.whl +0 -0
  51. package/jupyterlite-builds/free-private/.cache/pyodide-lock/_work/constraints.txt +0 -354
  52. package/jupyterlite-builds/free-private/.cache/pyodide-lock/_work/excludes.txt +0 -3
  53. package/jupyterlite-builds/free-private/.cache/pyodide-lock/_work/pylock.toml +0 -347
  54. package/jupyterlite-builds/free-private/.cache/pyodide-lock/_work/requirements.in +0 -26
  55. package/jupyterlite-builds/free-private/.cache/pyodide-lock/patched-pyodide-lock.json +0 -1
  56. package/jupyterlite-builds/free-private/.cache/pyodide-lock/pyodide-lock.json +0 -1
  57. package/jupyterlite-builds/free-private/.cache/pyodide-lock/remote-pyodide-lock.json +0 -1
  58. package/jupyterlite-builds/free-private/.cache/wheels/aiofiles-25.1.0-py3-none-any.whl.meta.json +0 -24
  59. package/jupyterlite-builds/free-private/.cache/wheels/backoff-2.2.1-py3-none-any.whl.meta.json +0 -24
  60. package/jupyterlite-builds/free-private/.cache/wheels/cdislogging-1.2.0-py3-none-any.whl.meta.json +0 -24
  61. package/jupyterlite-builds/free-private/.cache/wheels/dataclasses_json-0.5.9-py3-none-any.whl.meta.json +0 -24
  62. package/jupyterlite-builds/free-private/.cache/wheels/dictionaryutils-4.0.0-py3-none-any.whl.meta.json +0 -24
  63. package/jupyterlite-builds/free-private/.cache/wheels/drsclient-0.4.0-py3-none-any.whl.meta.json +0 -24
  64. package/jupyterlite-builds/free-private/.cache/wheels/fastavro-1.12.2-py3-none-any.whl.meta.json +0 -24
  65. package/jupyterlite-builds/free-private/.cache/wheels/gen3-4.28.3-py3-none-any.whl.meta.json +0 -24
  66. package/jupyterlite-builds/free-private/.cache/wheels/gen3dictionary-3.0.0-py3-none-any.whl.meta.json +0 -24
  67. package/jupyterlite-builds/free-private/.cache/wheels/gen3users-1.1.1-py3-none-any.whl.meta.json +0 -24
  68. package/jupyterlite-builds/free-private/.cache/wheels/humanfriendly-10.0-py2.py3-none-any.whl.meta.json +0 -24
  69. package/jupyterlite-builds/free-private/.cache/wheels/importlib_metadata-8.9.0-py3-none-any.whl.meta.json +0 -24
  70. package/jupyterlite-builds/free-private/.cache/wheels/indexclient-6.3.0-py3-none-any.whl.meta.json +0 -24
  71. package/jupyterlite-builds/free-private/.cache/wheels/marshmallow-3.26.2-py3-none-any.whl.meta.json +0 -24
  72. package/jupyterlite-builds/free-private/.cache/wheels/marshmallow_enum-1.5.1-py2.py3-none-any.whl.meta.json +0 -24
  73. package/jupyterlite-builds/free-private/.cache/wheels/mypy_extensions-1.1.0-py3-none-any.whl.meta.json +0 -24
  74. package/jupyterlite-builds/free-private/.cache/wheels/pypfb-0.6.2-py3-none-any.whl.meta.json +0 -24
  75. package/jupyterlite-builds/free-private/.cache/wheels/python_dateutil-2.9.0.post0-py2.py3-none-any.whl.meta.json +0 -24
  76. package/jupyterlite-builds/free-private/.cache/wheels/python_json_logger-4.2.0-py3-none-any.whl.meta.json +0 -24
  77. package/jupyterlite-builds/free-private/.cache/wheels/typing_inspect-0.9.0-py3-none-any.whl.meta.json +0 -24
  78. package/jupyterlite-builds/free-private/.cache/wheels/xmltodict-0.13.0-py2.py3-none-any.whl.meta.json +0 -24
  79. package/jupyterlite-builds/free-private/.cache/wheels/zipp-4.1.0-py3-none-any.whl.meta.json +0 -24
  80. package/jupyterlite-builds/free-private/cockle-config.json +0 -71
  81. package/jupyterlite-builds/free-private/cockle_wasm_env/.mambarc +0 -1
  82. package/jupyterlite-builds/free-private/cockle_wasm_env/bin/coreutils.js +0 -5421
  83. package/jupyterlite-builds/free-private/cockle_wasm_env/bin/coreutils.wasm +0 -0
  84. package/jupyterlite-builds/free-private/cockle_wasm_env/bin/fs.d.ts +0 -375
  85. package/jupyterlite-builds/free-private/cockle_wasm_env/bin/fs.js +0 -3401
  86. package/jupyterlite-builds/free-private/cockle_wasm_env/bin/fs.wasm +0 -0
  87. package/jupyterlite-builds/free-private/cockle_wasm_env/bin/grep.js +0 -3839
  88. package/jupyterlite-builds/free-private/cockle_wasm_env/bin/grep.wasm +0 -0
  89. package/jupyterlite-builds/free-private/cockle_wasm_env/bin/less.data +0 -0
  90. package/jupyterlite-builds/free-private/cockle_wasm_env/bin/less.js +0 -5060
  91. package/jupyterlite-builds/free-private/cockle_wasm_env/bin/less.wasm +0 -0
  92. package/jupyterlite-builds/free-private/cockle_wasm_env/bin/sed.js +0 -3843
  93. package/jupyterlite-builds/free-private/cockle_wasm_env/bin/sed.wasm +0 -0
  94. package/jupyterlite-builds/free-private/cockle_wasm_env/conda-meta/cockle_fs-0.3.0-h27506cd_2.json +0 -60
  95. package/jupyterlite-builds/free-private/cockle_wasm_env/conda-meta/coreutils-9.10-h072c4ef_3.json +0 -52
  96. package/jupyterlite-builds/free-private/cockle_wasm_env/conda-meta/emscripten-abi-4.0.9-h267e887_9.json +0 -31
  97. package/jupyterlite-builds/free-private/cockle_wasm_env/conda-meta/grep-3.12-h8b79025_0.json +0 -52
  98. package/jupyterlite-builds/free-private/cockle_wasm_env/conda-meta/history +0 -10
  99. package/jupyterlite-builds/free-private/cockle_wasm_env/conda-meta/less-693-hf259948_0.json +0 -60
  100. package/jupyterlite-builds/free-private/cockle_wasm_env/conda-meta/sed-4.9-h072c4ef_0.json +0 -52
  101. package/scripts/aiohttp-3.13.5-cp314-cp314-pyemscripten_2026_0_wasm32.whl +0 -0
  102. package/scripts/build-gen3sdk-lite_v2.sh +0 -310
  103. package/scripts/build-jupyterlite_v2.sh +0 -111
package/TODO.md CHANGED
@@ -48,15 +48,14 @@
48
48
 
49
49
  ```bash
50
50
  docker pull --platform linux/amd64 quay.io/cdis/gen3-vectis:qa-jegv2
51
- docker pull --platform linux/amd64 quay.io/cdis/gen3-vectis:gen3-vectisv6
52
51
  docker pull --platform linux/amd64 quay.io/cdis/gen3-vectis:qa-goproxy
53
- docker pull --platform linux/amd64 quay.io/cdis/multihead-workspace-proxy:feat_init
52
+ #docker pull --platform linux/amd64 quay.io/cdis/multihead-workspace-proxy:feat_init
53
+ #docker pull --platform linux/amd64 quay.io/cdis/gen3-vectis:gen3-vectisv6
54
54
  ```
55
-
56
- kind load docker-image quay.io/cdis/gen3-vectis:qa-jegv2 --name kind-multi-node
57
- kind load docker-image quay.io/cdis/gen3-vectis:gen3-vectisv6 --name kind-multi-node
58
- kind load docker-image quay.io/cdis/gen3-vectis:qa-goproxy --name kind-multi-node
59
- kind load docker-image quay.io/cdis/multihead-workspace-proxy:feat_init --name kind-multi-node
55
+ kind load docker-image quay.io/cdis/gen3-vectis:qa-jegv2 --name kind-multi-node kind load docker-image
56
+ quay.io/cdis/gen3-vectis:qa-goproxy --name kind-multi-node #kind load docker-image
57
+ quay.io/cdis/multihead-workspace-proxy:feat_init --name kind-multi-node #kind load docker-image
58
+ quay.io/cdis/gen3-vectis:gen3-vectisv6 --name kind-multi-node
60
59
 
61
60
  # load local frontend image
62
61
 
@@ -3,24 +3,10 @@
3
3
  "apps": ["lab"],
4
4
  "output_dir": "site"
5
5
  },
6
- "LiteServerConfig": {
7
- "contents": ["./notebooks"],
8
- "settings_overrides": {
9
- "@jupyterlite/piplite-extension:plugin": {
10
- "pipliteDeps": [
11
- "numpy",
12
- "pandas",
13
- "scipy",
14
- "matplotlib",
15
- "seaborn",
16
- "biopython",
17
- "scanpy",
18
- "anndata",
19
- "pysam",
20
- "boto3",
21
- "s3fs"
22
- ]
23
- }
24
- }
6
+ "PyodideAddon": {
7
+ "pyodide_url": "https://github.com/pyodide/pyodide/releases/download/314.0.5/pyodide-314.0.5.tar.bz2"
8
+ },
9
+ "PyodideLockAddon": {
10
+ "enabled": false
25
11
  }
26
12
  }
@@ -1,3 +1,3 @@
1
1
  jupyterlite-core>=0.8.1
2
2
  jupyterlab>=4.6.0
3
- jupyterlite-pyodide-kernel
3
+ jupyterlite-pyodide-kernel[lock]
@@ -22,5 +22,21 @@
22
22
  "disabled": true
23
23
  }
24
24
  ]
25
+ },
26
+ "@jupyterlab/application-extension:context-menu": {
27
+ "contextMenu": [
28
+ {
29
+ "command": "filebrowser:download",
30
+ "selector": ".jp-DirListing-item[data-isdir=\"false\"]",
31
+ "rank": 9,
32
+ "disabled": true
33
+ },
34
+ {
35
+ "command": "filebrowser:copy-download-link",
36
+ "selector": ".jp-DirListing-item[data-isdir=\"false\"]",
37
+ "rank": 13,
38
+ "disabled": true
39
+ }
40
+ ]
25
41
  }
26
42
  }
@@ -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 "$@"