Skip to content

Web / Add Support for "Pyodide Packages" #1104

@rmartin16

Description

@rmartin16

What is the problem or limitation you are having?

Pyodide maintains a collection of popular Python packages that are compatible with the pyscript runtime.

It is currently difficult to use these packages within the Briefcase web workflows. For example, if you add numpy to the pyproject.toml requires list, and then briefcase run web, Pyodide gives a runtime error "Wheel platform 'win_amd64' is not compatible with Pyodide's platform".

Image

Describe the solution you'd like

Briefcase static web format should support adding Pyodide packages as requirements to the app.

Describe alternatives you've considered

Manually add the needed package to pyscript.toml. This needs to happen each time the app is rebuilt.

packages = [
    "/static/wheels/helloworld-0.0.1-py3-none-any.whl",
    "/static/wheels/toga_core-0.3.0-py3-none-any.whl",
    "/static/wheels/toga_web-0.3.0-py3-none-any.whl",
    "/static/wheels/travertino-0.1.3-py3-none-any.whl",
    "numpy",
]

See the package loaded in the browser console:

[pyscript/main] Packages to install:  (5) ['/static/wheels/helloworld-0.0.1-py3-none-any.whl', '/static/wheels/toga_core-0.3.0-py3-none-any.whl', '/static/wheels/toga_web-0.3.0-py3-none-any.whl', '/static/wheels/travertino-0.1.3-py3-none-any.whl', 'numpy']0: "/static/wheels/helloworld-0.0.1-py3-none-any.whl"1: "/static/wheels/toga_core-0.3.0-py3-none-any.whl"2: "/static/wheels/toga_web-0.3.0-py3-none-any.whl"3: "/static/wheels/travertino-0.1.3-py3-none-any.whl"4: "numpy"]
pyodide.asm.js:10 Loading numpy
pyodide.asm.js:10 Loaded numpy

It does seem eventually that library maintainers will be able to provide packages on PyPI that will be compatible with browser runtimes.

In theory, it should also probably be possible to download Pyodide's numpy wheel but pip gets upset about the platform for the downloaded wheel.

>>> Running Command:
>>>     /home/russell/github/beeware/briefcase/venv-3.10-briefcase/bin/python -u -m pip wheel --wheel-dir '/home/russell/tmp/beeware/helloworld/web/static/Hello World/www/static/wheels' -r '/home/russell/tmp/beeware/helloworld/web/static/Hello World/requirements.txt'
>>> Working Directory:
>>>     /home/russell/tmp/beeware/helloworld
ERROR: numpy-1.22.4-cp310-cp310-emscripten_3_1_14_wasm32.whl is not a supported wheel on this platform.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew features, or improvements to existing features.webThe issue relates to supporting the web as a platform.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions