-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider --config-settings
in wheel cache keys
#11164
Comments
IIRC we do disable cache if |
The change proposed here seems like a minor band aid for a much larger problem. In general, The caching cannot possibly be reliable, so caching wheels for builds from source is best completely disabled imho, and only used for local caching of wheels retrieved from a package index. |
@rgommers I agree that pip lacks information to cache 100% reliably. But it's useful it a lot of situations where no compiler is involved or repeated installs are made on the same platform. |
That may be worth checking for then, and only caching pure wheels? It's in the For compiled code, there's too much variation, and what I've also seen happen regularly is having users with a build that was broken initially (e.g., successful build but error on importing some module) then get confused by the broken wheel being cached and suggested changes to the build setup having no effect. |
I'm -1 on that as there is a broad middle ground where the variations are adequately captured in wheel tags. A typical example in my daily $work is psycopg2 where caching is totally valid and helpful. |
@sbidoul I wouldn't call it "totally valid", I think what you want to say is "it works well enough in practice for me". It's easy to break, in multiple ways. Not just thinks like choice of compilers, but it has flags (see its setup.py) to build with/without OpenSSL or statically like the PostgreSQL library. So if you use any of that locally, the cached wheel for that version is going to clash with what's on PyPI. And Pip won't know. I think it's safe to say that technically the only thing Pip can actually reliably cache is wheels downloaded from PyPI. Everything else is technically unreliable, and the proposal in this PR just tweaks how that unreliability works in practice a bit. If you want to go ahead and distinguish Pip already has the knobs to disable caching. The problem is that the users won't know about that. A better default that still preserves the main benefits of caching would probably be to still cache for sdists downloaded from PyPI, but not cache wheels built from local sources. |
I aware of all the caveats, as I wrote in the OP. I guess what is considered the best default will vary across user populations. Perhaps we should log more prominently that a cached wheel is used? And make |
That sounds like a good idea to me. |
In the interest of getting some traction under this, @pfmoore in #11126 (comment) when @sbidoul proposed capturing
Can we assume that sign has well and truly come? |
@sbidoul I wonder, is there any possibility of making it possible (perhaps via a That would give package authors a safety valve, not only for I suppose it's possible such a flag could be abused, but... |
Yes, I think we can see |
For the record, the simple reproducer from my report in #12672, which may be useful for anyone wishing to look into the problem: How to ReproduceInstall two copies of pygobject-stubs, ostensibly configured differently# Install 1
python3 -m venv venv_first
. ./venv_first/bin/activate
pip install pygobject-stubs --config-settings=config=Gtk3,Gdk3
# Install 2
deactivate
python3 -m venv venv_second
. ./venv_second/bin/activate
pip install pygobject-stubs --config-settings=config=Gtk4,Gdk4
# Verify the stubs versioning...
diff venv_first/lib/python3.*/site-packages/gi-stubs/repository/Gtk.pyi \
venv_second/lib/python3.*/site-packages/gi-stubs/repository/Gtk.pyi There should be differences between the two files, because one should have been built with Replacing both And as I noted there, while This makes it extremely difficult (impossible, in practice) for projects which use |
I marked this issue as awaiting PR as I think we want to do this. Until a PR is submitted and reviewed, there is no other solution than using |
Another workaround is |
FWIW, uv has implemented cache invalidation on |
^ Actually, even better, according to the PR summary:
|
What's the problem this feature will solve?
Wheel cache entries are currently keyed by source artifact URL.
However successive builds of the same artifact may yield different results, due to environmental parameters that we can't possibly know about.
There are some parameters we do know about, though:
--config-settings
Describe the solution you'd like
Expand wheel cache to
_get_cache_path_parts
to take into account config settings.Alternative Solutions
Ask users to use different cache directories or disable caching in when they use different config settings that influence the built wheels.
Additional context
#11126 (comment)
Code of Conduct
The text was updated successfully, but these errors were encountered: