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.

fix: QOL improvements when deploying with docker (#2864)

Myles Scolnickd9bc2518e5fb
diff --git a/marimo/_config/config.py b/marimo/_config/config.py
index acd28800f0..57dac56e22 100644
--- a/marimo/_config/config.py
+++ b/marimo/_config/config.py
@@ -5,6 +5,8 @@ import sys
from dataclasses import dataclass
from typing import TypeVar
+from marimo._config.packages import infer_package_manager
+
if sys.version_info < (3, 11):
from typing_extensions import NotRequired
else:
@@ -280,7 +282,7 @@ DEFAULT_CONFIG: MarimoConfig = {
"autosave_delay": 1000,
"format_on_save": False,
},
- "package_management": {"manager": "pip"},
+ "package_management": {"manager": infer_package_manager()},
"server": {
"browser": "default",
"follow_symlink": False,
diff --git a/marimo/_config/packages.py b/marimo/_config/packages.py
new file mode 100644
index 0000000000..178a44248c
--- /dev/null
+++ b/marimo/_config/packages.py
@@ -0,0 +1,52 @@
+from __future__ import annotations
+
+import os
+import sys
+from pathlib import Path
+from typing import Literal
+
+
+def infer_package_manager() -> Literal["pip", "rye", "uv", "poetry", "pixi"]:
+ """Infer the package manager from the current project."""
+
+ try:
+ # Get the project root by looking for common project files
+ current_dir = Path.cwd()
+ root_dir = current_dir
+
+ while root_dir != root_dir.parent:
+ if any(root_dir.glob("pyproject.toml")) or any(
+ root_dir.glob("requirements.txt")
+ ):
+ break
+ root_dir = root_dir.parent
+
+ # Check for Poetry
+ if (root_dir / "poetry.lock").exists():
+ return "poetry"
+
+ # Check for Rye
+ if (root_dir / ".rye").exists():
+ return "rye"
+
+ # Check for Pixi
+ if (root_dir / "pixi.toml").exists():
+ return "pixi"
+
+ VIRTUAL_ENV = os.environ.get("VIRTUAL_ENV", "")
+
+ # Check for '/uv/' in VIRTUAL_ENV
+ if (os.path.sep + "uv" + os.path.sep) in VIRTUAL_ENV:
+ return "uv"
+
+ # Check for virtualenv/pip
+ if hasattr(sys, "real_prefix") or (
+ hasattr(sys, "base_prefix") and sys.base_prefix != sys.prefix
+ ):
+ return "pip"
+
+ # If no specific markers found, default to pip
+ return "pip"
+ except Exception:
+ # Fallback to pip
+ return "pip"
diff --git a/marimo/_runtime/packages/module_name_to_pypi_name.py b/marimo/_runtime/packages/module_name_to_pypi_name.py
index 7cfded1e8c..cedb09bd02 100644
--- a/marimo/_runtime/packages/module_name_to_pypi_name.py
+++ b/marimo/_runtime/packages/module_name_to_pypi_name.py
@@ -734,6 +734,7 @@ def module_name_to_pypi_name() -> dict[str, str]:
"twitter": "python-twitter",
"txclib": "transifex-client",
"u115": "115wangpan",
+ "umap": "umap-learn",
"unidecode": "Unidecode",
"universe": "ansible-universe",
"usb": "pyusb",
diff --git a/marimo/_runtime/packages/utils.py b/marimo/_runtime/packages/utils.py
index 66dc4c07aa..a46e475bdd 100644
--- a/marimo/_runtime/packages/utils.py
+++ b/marimo/_runtime/packages/utils.py
@@ -23,9 +23,18 @@ def in_conda_env() -> bool:
return "CONDA_DEFAULT_ENV" in os.environ
+def is_dockerized() -> bool:
+ return os.path.exists("/.dockerenv")
+
+
def is_python_isolated() -> bool:
"""Returns True if not using system Python"""
- return in_virtual_environment() or in_conda_env() or is_pyodide()
+ return (
+ in_virtual_environment()
+ or in_conda_env()
+ or is_pyodide()
+ or is_dockerized()
+ )
def append_version(pkg_name: str, version: Optional[str]) -> str:
diff --git a/marimo/_server/api/endpoints/login.py b/marimo/_server/api/endpoints/login.py
index 009f5c2847..5b916cc71e 100644
--- a/marimo/_server/api/endpoints/login.py
+++ b/marimo/_server/api/endpoints/login.py
@@ -2,7 +2,7 @@
from __future__ import annotations
from typing import TYPE_CHECKING
-from urllib.parse import parse_qsl
+from urllib.parse import parse_qsl, urlparse
from starlette.responses import (
HTMLResponse,
@@ -100,6 +100,11 @@ async def login_submit(request: Request) -> Response:
error = ""
redirect_url = request.query_params.get("next", "/")
+ # Ensure redirect URL uses same protocol as request
+ parsed = urlparse(redirect_url)
+ if parsed.scheme:
+ redirect_url = parsed._replace(scheme=request.url.scheme).geturl()
+
if request.user.is_authenticated:
return RedirectResponse("/", 302)