As per Building distributions and drawing the Platypus, I figured I would kick off a discussion to figure out where any gaps exist for downloading and installing an appropriate wheel from PyPI. I’m thinking of the case where you know the name of the project and version you want already, so this is for selecting the correct wheel from those available on PyPI, downloading it, and then installing it.
Here is the outline of steps that I’m aware of to accomplish this feature/story and whether something exists as a spec and/or package:
Cache the wheel locally (? / ?; see local cache check for potential details)
Install the wheel
Choose which directory to install the files to (e.g. user versus system/virtual environment; ? / ?)
Install the files (spec / distlib.wheel although works on file paths versus bytes and so can’t go straight from reading off the socket to installation)
Yes, I have a PR that I’ll be updating shortly with more detailed documentation on how this works in pip currently. (It was requested that I add this to an “architecture” document.)
Because I would rather not see five copies of pip or request’s wheels installed on my machine due to caching by 5 different tools. Basically why waste the disk and networking if we could all agree on where wheels should get cached?
Great! In terms of coding this it shouldn’t be hard:
# Keeping it simple by assuming PyPI.
def find_release_file(project, version):
files = pypi_release(project, version)
wheel_mapping = map_wheels_to_files(files) # Because of compressed wheel tags.
for tag in packaging.tags.sys_tags():
if file := wheel_mapping.get(tag):
return file
else:
raise NoCompatibleFileError