Skip to content

Commit

Permalink
Python baseline snapshot: Invalidate caches (#1913)
Browse files Browse the repository at this point in the history
Invalidate caches if we have a baseline snapshot because the contents of
site-packages may be different when we rerun.
  • Loading branch information
hoodmane authored and dom96 committed Mar 28, 2024
1 parent 290803c commit ca3deee
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/pyodide/internal/python.js
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,11 @@ export async function loadPyodide(lockfile, indexURL) {
// Finish setting up Pyodide's ffi so we can use the nice Python interface
await enterJaegerSpan("finalize_bootstrap", Module.API.finalizeBootstrap);
const pyodide = Module.API.public_api;
if (DSO_METADATA?.settings?.baselineSnapshot) {
// Invalidate caches if we have a baseline snapshot because the contents of site-packages may
// have changed.
simpleRunPython(Module, "from importlib import invalidate_caches as f; f(); del f");
}

// This is just here for our test suite. Ugly but just about the only way to test this.
if (TEST_SNAPSHOT) {
Expand Down

0 comments on commit ca3deee

Please sign in to comment.