Skip to content

Commit

Permalink
Clean up unpack_url, especially its docstring and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
McSinyx committed Aug 1, 2020
1 parent 34709cc commit 5726655
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions src/pip/_internal/operations/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,38 +227,31 @@ def unpack_url(
# type: (...) -> Optional[File]
"""Unpack link into location, downloading if required.
:param hashes: A Hashes object, one of whose embedded hashes must match,
or HashMismatch will be raised. If the Hashes is empty, no matches are
required, and unhashable types of requirements (like VCS ones, which
would ordinarily raise HashUnsupported) are allowed.
One of embedded hashes in the given Hashes object must match,
or HashMismatch will be raised. If the Hashes is empty, no matches
are required, and unhashable types of requirements (like VCS ones,
which would ordinarily raise HashUnsupported) are allowed.
"""
# non-editable vcs urls
# Non-editable VCS URL
if link.is_vcs:
unpack_vcs_link(link, location)
return None

# If it's a url to a local directory
# URL to a local directory
if link.is_existing_dir():
if os.path.isdir(location):
rmtree(location)
_copy_source_tree(link.file_path, location)
return None

# file urls
if link.is_file:
file = get_file_url(link, download_dir, hashes=hashes)

# http urls
else:
file = get_http_url(
link,
downloader,
download_dir,
hashes=hashes,
)
file = get_http_url(link, downloader, download_dir, hashes=hashes)

# unpack the archive to the build dir location. even when only downloading
# archives, they have to be unpacked to parse dependencies, except wheels
# Unpack the archive to the build directory unless it is a wheel.
# Even if the command is download, archives still have to be
# unpacked to parse dependencies.
if not link.is_wheel:
unpack_file(file.path, location, file.content_type)

Expand Down

0 comments on commit 5726655

Please sign in to comment.