Skip to content

request: Pyodide support for polars; Use polars in shinylive examples #1576

@schloerke

Description

@schloerke

Related:

Goal: Display an example app using polars on shinylive (wasm / pyodide).

Failing reprex: link

Error:

>>> Installing polars ...
Traceback (most recent call last):
  File "<exec>", line 369, in _start_app
  File "<exec>", line 302, in _install_requirements_from_dir
  File "/lib/python3.12/site-packages/micropip/_commands/install.py", line 142, in install
    await transaction.gather_requirements(requirements)
  File "/lib/python3.12/site-packages/micropip/transaction.py", line 55, in gather_requirements
    await asyncio.gather(*requirement_promises)
  File "/lib/python3.12/site-packages/micropip/transaction.py", line 62, in add_requirement
    return await self.add_requirement_inner(Requirement(req))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.12/site-packages/micropip/transaction.py", line 151, in add_requirement_inner
    await self._add_requirement_from_package_index(req)
  File "/lib/python3.12/site-packages/micropip/transaction.py", line 190, in _add_requirement_from_package_index
    wheel = find_wheel(metadata, req)
            ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.12/site-packages/micropip/transaction.py", line 281, in find_wheel
    raise ValueError(
ValueError: Can't find a pure Python 3 wheel for 'polars'.
See: https://pyodide.org/en/stable/usage/faq.html#why-can-t-micropip-find-a-pure-python-wheel-for-a-package
You can use `await micropip.install(..., keep_going=True)` to get a list of all packages with missing wheels.

Shiny uses shinylive to display its examples in the browser (via pyodide) without a central compute server. It would be nice to have polars in these examples. However, polars currently does not compile for pyodide due to threading.

Talking with @georgestagg , he believes we can follow pattern of huggingface/tokenizers's flag where they turn off threads given an envvar value (or if we could determine if the target is wasm).

If a fix is found, this could be a possible technical blog post?


Made issue for tracking. Will pick back up after posit::conf(2024). The fix will most likely need to be in the pola-rs/polars repo.

cc @gadenbuie @wch

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestshinyliveRelated to hosting app with shinylive

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions