Skip to main content

A little wrapper around `uv` to launch ephemeral Jupyter notebooks.

Project description

juv

A little wrapper around uv to launch ephemeral Jupyter notebooks.

uvx juv
# Usage: juv [OPTIONS] COMMAND [ARGS]...
#
#   A wrapper around uv to launch ephemeral Jupyter notebooks.
#
# Options:
#   --help  Show this message and exit.
#
# Commands:
#   add      Add dependencies to the notebook.
#   info     Display juv and uv versions.
#   init     Initialize a new notebook.
#   run      Launch a notebook or script.
#   version  Display juv's version.

usage

juv should feel familar for uv users. The goal is to extend its dependencies management to Jupyter notebooks.

# create a notebook
juv init notebook.ipynb
juv init --python=3.9 notebook.ipynb # specify a minimum Python version

# add dependencies to the notebook
juv add notebook.ipynb pandas numpy
juv add notebook.ipynb --requirements=requirements.txt

# launch the notebook
juv run notebook.ipynb
juv run --with=polars notebook.ipynb # additional dependencies for this session (not saved)
juv run --jupyter=notebook@6.4.0 notebook.ipynb # pick a specific Jupyter frontend

# JUV_JUPYTER env var to set preferred Jupyter frontend (default: lab)
export JUV_JUPYTER=nbclassic
juv run notebook.ipynb

If a script is provided to run, it will be converted to a notebook before launching the Jupyter session.

uvx juv run script.py
# Converted script to notebook `script.ipynb`
# Launching Jupyter session...

what

PEP 723 (inline script metadata) allows specifying dependencies as comments within Python scripts, enabling self-contained, reproducible execution. This feature could significantly improve reproducibility in the data science ecosystem, since many analyses are shared as standalone code (not packages). However, a lot of data science code lives in notebooks (.ipynb files), not Python scripts (.py files).

juv bridges this gap by:

  • Extending PEP 723-style metadata support from uv to Jupyter notebooks
  • Launching Jupyter sessions with the specified dependencies

It's a simple Python script that parses the notebook and starts a Jupyter session with the specified dependencies (piggybacking on uv's existing functionality).

alternatives

juv is opinionated and might not suit your preferences. That's ok! uv is super extensible, and I recommend reading the wonderful documentation to learn about its primitives.

For example, you can achieve a similar workflow using the --with-requirements flag:

uvx --with-requirements=requirements.txt --from=jupyter-core --with=jupyterlab jupyter lab notebook.ipynb

While slightly more verbose and breaking self-containment, this approach totally works and saves you from installing another dependency.

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

juv-0.2.0.tar.gz (29.2 kB view details)

Uploaded Source

Built Distribution

juv-0.2.0-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file juv-0.2.0.tar.gz.

File metadata

  • Download URL: juv-0.2.0.tar.gz
  • Upload date:
  • Size: 29.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for juv-0.2.0.tar.gz
Algorithm Hash digest
SHA256 ef6d082378073fcef1b1eb853c0e5505e3f3b55f3a854de7d7db8070b3c82d53
MD5 8c392c31c6d1f8558bcef76664f0f25c
BLAKE2b-256 07cf3b090218eb41ae16359eae29883e69e3b03c70d55246e541edc77c004af2

See more details on using hashes here.

File details

Details for the file juv-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: juv-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for juv-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e5665de0292f2a422edeaa343a22ffd17f68ed16394c92717f8902c1bc1b6f55
MD5 512052862a0c06490f4bbe8c9c49e07b
BLAKE2b-256 23d99c67cfa215415ad012dda50f6126b6b43fb535a2de083f7e6c166b7a2108

See more details on using hashes here.

Supported by

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