@marimo-team/islands 0.25.2-dev14 → 0.25.2-dev17
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/dist/{ErrorBoundary-M1CN91UQ.js → ErrorBoundary-DXelDloc.js} +1 -1
- package/dist/assets/__vite-browser-external-BqAtzd2P.js +1 -0
- package/dist/assets/{worker-D7hWi02M.js → worker-Bf8dt6S-.js} +5 -5
- package/dist/{code-visibility-Clbu601l.js → code-visibility-BEL4L-20.js} +1 -1
- package/dist/{common-DnmYjCVM.js → common-DFv4dzDF.js} +1 -1
- package/dist/{data-grid-overlay-editor-CYhrcE4X.js → data-grid-overlay-editor-Ugx4sFND.js} +1 -1
- package/dist/{feedback-button-DQUXhzxG.js → feedback-button-Fdi-8vPd.js} +2 -2
- package/dist/{glide-data-editor-B4sl2a3f.js → glide-data-editor-By_aUFBC.js} +3 -3
- package/dist/{globals-DZ0cKrtp.js → globals-CzVnehHf.js} +1 -1
- package/dist/main.js +7 -7
- package/dist/{number-overlay-editor-CbKIioUo.js → number-overlay-editor-Y2fvG-Fs.js} +1 -1
- package/dist/{reveal-component-CSChrj7R.js → reveal-component-DkmJYf9T.js} +2 -2
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/core/wasm/__tests__/bootstrap.test.ts +33 -1
- package/src/core/wasm/worker/bootstrap.ts +22 -3
- package/src/css/katex.min.css +145 -144
- package/dist/assets/__vite-browser-external-C9iR87Zl.js +0 -1
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { loadPyodide } from "pyodide";
|
|
4
4
|
import type { PyodideInterface } from "pyodide";
|
|
5
5
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
6
|
-
import { DefaultWasmController } from "../worker/bootstrap";
|
|
6
|
+
import { DefaultWasmController, requirementName } from "../worker/bootstrap";
|
|
7
7
|
|
|
8
8
|
vi.mock("pyodide", () => ({ loadPyodide: vi.fn() }));
|
|
9
9
|
vi.mock("../worker/getMarimoWheel", () => ({
|
|
@@ -61,3 +61,35 @@ describe("WASM runtime sources", () => {
|
|
|
61
61
|
expect(controller.requirePyodide).toBe(pyodide);
|
|
62
62
|
});
|
|
63
63
|
});
|
|
64
|
+
|
|
65
|
+
describe("requirementName", () => {
|
|
66
|
+
it("returns the distribution name for a bare requirement", () => {
|
|
67
|
+
expect(requirementName("pandas")).toBe("pandas");
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it.each([
|
|
71
|
+
["pandas==2.1.0", "pandas"],
|
|
72
|
+
["pandas>=2", "pandas"],
|
|
73
|
+
["pandas<=2", "pandas"],
|
|
74
|
+
["pandas~=2.1", "pandas"],
|
|
75
|
+
["pandas!=2.0", "pandas"],
|
|
76
|
+
["nltools===0.6.0.dev2", "nltools"],
|
|
77
|
+
])("cuts the specifier off %s", (requirement, expected) => {
|
|
78
|
+
expect(requirementName(requirement)).toBe(expected);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("cuts extras and markers", () => {
|
|
82
|
+
expect(requirementName("rich[jupyter]>=13")).toBe("rich");
|
|
83
|
+
expect(requirementName('cowsay==6.1; sys_platform == "emscripten"')).toBe(
|
|
84
|
+
"cowsay",
|
|
85
|
+
);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("cuts a URL requirement at the name", () => {
|
|
89
|
+
expect(requirementName("pkg @ https://example.com/pkg.whl")).toBe("pkg");
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("tolerates surrounding whitespace", () => {
|
|
93
|
+
expect(requirementName(" pandas >= 2 ")).toBe("pandas");
|
|
94
|
+
});
|
|
95
|
+
});
|
|
@@ -30,6 +30,17 @@ type SessionResources = [
|
|
|
30
30
|
// 3.b Install from micropip
|
|
31
31
|
// 4. Initialize the notebook
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* The distribution name of a PEP 508 requirement: "pandas>=2" -> "pandas".
|
|
35
|
+
*
|
|
36
|
+
* Extras, markers and URL forms are all cut at their first delimiter, which is
|
|
37
|
+
* enough for the "already installed" lookups this is used for.
|
|
38
|
+
*/
|
|
39
|
+
export function requirementName(requirement: string): string {
|
|
40
|
+
// Trim first: a leading space would otherwise split into an empty name.
|
|
41
|
+
return requirement.trim().split(/[[<>=!~;@\s]/)[0];
|
|
42
|
+
}
|
|
43
|
+
|
|
33
44
|
export class DefaultWasmController implements WasmController {
|
|
34
45
|
protected pyodide: PyodideInterface | null = null;
|
|
35
46
|
private packageLoadQueue = Promise.resolve();
|
|
@@ -314,18 +325,26 @@ export class DefaultWasmController implements WasmController {
|
|
|
314
325
|
});
|
|
315
326
|
loadSpan.end();
|
|
316
327
|
|
|
317
|
-
// Load from micropip
|
|
328
|
+
// Load from micropip.
|
|
329
|
+
//
|
|
330
|
+
// `imports` are PEP 508 requirements and may carry a version specifier
|
|
331
|
+
// ("pandas>=2", "nltools==0.6.0.dev2"). micropip wants them whole, but the
|
|
332
|
+
// "do we already have this?" checks below are keyed by name, so compare on
|
|
333
|
+
// the name and install the requirement.
|
|
318
334
|
loadSpan = t.startSpan("micropip.install");
|
|
319
335
|
const missingPackages = imports.filter(
|
|
320
|
-
(pkg) => !pyodide.loadedPackages[pkg],
|
|
336
|
+
(pkg) => !pyodide.loadedPackages[requirementName(pkg)],
|
|
321
337
|
);
|
|
322
338
|
if (missingPackages.length > 0) {
|
|
339
|
+
const byName = missingPackages.map(
|
|
340
|
+
(pkg) => [requirementName(pkg), pkg] as const,
|
|
341
|
+
);
|
|
323
342
|
await pyodide
|
|
324
343
|
.runPythonAsync(`
|
|
325
344
|
import micropip
|
|
326
345
|
import sys
|
|
327
346
|
# Filter out builtins
|
|
328
|
-
missing = [
|
|
347
|
+
missing = [req for name, req in ${JSON.stringify(byName)} if name not in sys.modules]
|
|
329
348
|
if len(missing) > 0:
|
|
330
349
|
print("Loading from micropip:", missing)
|
|
331
350
|
await micropip.install(missing)
|