Description
Currently, when pip downloads sdists it is sometimes necessary for it to build a wheel in order to get trustworthy metadata #7995 #1884. Ideally it wouldn't need to do so, but that is a difficult problem to solve.
I would instead suggest that when pip does need to build a wheel during download it should default to saving that resulting wheel along-side the sdist package. This would let users avoid having to build the wheel twice in some cases, which could save a considerable amount of time.
While there are other cases where that wheel wouldn't be useful to the user (they want to make modifications first, control build settings, etc) it doesn't hurt them to have it, as it was being built anyway, and thus the time and disc space requirements are unchanged. People using pip download
in scripts and the like may have to make changes to account for the additional file, so a transition plan would be needed.
I think the closest existing alternative to this is pip download --build ./tmp --no-clean
. The main downside to that is knowing and remembering that it is necessary. Users are often surprised that pip download
builds packages. Even when aware of the issue it can be easy to forget, especially when an sdist is downloaded because no appropriate wheels are available rather than because --no-binary
was used.
This might dovetail with #9769 which aims to always make wheels as an intermediate step in installing sdists.