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: respect current Python version for sandbox (#6924)
Akshay Agrawal1b0152325bd4
diff --git a/marimo/_cli/sandbox.py b/marimo/_cli/sandbox.pyindex fdd8df89aa..903bcdab0f 100644--- a/marimo/_cli/sandbox.py+++ b/marimo/_cli/sandbox.py@@ -3,6 +3,7 @@ from __future__ import annotationsimport atexitimport os+import platformimport signalimport subprocessimport sys@@ -259,27 +260,26 @@ def construct_uv_flags(if len(additional_deps) > 0:uv_flags.extend(["--with", ",".join(additional_deps)])- # Add refreshif uv_needs_refresh:uv_flags.append("--refresh")- # Add Python version if specified+ # We use the specified Python version (if any), otherwise+ # the current Python versionpython_version = pyproject.python_versionif python_version:uv_flags.extend(["--python", python_version])+ else:+ uv_flags.extend(["--python", platform.python_version()])- # Add index URL if specifiedindex_url = pyproject.index_urlif index_url:uv_flags.extend(["--index-url", index_url])- # Add extra-index-urls if specifiedextra_index_urls = pyproject.extra_index_urlsif extra_index_urls:for url in extra_index_urls:uv_flags.extend(["--extra-index-url", url])- # Add index configs if specifiedindex_configs = pyproject.index_configsif index_configs:for config in index_configs:diff --git a/tests/_cli/test_sandbox.py b/tests/_cli/test_sandbox.pyindex 6e64f5e192..24da569ea2 100644--- a/tests/_cli/test_sandbox.py+++ b/tests/_cli/test_sandbox.py@@ -483,3 +483,28 @@ def test_should_run_in_sandbox_dangerous_sandbox(tmp_path: Path) -> None:name=str(dir_path),)assert result+++def test_construct_uv_cmd_without_python_version(tmp_path: Path) -> None:+ """Test that current Python version is used when not specified."""+ import platform++ # Create a script without requires-python+ script_path = tmp_path / "test.py"+ script_path.write_text(+ """+# /// script+# dependencies = ["numpy"]+# ///+import marimo+ """+ )+ uv_cmd = construct_uv_command(+ ["edit", str(script_path)],+ str(script_path),+ additional_features=[],+ additional_deps=[],+ )+ assert "--python" in uv_cmd+ python_idx = uv_cmd.index("--python")+ assert uv_cmd[python_idx + 1] == platform.python_version()