Skip to content

fix: skip wheel cache for local directory links#14080

Open
shivamshrey wants to merge 3 commits into
pypa:mainfrom
shivamshrey:fix-local-dir-wheel-cache
Open

fix: skip wheel cache for local directory links#14080
shivamshrey wants to merge 3 commits into
pypa:mainfrom
shivamshrey:fix-local-dir-wheel-cache

Conversation

@shivamshrey

Copy link
Copy Markdown

Fixes #14044

This prevents SimpleWheelCache from returning a cached wheel when the
requirement link points to an existing local directory, such as
Package @ file:///path/to/project.

Added a regression test covering local directory links.

Fixes pypa#14044

This prevents `SimpleWheelCache` from returning a cached wheel when the
requirement link points to an existing local directory, such as
`Package @ file:///path/to/project`.

Added a regression test covering local directory links.
@notatallshaw

Copy link
Copy Markdown
Member

Thanks for the PR!

Hope you don't mind, but I've added two commits:

  • Given we're not reading from the cache, we can also stop writing to the cache
  • Additional unit and functional tests

@notatallshaw

Copy link
Copy Markdown
Member

Some design thoughts here:

This will always produce the correct result but potentially at a huge performance cost for some users. We could instead tag the source of the cached item and only allow cache to be used in this case when it came from the same file path?

@notatallshaw notatallshaw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

My current thinking is we should merge this as a correctness fix and come up with a better caching strategy as a later optimization, perhaps motivated if we get real world reports.

But if another maintainer disagrees feel free to block merging this.

@ichard26

ichard26 commented Jun 19, 2026

Copy link
Copy Markdown
Member

This will always produce the correct result but potentially at a huge performance cost for some users. We could instead tag the source of the cached item and only allow cache to be used in this case when it came from the same file path?

Sorry, what's the concern? I thought pip was supposed to rebuild local project directories? is the concern that we're expanding this and may catch some users off-guard who didn't mind the cached wheels?

Like, we do make this claim in the documentation:

Wheels built from source distributions provided to pip as a direct path (such as pip install .) are not cached across runs, though they may be reused within the same pip execution.

The language here is a bit weird since . is not a source distribution, but why shouldn't name @ file:. be the same as just .?

FWIW, I also don't understand how this bug occurs. The reproduction example requires a (seemingly) locally built wheel is manually placed in the cache when the this wheel shouldn't have been cached in the first place. I'm not saying the bug isn't real, but I think we should dig into what's happening exactly first.

I'll find some time to do that soon.

@notatallshaw

Copy link
Copy Markdown
Member

Sorry, what's the concern? I thought pip was supposed to rebuild local project directories? is the concern that we're expanding this and may catch some users off-guard who didn't mind the cached wheels?

At the moment there is a bug which means this doesn't always happen, some users may be surprised that they previously weren't building and now are.

It's definitely correct to be building, but due to Hyrum's Law I'm sure someone is relying on this behavior.

The reproduction example requires a (seemingly) locally built wheel is manually placed in the cache when the this wheel shouldn't have been cached in the first place. I'm not saying the bug isn't real, but I think we should dig into what's happening exactly first.

There was a discord discussion about this: https://discord.com/channels/803025117553754132/837243676814999553/1513958096571990086

The user had the issue, thought it was a difference between specifying /path/to/project/.[extra] and Package-Name[extra] @ file:///path/to/project, after digging into it it's because it was cached.

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.

pip install sometimes uses the cache when using pkg @ file:///path syntax

3 participants