posit-dev / py-shiny

Shiny for Python
https://shiny.posit.co/py/
MIT License
1.32k stars 81 forks source link

Missing wheel for libsass in Shiny for Python's Pyodide distribution #1753

Open coatless opened 2 weeks ago

coatless commented 2 weeks ago

ui.Theme's dependency on libsass is problematic for the Shiny for Python environment, c.f.

ImportError: The 'libsass' package is required to compile custom themes. Please install it with `pip install {pkg}` or `pip install "shiny[theme]"`.

Adding a requirements.txt file with:

pip install libsass

Yields:

ValueError: Can't find a pure Python 3 wheel for 'libsass'.
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 app demo: Playground

Image

[!NOTE]

I do not believe it's possible to use shiny["theme"] inside of requirements.txt within the playground itself due to how the shiny package has to be started.

gadenbuie commented 2 weeks ago

Thanks @coatless, we're tracking in posit-dev/shinylive#160. The following workaround still works but as you noted we need to bring the wheel into the shinylive Python bundle.

# requirements.txt
https://pkg.garrickadenbuie.com/libsass-python/libsass-0.23.0-cp312-abi3-pyodide_2024_0_wasm32.whl
shiny[theme]
coatless commented 2 weeks ago

Ugh, sorry for the duplicate ticket. In the future, just put anything wasm related under shinylive?

gadenbuie commented 2 weeks ago

No worries! shinylive issues are very hard to place, I don't mind moving them or having duplicates that might provide links that help other find their way to the right place. But you're probably right, posit-dev/shinylive is a good starting place for anything WASM-related.