Get help from the marimo community

Updated 2 months ago

How to try a pre-release/development version locally with sandbox?

At a glance

The post discusses an issue with the Marimo package, where it installs the version from PyPI that corresponds to the running version, making it difficult to test development branches. The community members tried installing the dev branch directly in the notebook, but that didn't work either.

In the comments, the community members discuss potential solutions, such as commenting out a section of code to install an editable version of Marimo, and using importlib.metadata to check if the package is being installed in an editable mode. They eventually find a solution using distribution.origin in Python 3.13, which is demonstrated in a pull request.

Useful resources
From the logs that flash by as marimo starts in sandbox mode, it seems it installs the version of the marimo package from pypi that corresponds to the running version's version. This works fine with official releases, but makes it hard to test development branches, since they still have the prior version number, so the running notebook won't reflect the changes

I tried installing the dev branch of marimo that I wanted to try from within the notebook itself, but that didn't work either:
g
M
11 comments
i dont think there is a great way to do this. i've commeneted out this in the code to test this. you can kinda trick the code path with MARIMO_MANAGE_SCRIPT_METADATA=true marimo edit, but that wont actually create the sandbox for you (just think you are in one).
i have this code:

Plain Text
    marimo_deps = [d for d in dependencies if _is_marimo_dependency(d)]
    if not marimo_deps:
        # During development, you can comment this out to install an
        # editable version of marimo assuming you are in the marimo directory
        # DO NOT COMMIT THIS WHEN SUBMITTING PRs
        # return dependencies + [f"marimo -e ."]

        return dependencies + [f"marimo=={marimo_version}"]
if there is a way to check if you are running from an editable install, that would help. or we could expose an environment variable
thanks for the follow-up! looks like this is exposed by importlib metadata
it's a little roundabout for now:

Plain Text
import json
from importlib.metadata import Distribution

direct_url = Distribution.from_name("pkg-name").read_text("direct_url.json")
pkg_is_editable = json.loads(direct_url).get("dir_info", {}).get("editable", False) 
apparently with python 3.13 you can just directly access distribution.origin
ah very cool, let me try it out
awesome! thanks!
Add a reply
Sign up and join the conversation on Discord