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.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
improve: add --compile and --compile-bytecode flags to uv (#4578)
Shahmir Varqha37bcb7a0bba2
diff --git a/marimo/_cli/sandbox.py b/marimo/_cli/sandbox.pyindex bccebaf557..343ace66e0 100644--- a/marimo/_cli/sandbox.py+++ b/marimo/_cli/sandbox.py@@ -322,6 +322,8 @@ def construct_uv_command(# sandboxed notebook shouldn't pick up existing pyproject.toml,# which may conflict with the sandbox requirements"--no-project",+ # trade installation time for faster start time+ "--compile-bytecode","--with-requirements",temp_file_path,]diff --git a/marimo/_runtime/packages/pypi_package_manager.py b/marimo/_runtime/packages/pypi_package_manager.pyindex b28a7ae04c..3de192713f 100644--- a/marimo/_runtime/packages/pypi_package_manager.py+++ b/marimo/_runtime/packages/pypi_package_manager.py@@ -118,7 +118,16 @@ class UvPackageManager(PypiPackageManager):async def _install(self, package: str) -> bool:return self.run(- ["uv", "pip", "install", *split_packages(package), "-p", PY_EXE]+ [+ "uv",+ "pip",+ "install",+ # trade installation time for faster start time+ "--compile",+ *split_packages(package),+ "-p",+ PY_EXE,+ ])def update_notebook_script_metadata(diff --git a/tests/_cli/test_sandbox.py b/tests/_cli/test_sandbox.pyindex 3e941dc587..a4719c3a24 100644--- a/tests/_cli/test_sandbox.py+++ b/tests/_cli/test_sandbox.py@@ -439,6 +439,7 @@ import marimoassert ">=3.11" in uv_cmdassert "--isolated" in uv_cmdassert "--no-project" in uv_cmd+ assert "--compile-bytecode" in uv_cmdassert "--sandbox" not in uv_cmd@@ -517,6 +518,7 @@ def test_construct_uv_cmd_empty_dependencies() -> None:)assert "--refresh" in uv_cmdassert "--isolated" in uv_cmd+ assert "--compile-bytecode" in uv_cmdassert "--no-project" in uv_cmddiff --git a/tests/_runtime/packages/test_package_managers.py b/tests/_runtime/packages/test_package_managers.pyindex 85a1378d0d..df22e57208 100644--- a/tests/_runtime/packages/test_package_managers.py+++ b/tests/_runtime/packages/test_package_managers.py@@ -4,6 +4,7 @@ import pytestfrom marimo._runtime.packages.package_managers import create_package_managerfrom marimo._runtime.packages.pypi_package_manager import (+ PY_EXE,MicropipPackageManager,PipPackageManager,RyePackageManager,@@ -223,3 +224,18 @@ def test_update_script_metadata_marimo_packages() -> None:]]runs_calls.clear()+++async def test_uv_pip_install() -> None:+ runs_calls: list[list[str]] = []++ class MockUvPackageManager(UvPackageManager):+ def run(self, command: list[str]) -> bool:+ runs_calls.append(command)+ return True++ pm = MockUvPackageManager()+ await pm._install("foo")+ assert runs_calls == [+ ["uv", "pip", "install", "--compile", "foo", "-p", PY_EXE],+ ]