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.

feat: add pixi package manager (#1035)

Akshay Agrawalf2808af2bd2c
diff --git a/frontend/src/components/app-config/user-config-form.tsx b/frontend/src/components/app-config/user-config-form.tsx
index 60df943c8c..0be0f6e412 100644
--- a/frontend/src/components/app-config/user-config-form.tsx
+++ b/frontend/src/components/app-config/user-config-form.tsx
@@ -22,6 +22,7 @@ import { Switch } from "../ui/switch";
import { SettingTitle, SettingDescription, SettingSubtitle } from "./common";
import { THEMES } from "@/theme/useTheme";
import { isPyodide } from "@/core/pyodide/utils";
+import { PackageManagerNames } from "../../core/config/config-schema";
export const UserConfigForm: React.FC = () => {
const [config, setConfig] = useUserConfig();
@@ -300,7 +301,7 @@ export const UserConfigForm: React.FC = () => {
disabled={field.disabled}
className="inline-flex mr-2"
>
- {["pip", "uv", "rye", "poetry"].map((option) => (
+ {PackageManagerNames.map((option) => (
<option value={option} key={option}>
{option}
</option>
diff --git a/frontend/src/components/editor/package-alert.tsx b/frontend/src/components/editor/package-alert.tsx
index 55b03fc41c..20e7026df6 100644
--- a/frontend/src/components/editor/package-alert.tsx
+++ b/frontend/src/components/editor/package-alert.tsx
@@ -36,6 +36,10 @@ import { PackageInstallationStatus } from "@/core/kernel/messages";
import { logNever } from "@/utils/assertNever";
import { useUserConfig } from "@/core/config/config";
import { isPyodide } from "@/core/pyodide/utils";
+import {
+ PackageManagerName,
+ PackageManagerNames,
+} from "../../core/config/config-schema";
export const PackageAlert: React.FC = (props) => {
const { packageAlert } = useAlerts();
@@ -237,7 +241,7 @@ const ProgressIcon = ({
};
async function installPackages(
- manager: "pip" | "uv" | "rye" | "poetry",
+ manager: PackageManagerName,
clearPackageAlert: () => void,
) {
clearPackageAlert();
@@ -249,7 +253,7 @@ const InstallPackagesButton = ({
manager,
clearPackageAlert,
}: {
- manager: "pip" | "uv" | "rye" | "poetry";
+ manager: PackageManagerName;
clearPackageAlert: () => void;
}) => {
return (
@@ -300,7 +304,7 @@ export const PackageManagerForm: React.FC = () => {
disabled={field.disabled}
className="inline-flex mr-2"
>
- {["pip", "uv", "rye", "poetry"].map((option) => (
+ {PackageManagerNames.map((option) => (
<option value={option} key={option}>
{option}
</option>
diff --git a/frontend/src/core/config/config-schema.ts b/frontend/src/core/config/config-schema.ts
index 42f566571d..6a0d3d5f62 100644
--- a/frontend/src/core/config/config-schema.ts
+++ b/frontend/src/core/config/config-schema.ts
@@ -6,6 +6,16 @@ import {
getRawMarimoUserConfig,
} from "../dom/marimo-tag";
+// This has to be defined in the same file as the zod schema to satisfy zod
+export const PackageManagerNames = [
+ "pip",
+ "uv",
+ "rye",
+ "poetry",
+ "pixi",
+] as const;
+export type PackageManagerName = (typeof PackageManagerNames)[number];
+
export const UserConfigSchema = z
.object({
completion: z
@@ -54,7 +64,7 @@ export const UserConfigSchema = z
.default({}),
package_management: z
.object({
- manager: z.enum(["pip", "uv", "rye", "poetry"]).default("pip"),
+ manager: z.enum(PackageManagerNames).default("pip"),
})
.default({ manager: "pip" }),
experimental: z
diff --git a/frontend/src/core/network/types.ts b/frontend/src/core/network/types.ts
index 9b3c16443c..92e7c5fe21 100644
--- a/frontend/src/core/network/types.ts
+++ b/frontend/src/core/network/types.ts
@@ -5,6 +5,7 @@ import { CellId } from "../cells/ids";
import { CellConfig } from "../cells/types";
import { RequestId } from "./DeferredRequestRegistry";
import { FilePath } from "@/utils/paths";
+import { PackageManagerName } from "../config/config-schema";
// Ideally this would be generated from server.py, but for now we just
// manually keep them in sync.
@@ -96,7 +97,7 @@ export interface SendStdin {
// In the future may include things like package manager, index URL, ...
export interface SendInstallMissingPackages {
- manager: "pip" | "uv" | "rye" | "poetry";
+ manager: PackageManagerName;
}
export interface ValueUpdate {
diff --git a/marimo/_config/config.py b/marimo/_config/config.py
index cbac25d6ba..de38f63aa5 100644
--- a/marimo/_config/config.py
+++ b/marimo/_config/config.py
@@ -117,7 +117,7 @@ class PackageManagementConfig(TypedDict, total=False):
- `manager`: the package manager to use
"""
- manager: Literal["pip", "rye", "uv"]
+ manager: Literal["pip", "rye", "uv", "poetry", "pixi"]
@mddoc
diff --git a/marimo/_runtime/packages/package_managers.py b/marimo/_runtime/packages/package_managers.py
index f35159100f..65dc62d27b 100644
--- a/marimo/_runtime/packages/package_managers.py
+++ b/marimo/_runtime/packages/package_managers.py
@@ -3,6 +3,7 @@ from marimo._runtime.packages.package_manager import PackageManager
from marimo._runtime.packages.pypi_package_manager import (
MicropipPackageManager,
PipPackageManager,
+ PixiPackageManager,
PoetryPackageManager,
RyePackageManager,
UvPackageManager,
@@ -15,6 +16,7 @@ PACKAGE_MANAGERS = {
RyePackageManager.name: RyePackageManager,
UvPackageManager.name: UvPackageManager,
PoetryPackageManager.name: PoetryPackageManager,
+ PixiPackageManager.name: PixiPackageManager,
}
diff --git a/marimo/_runtime/packages/pypi_package_manager.py b/marimo/_runtime/packages/pypi_package_manager.py
index d5882b2be2..3e6303f813 100644
--- a/marimo/_runtime/packages/pypi_package_manager.py
+++ b/marimo/_runtime/packages/pypi_package_manager.py
@@ -11,12 +11,15 @@ from marimo._utils.platform import is_pyodide
class PypiPackageManager(PackageManager):
- """Implements installation for both pip and micropip.
+ """Base class for package managers that use PyPI.
- Can fork into two different classes if needed.
+ Has a heuristic for mapping from package names to module names and back,
+ using a registry of well-known packages and basic rules for package
+ names.
"""
def __init__(self) -> None:
+ # Initialized lazily
self._module_name_to_pypi_name: dict[str, str] | None = None
self._pypi_name_to_module_name: dict[str, str] | None = None
@@ -98,3 +101,15 @@ class PoetryPackageManager(PypiPackageManager):
async def install(self, package: str) -> bool:
return subprocess.run(["poetry", "add", package]).returncode == 0
+
+
+# Pixi actually uses Conda by default ... but the package-to-module
+# resolution that we use for Pypi packages seems to work fine, so
+# we subclass PypiPackageManager.
+#
+# Can change the base class if/when needed.
+class PixiPackageManager(PypiPackageManager):
+ name = "pixi"
+
+ async def install(self, package: str) -> bool:
+ return subprocess.run(["pixi", "add", package]).returncode == 0