Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for packages outside of the Pyodide list for wasm/github pages #3859

Open
Justyouraveragehomie opened this issue Feb 20, 2025 · 9 comments
Labels
enhancement New feature or request

Comments

@Justyouraveragehomie
Copy link

Justyouraveragehomie commented Feb 20, 2025

Description

Hi there, I'm running into an issue where I have a few packages in my notebook (ipynb) that are not included in Pyodide (namely ipywidgets).
I realize marimo is supposed to replace ipywidgets, but there are cases where cross compatibility would be useful, such as in my case.

As I understand it I can convert my ipynb into a marimo .py and then host this on github pages using WASM.

Ideally if it were possible to pre-pack any third party (pure python) packages via PYPI along with the notebook when deploying to github pages this would be hella useful to me since I can't proceed due to the limits of Pyodide.
There are a few smaller packages that are crucial for my notebook, that likely wont be added to the Pyodide list.

Suggested solution

Pre-pack all the packages with the notebook (not sure how) I know the current method is using micropip in Pyodide to install packages upon opening the notebook, but this would not make sense in terms of wait time/nor with github pages.

@Justyouraveragehomie Justyouraveragehomie added the enhancement New feature or request label Feb 20, 2025
@mscolnick
Copy link
Contributor

mscolnick commented Feb 20, 2025

The wait time would be roughly the same. You either need to load the python files from GitHub or load them PyPI. It all runs on the client's computer so it all gets downloaded to the client's computer.

In fact, with PyPI, there would be better caching because it has propper versioning.

@Justyouraveragehomie
Copy link
Author

Justyouraveragehomie commented Feb 20, 2025

Gotcha. I think it would be preferable to load everything from one place on the github page. Also, after loading the html page from github, is it possible to run the whole thing offline? If everything is downloaded to the clients computer.

@mscolnick
Copy link
Contributor

marimo and its dependencies are not actually loaded from github either, those come from pypi. so all python today comes from pypi and would require an internet connection

@Justyouraveragehomie
Copy link
Author

Oh I see, I misunderstood then. Is there any future plan to allow wasm-Marimo to run offline/to be self contained?

@mscolnick
Copy link
Contributor

No plans currently

@Justyouraveragehomie
Copy link
Author

Sorry so what is the current method then to include things like ipywidgets or packages not included in Pyodide when deploying on github pages? Is it with micropip?

@mscolnick
Copy link
Contributor

mscolnick commented Feb 27, 2025

You can:

  1. publish to pypi and then import with micropip
import micropip
await micropip.install("my_package")
import my_package
  1. [more advanced] build your wheel into a /public directory and then
import micropip
await micropip.install(mo.notebook_location () / "public/my_package.wheel")
import my_package

@Justyouraveragehomie
Copy link
Author

Justyouraveragehomie commented Feb 28, 2025

For #2 When you say /public directory, do you mean that you could essentially download the whl's that you need in your project from pypi and call them using micropip? Bit confused on that part. Is this in the documentation?
-Would be great as a feature request to have some documentation on how to include packages not included in Pyodide when exporting to wasm for github pages

@mscolnick
Copy link
Contributor

yes, its documented here: https://docs.marimo.io/guides/wasm/?h=public#including-data

it talks about in the context of data, but you can also put python wheel theres. and follow the micropip documentation: https://micropip.pyodide.org/en/stable/project/usage.html#examples

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants