Is it possible to build python wheel in browser using wasm for pyodide?

544 views Asked by At

I have implemented pyodide in browser for small web apps. Some python package have no pure python wheel so I have built locally then uploaded to CDN. This python wheel can be installed using micropip in pyodide.

So my questions, is there way to build the wheel in browser for pyodide. What will be difficulty for implementing this? I am curious to know. Thanks

1

There are 1 answers

0
rth On BEST ANSWER

To the extent that a wheel of a pure Python packages consists of some Python files with metadata, packaged as a ZIP file, you can certainly create such an archive in Pyodide.

In practice though, wheels are most commonly created with setuptools or the wheel package which has following challenges for pyodide:

  1. setuptools, at least, uses the subprocess module which is not supported in WebAssembly VM, meaning that it would need to be patched to avoid making subprocess calls
  2. install requirements in setup.py (and build requirements in pyproject.toml) imply that one is able to download and install dependencies with pip which poses its own chalenges, namely,
    • the use of subprocess in pip / setuptools
    • fetching of packages with standard python modules also doesn't work (no sockets in WASM) unless ones rewrites some of them with Web API pyodide#140

For those reason, micropip was written as very rudimentary alternative to pip in the context of pyodide.

It's also a good idea to create wheels for pure python packages even for Python on classical architectures, as they don't require arbitrary code execution to install. Which means that wheels are safer, more reliable and faster to install.