Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

944 B
Raw Blame
/* Copyright 2026 Marimo. All rights reserved. */

import { getMarimoVersion } from "@/core/meta/globals";

export interface WasmRuntimeConfig {
  version: string;
  pyodideIndexUrl?: string;
  pyodideLockfileUrl?: string;
  pypiIndexUrl?: string;
}

export function getWasmRuntimeConfig(): WasmRuntimeConfig {
  const element = document.querySelector<HTMLElement>("marimo-wasm");
  const resolve = (url: string | undefined) => {
    try {
      return url ? new URL(url, document.baseURI).href : undefined;
    } catch {
      return undefined;
    }
  };
  return {
    version: getMarimoVersion(),
    pyodideIndexUrl: resolve(element?.dataset.pyodideIndexUrl),
    pyodideLockfileUrl: resolve(element?.dataset.pyodideLockfileUrl),
    // URL serialization escapes the placeholder understood by micropip.
    pypiIndexUrl: resolve(element?.dataset.pypiIndexUrl)?.replaceAll(
      "%7Bpackage_name%7D",
      "{package_name}",
    ),
  };
}