Skip to content

Commit f5dcaa3

Browse files
committed
refactor: make runtime package specs configurable
Preserve main's Sigima 1.1.6 and guidata 3.15.0 defaults while allowing coordinated local wheel testing through Vite. Assisted-by: GitHub Copilot
1 parent 2bc1db8 commit f5dcaa3

4 files changed

Lines changed: 21 additions & 4 deletions

File tree

‎doc/shim-registry.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ DataLab-Web requires guidata 3.15 or later. That release provides `guidata.datas
3333

3434
| Package | How the runtime gets it | Fast-audit source |
3535
| ------------------------ | -------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
36-
| `guidata` | `micropip.install("guidata>=3.15.0")` | Latest PyPI release from `https://pypi.org/pypi/guidata/json` |
37-
| `sigima` | `micropip.install("sigima>=1.1.6")` | Latest PyPI release from `https://pypi.org/pypi/sigima/json` |
36+
| `guidata` | `VITE_GUIDATA_INSTALL_SPEC` (default: `guidata>=3.15.0`) | Latest PyPI release from `https://pypi.org/pypi/guidata/json` |
37+
| `sigima` | `VITE_SIGIMA_INSTALL_SPEC` (default: `sigima>=1.1.6`) | Latest PyPI release from `https://pypi.org/pypi/sigima/json` |
3838
| `numpy`, `scipy`, `h5py` | Bundled with the pinned Pyodide build (`py.loadPackage`) | `pyodide-lock.json` of the pinned `PYODIDE_VERSION` (from [src/runtime/workerBase.ts](../src/runtime/workerBase.ts)) |
3939

4040
The fast audit infers these versions **without booting Pyodide**, so it is cheap and useful for routine monitoring. For PyPI packages it does not execute dependency resolution, so the latest release is only an approximation of what `micropip` will select. The live audit instead reads the versions actually resolved inside Pyodide via `DataLabRuntime.getInstalledVersions()` (backed by `importlib.metadata`), which is authoritative but pays the cold-start cost. Both feed the same `classifyShim` logic.

‎src/runtime/runtime.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ export interface PyProxy {
107107

108108
const PYODIDE_VERSION = "v0.26.4";
109109
const PYODIDE_INDEX = `https://cdn.jsdelivr.net/pyodide/${PYODIDE_VERSION}/full/`;
110+
const SIGIMA_INSTALL_SPEC =
111+
import.meta.env.VITE_SIGIMA_INSTALL_SPEC || "sigima>=1.1.6";
112+
const GUIDATA_INSTALL_SPEC =
113+
import.meta.env.VITE_GUIDATA_INSTALL_SPEC || "guidata>=3.15.0";
110114

111115
export interface PythonDistributionInfo {
112116
name: string;
@@ -1339,7 +1343,7 @@ os.environ["LANGUAGE"] = ${JSON.stringify(lang)}
13391343
// ``PYODIDE_VERSION`` bumps to a build with numpy>=2.1.
13401344
await py.runPythonAsync(`
13411345
import micropip
1342-
await micropip.install(["sigima>=1.1.6", "guidata>=3.15.0", "tifffile<2025"])
1346+
await micropip.install([${JSON.stringify(SIGIMA_INSTALL_SPEC)}, ${JSON.stringify(GUIDATA_INSTALL_SPEC)}, "tifffile<2025"])
13431347
`);
13441348

13451349
onProgress?.(t("Initialising Sigima namespace…"));

‎src/runtime/workerBase.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515

1616
export const PYODIDE_VERSION = "v0.26.4";
1717
export const PYODIDE_INDEX = `https://cdn.jsdelivr.net/pyodide/${PYODIDE_VERSION}/full/`;
18+
const SIGIMA_INSTALL_SPEC =
19+
import.meta.env.VITE_SIGIMA_INSTALL_SPEC || "sigima>=1.1.6";
20+
const GUIDATA_INSTALL_SPEC =
21+
import.meta.env.VITE_GUIDATA_INSTALL_SPEC || "guidata>=3.15.0";
1822

1923
/** Minimal slice of the Pyodide API surface used by the workers. */
2024
export interface PyodideAPI {
@@ -93,7 +97,7 @@ os.environ["LANGUAGE"] = ${JSON.stringify(opts.lang)}
9397
// Pyodide ships numpy 1.26.4 (lift when Pyodide bumps numpy).
9498
await py.runPythonAsync(`
9599
import micropip
96-
await micropip.install(["sigima>=1.1.6", "guidata>=3.15.0", "tifffile<2025"])
100+
await micropip.install([${JSON.stringify(SIGIMA_INSTALL_SPEC)}, ${JSON.stringify(GUIDATA_INSTALL_SPEC)}, "tifffile<2025"])
97101
`);
98102

99103
// Install Sigima's ``PlaceholderTitleFormatter`` so titles produced in

‎vite.config.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@ export default defineConfig({
6666
},
6767
server: {
6868
port: 5173,
69+
fs: {
70+
// Supports VITE_*_INSTALL_SPEC=/@fs/... during coordinated pre-release
71+
// development without exposing the rest of the workspace.
72+
allow: [
73+
__dirname,
74+
resolve(__dirname, "../Sigima/dist"),
75+
resolve(__dirname, "../guidata/dist"),
76+
],
77+
},
6978
// NOTE: do NOT enable Cross-Origin-Embedder-Policy=require-corp here.
7079
// It would block the Pyodide CDN <script> tag (loaded without
7180
// `crossorigin`) and silently break the whole runtime. Basic Pyodide

0 commit comments

Comments
 (0)