Skip to content

fix: disable packages cache when local wheels are detected#184

Open
Archmonger wants to merge 1 commit into
pyscript:mainfrom
Archmonger:fix-issue-2282-local-wheel-cache
Open

fix: disable packages cache when local wheels are detected#184
Archmonger wants to merge 1 commit into
pyscript:mainfrom
Archmonger:fix-issue-2282-local-wheel-cache

Conversation

@Archmonger

@Archmonger Archmonger commented Jul 20, 2026

Copy link
Copy Markdown

Description

Fixes pyscript/pyscript#2282

When local .whl files are specified in the packages list, their dependencies fail to resolve on subsequent page loads because micropip.freeze() stores stale absolute or virtual filesystem references in IndexedDB. On the next page load, the frozen lockfile is restored instead of running micropip.install(), causing ModuleNotFoundError for the wheel's dependencies.

Somewhat of a band-aid, based on the following response:

There are cache cases we were hoping to easily control out of the micropip box but if we need to orchestrate anything "that convoluted" you are actually better off without the cache because nothing else would be necessarily faster but it's something to consider/think about sooner than later.

Solution

This change automatically sets packages_cache to 'never' when local wheels are detected in the packages array. Local wheels are identified by:

  • Paths starting with ./, ../, /, emfs://, file://
  • URLs ending with .whl

Users can still explicitly opt into caching with packages_cache = "all".

Related

When local .whl files are specified in the packages list, their
dependencies fail to resolve on subsequent page loads because
micropip.freeze() stores stale references in IndexedDB.

This change automatically sets packages_cache to "never" when local
wheels are detected (paths starting with ./, ../, /, emfs://, file://,
or URLs ending in .whl). Users can still opt into caching with
packages_cache = "all".
@WebReflection

Copy link
Copy Markdown
Contributor

I think we should freeze the VFS into IndexedDB instead of using micropip because this problem has been coming up so many times already ... but this seems sensible, will have a look but I am on vacation right now, not sure if I'll manage before the 27th 'cause it needs a release via PyScript.

// or URLs ending in .whl. When local wheels are present, disable IndexedDB
// caching unless the user explicitly sets packages_cache = "all".
// See https://github.com/pyscript/pyscript/issues/2282
if (packages && packages.some(pkg => /^(?:\.{1,2}\/|\/|emfs:\/\/|file:\/\/)/.test(pkg) || /\.whl(?:\?|$)/.test(pkg))) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/^(?:\.{1,2}\/|\/|(?:emfs|file):\/\/)/.test(pkg)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Configuring "packages" to a local wheel causes dependency resolution failure V0.6.x micropip often fails to discover package

2 participants