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
fix: Installation flag (#5842)
Dylan Madisettie08450157daa
diff --git a/marimo/_runtime/packages/pypi_package_manager.py b/marimo/_runtime/packages/pypi_package_manager.pyindex 83ae1fc7cd..5e55062ea7 100644--- a/marimo/_runtime/packages/pypi_package_manager.py+++ b/marimo/_runtime/packages/pypi_package_manager.py@@ -152,8 +152,14 @@ class UvPackageManager(PypiPackageManager):install_cmd = [self._uv_bin, "add"]else:LOGGER.info(f"Installing in {package} with 'uv pip install'")+install_cmd = [self._uv_bin, "pip", "install"]+ # Allow for explicit site directory location if needed+ target = os.environ.get("MARIMO_UV_TARGET", None)+ if target:+ install_cmd.append(f"--target={target}")+if upgrade:install_cmd.append("--upgrade")diff --git a/tests/_runtime/packages/test_pypi_package_manager.py b/tests/_runtime/packages/test_pypi_package_manager.pyindex b77f5272f3..7b1589c238 100644--- a/tests/_runtime/packages/test_pypi_package_manager.py+++ b/tests/_runtime/packages/test_pypi_package_manager.py@@ -216,6 +216,37 @@ async def test_uv_install_not_in_project(mock_run: MagicMock):assert result is True+@patch("subprocess.run")[email protected](UvPackageManager, "is_in_uv_project", False)+async def test_uv_install_not_in_project_with_target(mock_run: MagicMock):+ """Test UV install uses pip with target"""+ mock_run.return_value = MagicMock(returncode=0)+ mgr = UvPackageManager()++ # Explicitly set environ, since patch doesn't work in an asynchronous+ # context.+ import os++ os.environ["MARIMO_UV_TARGET"] = "target_path"+ result = await mgr._install("package1 package2", upgrade=False)+ del os.environ["MARIMO_UV_TARGET"]++ mock_run.assert_called_once_with(+ [+ "uv",+ "pip",+ "install",+ "--target=target_path",+ "--compile",+ "package1",+ "package2",+ "-p",+ PY_EXE,+ ],+ )+ assert result is True++@patch("subprocess.run")@patch.object(UvPackageManager, "is_in_uv_project", True)async def test_uv_install_in_project(mock_run: MagicMock):