Skip to content

Conversation

@AryanBagade
Copy link
Contributor

@AryanBagade AryanBagade commented Dec 3, 2025

Summary

Load python-dateutil when initializing Pyodide using micropip.install()This PR enables users to import and use python dateutil in the Pyrefly sandbox by automatically installing the package during Pyodide initialization.

Changes:

  • Modified pythonWorker.ts to load micropip and install python-dateutil during Pyodide init
  • Added error handling to prevent initialization failures if package loading fails

Fixes #1699

Test Plan

Local Testing:

  • ⚠️ Unable to fully verify locally due to SRI (Subresource Integrity) check failures on Pyodide packages in dev environment

Verification needed:

  • Maintainers should verify this works in production/CI where SRI checks pass correctly

Load python-dateutil when initializing Pyodide using micropip.install()
@meta-cla meta-cla bot added the cla signed label Dec 3, 2025
@yangdanny97 yangdanny97 self-assigned this Dec 3, 2025
@yangdanny97
Copy link
Contributor

yangdanny97 commented Dec 3, 2025

Questions here:

  1. does the snippet that does the instlalation run at page load, or only when you hit "Run"?
  2. if the latter, is there a way to detect that the code uses that package and only install it when necessary? One package is probably fine but if we end up having a whole list of packages installed each time the page loads it could get fairly slow and expensive.

@yangdanny97
Copy link
Contributor

re: testing, @migeed-z might know

@AryanBagade
Copy link
Contributor Author

  1. does the snippet that does the instlalation run at page load, or only when you hit "Run"?

The installation runs on first "Run" click, not at page load. Pyodide initializes lazily when the worker receives user's first code execution, so the package is installed then and cached for all subsequent runs.

@meta-codesync
Copy link

meta-codesync bot commented Dec 4, 2025

@yangdanny97 has imported this pull request. If you are a Meta employee, you can view this in D88415618.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sandbox has source not found for dateutil

2 participants