Importing a new package that doesn't exist in `Pyodide`
See original GitHub issueI have been trying to look into ways to import torch
but I couldn’t manage to do so because it isn’t in Pyodide
’s list of supported packages.
From my research on this, there are two ways to have any new package be utilized:
- Find a
pure Python 3 wheel
which means the package could be installed without the need of hard specifications. - Add
torch
and its dependencies toPyodide
’s list of support packages. This will require doing the following:- Obtaining `Source Distribution of the package.
- Compiling the package locally.
- Building
Pyodide
from the source. - Add the package to
Pyodide
’s list of supported packages by following the documentation - Importing the newer version of
Pyodide
toPyscript
I don’t know how this can be done
Questions:
- How can I add a newer version of
Pyodide
which was built locally toPyscript
? - Isn’t there a way to import a python environment that has all of the packages already installed?
- Why do we need to have
pure Python 3 wheel
(aka needs to be compiled on all hardware)? Is it because it is actually being compiled on the browser-side which should be able to run all hardware? - From looking into the logs, it seems that every time the page has loaded the packages listed to be used get installed by
micropip
, is this correct? If yes, why can’t we store already installed packages to load them? - Why PyScript is super slow? I am assuming this because of the installation of packages from scratch (if my assumption is true).
Relevant resource:
Issue Analytics
- State:
- Created a year ago
- Reactions:4
- Comments:20 (4 by maintainers)
Top Results From Across the Web
Loading packages — Version 0.21.3 - Pyodide
Loading packages#. Only the Python standard library is available after importing Pyodide. To use other packages, you'll need to load them using either:....
Read more >Frequently Asked Questions — Version 0.21.3 - Pyodide
For security reasons JavaScript in the browser is not allowed to load local data files (for ... You can import your package like...
Read more >Loading packages — Pyodide 0.16.1 documentation
Only the Python standard library and six are available after importing Pyodide. ... It only supports packages included in Pyodide (not on PyPi)...
Read more >Creating a Pyodide package — Version 0.21.3
This tool will populate the latest version, download link and sha256 hash by querying PyPI. It doesn't currently handle package dependencies, ...
Read more >Creating a Pyodide package
This tool will populate the latest version, download link and sha256 hash by querying PyPI. It doesn't currently handle package dependencies, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
hi, i am excited to see your interest in this project. 😃
i have been working on getting torch into Pyodide. it’s pretty challenging.
we do have a alpha workflow to get non-pure python packages with c/c++/cython extensions into the pyscript/Pyodide ecosystem, but torch is extra complicated.
i plan on posting the build process for non-pure python packages as soon as i can
There was a discussion about JAX in https://github.com/pyodide/pyodide/issues/2198, tensorflow in https://github.com/pyodide/pyodide/issues/50 and torch in https://github.com/pyodide/pyodide/issues/1625. It would be great to have them but they are all fairly large and complex packages, so it would take a lot of work to make that happen.
For ML wrapping JS libraries (such as ONNX Runtime Web, Tensorflow.js etc) from Python via the Pyodide’s FFI is indeed another solution. Though your API is then not going to be exactly the same as when using e.g. Tensorflow from Python, so one cannot reuse code without changes.