Skip to main content

Build and publish python packages from marimo notebooks

Project description

marimo-dev

Build Python packages from Marimo notebooks.

Why this exists

Marimo notebooks are excellent for development - they manage dependencies automatically, provide instant feedback, and let you import functions between notebooks without configuration. But publishing requires traditional Python packages with proper module structure and __init__.py files.

marimo-dev bridges this gap. It extracts decorated functions and classes from your notebooks and writes them to clean Python modules, leaving behind the exploratory code, UI elements, and notebook-specific logic.

Quick start

uv init --lib my-project
cd my-project
uv add marimo marimo-dev
mkdir notebooks

Create notebooks/a_core.py:

import marimo
app = marimo.App()

@app.function
def greet(name:str="World"):
    "Return a greeting"
    return f"Hello, {name}!"

Build and publish:

md build
md publish --test

Project structure

my-project/
├── pyproject.toml
├── notebooks/
│   ├── a_core.py      # letter prefix avoids collision with 'core' package
│   ├── b_utils.py     # avoids collision with 'utils' package
│   └── XX_draft.py    # XX_ prefix = ignored during build
├── src/               # generated by md build
│   └── my_project/
│       ├── __init__.py 
│       ├── core.py    # letter prefix stripped
│       └── utils.py
└── docs/              # generated by md build
    └── llms.txt       # API signatures for LLM consumption

Module naming

Prefix notebooks with letters (a_, b_, c_) to avoid name collisions with common packages like requests, utils, or core. The prefix is stripped in the built package.

During development, import from other notebooks using their full names:

from a_core import greet

marimo-dev rewrites these to relative imports in the built package:

from .core import greet

What gets exported

  1. constants in setup cells
  2. self-contained functions and classes

Hash pipe directives

Control export and documentation behavior with #| directives on the line immediately after a decorator:

@app.function
#| nodoc
def helper(): 
    pass  # exported but not in llms.txt

@app.function
#| internal
def private(): 
    pass  # not added to __all__

@app.function
#| nodoc internal
def helper(): 
    pass  # neither exported nor documented

Documentation style

Use inline comments for parameter documentation:

@app.function
def add(
    a:int, # first number
    b:int, # second number
)->int:    # sum of a and b
    "Add two numbers"
    return a + b

These comments appear in llms.txt, making your API documentation useful for LLM-assisted coding.

Configuration

Add to pyproject.toml to override defaults:

[tool.marimo-dev]
nbs = "notebooks"           # notebook directory (default: "notebooks")
out = "src"                 # output directory (default: "src")
docs = "docs"               # docs directory (default: "docs")
decorators = ["app.function", "app.class_definition"]  # export markers
skip_prefixes = ["XX_", "test_"]  # ignore these files

Commands

md build              # build package from notebooks and make docs
md docs               # build the static docs (beta)
md publish --test     # publish to Test PyPI
md publish            # publish to PyPI
md tidy               # remove __pycache__ and cache files
md nuke               # remove all build artifacts (dist, docs, src, temp*)

If you make a temp folder it will be explicitly removed when running md nuke

Dependencies

Marimo manages package dependencies automatically through its package tab. You do not need to manually maintain pyproject.toml dependencies during development.

When you build, ensure your pyproject.toml includes all packages your exported functions import.

Requirements

  • Python 3.12+
  • marimo
  • uv

Tips

  • Update version in pyproject.toml before publishing
  • Use uv sync --upgrade to update dependencies
  • Use uv cache clean if you encounter caching issues
  • Rebuild takes ~18ms, so you can run md build frequently during development

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

marimo_dev-0.2.4.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

marimo_dev-0.2.4-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

Details for the file marimo_dev-0.2.4.tar.gz.

File metadata

  • Download URL: marimo_dev-0.2.4.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux ARM","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for marimo_dev-0.2.4.tar.gz
Algorithm Hash digest
SHA256 7954c65dc55d85507e7f5270fe1e9a61a954cfa0b406c081eae62c8f4e307db5
MD5 aec5f2443fee28a2ee11046a9fe378f0
BLAKE2b-256 77467967338d198d305766648623e10d6a1e937462eb9efc5a6bc37611a4c10b

See more details on using hashes here.

File details

Details for the file marimo_dev-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: marimo_dev-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 17.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux ARM","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for marimo_dev-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 88a99f865bf1bd7d1dc5c5c2e6f50bde77045df4432ceb6e8e06bfe872b05d0b
MD5 6e8a159822d00fdd94317b066a58e490
BLAKE2b-256 9b23890745df36fca38ef7c0cbaad8d878f0491c1a3e3a6895e50822246236ef

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page