Thank you for your interest in contributing to Mercury! 🎉 Mercury is an open-source framework for turning Python notebooks into interactive web apps. It includes:
- a widget system built on ipywidgets and anywidget (
mercury/) - a JupyterLab ≥ 4 extension for live preview (
packages/lab/) - an application bundle built on top of the extension (
packages/application/) - a lightweight frontend loader (
app/) - a server component (
mercury_app/)
This document explains how to set up your development environment and how to work on each part of the project.
mercury/ # Python package with widgets (ipywidgets + anywidget)
packages/
lab/ # JupyterLab extension (frontend TypeScript code)
application/ # Application built using the extension
app/ # Standalone web app wrapper, handles dynamic loading
mercury_app/ # Python server backend
dist/ # Python wheels and sdist
docs/ # Documentation using Astro
git clone https://github.com/mljar/mercury.git
cd mercurypython3 -m venv venv
source venv/bin/activate
pip install -e .[dev]Mercury uses Yarn (via jlpm) for frontend work.
jlpm installMercury has multiple components. Each part has a slightly different workflow.
Below is a guide for the most common development tasks.
The mercury directory contains Python widget definitions implemented using ipywidgets and anywidget.
- Make changes in the Python files under
mercury/. - Open a notebook using Mercury.
- Reload the notebook kernel and re-import:
from mercury import *- Your widget changes will appear immediately.
👉 No build step required. 👉 Mercury automatically picks up widget changes through Python import.
Widget tests are located in mercury/tests directory.
python -m ipykernel install --user --name venv
This is the TypeScript code that:
- integrates Mercury widgets into JupyterLab
- creates the live preview panel
- handles communication between cells and the app
Install editable Python package:
pip install -e .
jupyter labextension develop . --overwrite
jlpm install
jlpm buildPlease go into the extension directory:
cd packages/laband start watching the extension:
jlpm run watchThis runs the build in watch mode and automatically recompiles as you edit.
Open another terminal in the project root:
jupyter labThe extension should load automatically via federated extensions.
If not, rebuild everything:
jlpm run build- Edit TypeScript files in
packages/lab pip install -e .jlpm run watch- Reload JupyterLab
This directory contains the “standalone Mercury app” used when exporting or embedding.
- Go to the directory:
cd packages/application- Install dependencies (please run in main directory):
jlpm install- Start watch mode:
jlpm run watch- In another terminal, run JupyterLab or the Mercury server.
The app/ folder is responsible for:
- bundling the standalone Mercury app
- enabling federated extension dynamic loading
- packaging production builds
cd app
jlpm install
jlpm run build # or jlpm run watch for developmentThis directory contains the custom Python server used for:
- serving Mercury apps
- handling notebook metadata
- rendering static assets
- managing session state
- Make changes in Python files under
mercury_app/. - Restart the Mercury server:
mercury(or if running inside JupyterLab, restart JupyterLab)
👉 No frontend build is needed unless you edit static assets.
| Component | Path | How to Develop |
|---|---|---|
| Widgets (Python) | mercury/ |
Edit → reload notebook → re-import |
| JupyterLab Ext. | packages/lab/ |
pip install -e . → jlpm run watch → reload Lab |
| Application Bundle | packages/application/ |
jlpm run watch |
| Standalone Web App | app/ |
jlpm run build or jlpm run watch |
| Backend Server | mercury_app/ |
Edit Python → restart server |
Add instructions here once tests are added.
To build all packages:
jlpm run buildor production build:
jlpm run build:prodThis will:
- clean build artifacts
- build workspaces
- check that all expected output files exist
ruff check .
black .jlpm lintDocs are inside the docs/ directory and built using Astro.
cd docs
npm install
npm run dev
- Fork the repo.
- Create a new branch:
git checkout -b feature/my-improvement- Make your changes.
- Add or update tests (if available).
- Run builds/lints.
- Create a Pull Request.
We appreciate all PRs — bug fixes, features, docs, examples, tests, and refactoring.