Lock fewer Python packages and install the rest at runtime
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- python, typescript, wasm
- Domain
- backend, build-system
Research direction
Start by reading src/hooks/usePyodide.tsx and the package lock files build/shinylive/pyodide/pyodide-lock.json, shinylive_requirements.json, and shinylive_lock.json. Work out which packages must stay bundled for startup or compiled dependencies, then weigh runtime startup, offline exports, and version stability against reducing the lock. Done means a clear package selection and working lock and runtime install behavior; the issue leaves those trade-offs open.
Written by the indexing model from the issue text.
Description
Problem
The shinylive assets pin every package an app might want. Updating any of them (for example shinychat) takes make update_packages_lock plus a new shinylive release, and then py-shinylive and Quarto have to pick up that release.
The bundled Pyodide's lock (build/shinylive/pyodide/pyodide-lock.json) lists 391 packages, about 303 MB:
- Stock Pyodide packages, about 280 MB. numpy, pandas, scipy, matplotlib, ... from the Pyodide release archive. Most have compiled code, so they can't come from PyPI.
- Packages shinylive adds, about 22 MB (
shinylive_requirements.json→shinylive_lock.json):- built here: shiny, htmltools, shinywidgets, faicons, libsass;
- from PyPI: shinychat, plotly, plotnine, altair, seaborn, ipywidgets, ipyleaflet, siuba, palmerpenguins, qrcode, shinyswatch, black, and their dependencies.
Runtime install already works: a package in an app's requirements.txt that is not in the lock is installed from PyPI by micropip at startup (_install_requirements_from_dir in src/hooks/usePyodide.tsx).
Idea
Lock less, and let micropip fetch the rest at runtime.
- Keep in the lock: shiny and what it needs to start, the locally built wheels, and anything micropip can't install (compiled packages).
- Consider dropping fast-moving or optional pure-Python packages (shinychat, plotly, plotnine, seaborn, ...) so apps get the latest version without a shinylive release.
Trade-offs to weigh
- Apps that use an unlocked package need PyPI at runtime and start more slowly.
- Versions are no longer the ones we tested, so a PyPI release can break apps and examples.
- Exports and Quarto pages would no longer work offline for those packages, unless py-shinylive fetches them at export time.
- Examples that use a dropped package need a
requirements.txtentry. - Some PyPI packages need a newer compiled dependency than the bundled Pyodide has (for example, shinychat 0.7.x needs
pydantic>=2.11, which Pyodide 0.27.7 didn't have).
Related
- The website could also load the stock Pyodide packages from the Pyodide CDN instead of hosting them (about 280 MB less per deploy), as #288 does for the older shiny versions. That's a separate change from what is locked.
- Dominant language
- TypeScript
- Stars
- 253
- Forks
- 25
- Avg merge
- 6d 22h
- Merged PRs (30d)
- 13
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from posit-dev/shinylive
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 40/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 58/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
posit-dev/shinylive#221 · 8 comments · 2 reactions ·
Maintainers usually reply within 1 day
All issues in posit-dev/shinylive
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Vessel9817/onion-site-template#512 ·
Maintainers usually reply within 1 day
-
nightly-tests
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
BlackBeltTechnology/pi-agent-dashboard#1256 ·
Maintainers usually reply within 1 day
-
approved
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
fritzprix/libr-agent#3266 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
better-auth/better-auth#13101 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day