Skip to content

Can/should pip download directly to target directory #8755

Closed
@McSinyx

Description

@McSinyx

Environment

  • pip version: ea10d0e
  • Python version: 3.8.5, but I think it is irrelevant
  • OS: Debian, but I think it is irrelevant

Description

Currently pip download (and pip wheel also I believe) download distributions to a temporary directory. I think this is to unpack sdists (and historically wheels as well), and probably it also has something to do with caching (I'm not really familiar with the caching mechanism and would love to know the answer).

# let's download to a tmp dir
from_path, content_type = _download_http_url(
link, downloader, temp_dir.path, hashes

Later these will be copied to the download_dir:

if download_dir:
if link.is_existing_dir():
logger.info('Link is a directory, ignoring download_dir')
elif local_file:
download_location = os.path.join(
download_dir, link.filename
)
if not os.path.exists(download_location):
shutil.copy(local_file.path, download_location)
download_path = display_path(download_location)
logger.info('Saved %s', download_path)
if self._download_should_save:
# Make a .zip of the source_dir we already created.
if link.is_vcs:
req.archive(self.download_dir)

I'm wondering is there any reason not to download, at least wheels, directly to the user-specified directory and avoid copying.

This was initially raised as a TODO in #8737 (comment) but was suggested by @chrahunt to be filed in a separate issue instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions