mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
Merge pull request #7044 from chrahunt/refactor/no-download-in-wheel
Remove download dependency from wheel
This commit is contained in:
commit
716628a103
6 changed files with 16 additions and 13 deletions
|
@ -883,7 +883,7 @@ def is_dir_url(link):
|
|||
first.
|
||||
|
||||
"""
|
||||
link_path = url_to_path(link.url_without_fragment)
|
||||
link_path = link.file_path
|
||||
return os.path.isdir(link_path)
|
||||
|
||||
|
||||
|
@ -1115,7 +1115,7 @@ def unpack_file_url(
|
|||
If download_dir is provided and link points to a file, make a copy
|
||||
of the link file inside download_dir.
|
||||
"""
|
||||
link_path = url_to_path(link.url_without_fragment)
|
||||
link_path = link.file_path
|
||||
# If it's a url to a local directory
|
||||
if is_dir_url(link):
|
||||
if os.path.isdir(location):
|
||||
|
|
|
@ -12,6 +12,7 @@ from pip._internal.utils.misc import (
|
|||
)
|
||||
from pip._internal.utils.models import KeyBasedCompareMixin
|
||||
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
|
||||
from pip._internal.utils.urls import url_to_path
|
||||
|
||||
if MYPY_CHECK_RUNNING:
|
||||
from typing import Optional, Text, Tuple, Union
|
||||
|
@ -96,6 +97,11 @@ class Link(KeyBasedCompareMixin):
|
|||
assert name, ('URL %r produced no filename' % self._url)
|
||||
return name
|
||||
|
||||
@property
|
||||
def file_path(self):
|
||||
# type: () -> str
|
||||
return url_to_path(self.url)
|
||||
|
||||
@property
|
||||
def scheme(self):
|
||||
# type: () -> str
|
||||
|
|
|
@ -27,7 +27,6 @@ from pip._internal.utils.logging import indent_log
|
|||
from pip._internal.utils.marker_files import write_delete_marker_file
|
||||
from pip._internal.utils.misc import display_path, normalize_path
|
||||
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
|
||||
from pip._internal.utils.urls import url_to_path
|
||||
|
||||
if MYPY_CHECK_RUNNING:
|
||||
from typing import Optional
|
||||
|
@ -123,7 +122,7 @@ class RequirementPreparer(object):
|
|||
|
||||
# TODO: Breakup into smaller functions
|
||||
if link.scheme == 'file':
|
||||
path = url_to_path(link.url)
|
||||
path = link.file_path
|
||||
logger.info('Processing %s', display_path(path))
|
||||
else:
|
||||
logger.info('Collecting %s', req.req or req)
|
||||
|
|
|
@ -210,7 +210,7 @@ def untar_file(filename, location):
|
|||
def unpack_file(
|
||||
filename, # type: str
|
||||
location, # type: str
|
||||
content_type, # type: Optional[str]
|
||||
content_type=None, # type: Optional[str]
|
||||
):
|
||||
# type: (...) -> None
|
||||
filename = os.path.realpath(filename)
|
||||
|
|
|
@ -28,7 +28,6 @@ from pip._vendor.packaging.utils import canonicalize_name
|
|||
from pip._vendor.six import StringIO
|
||||
|
||||
from pip._internal import pep425tags
|
||||
from pip._internal.download import unpack_file_url
|
||||
from pip._internal.exceptions import (
|
||||
InstallationError,
|
||||
InvalidWheelFilename,
|
||||
|
@ -51,6 +50,7 @@ from pip._internal.utils.setuptools_build import make_setuptools_shim_args
|
|||
from pip._internal.utils.temp_dir import TempDirectory
|
||||
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
|
||||
from pip._internal.utils.ui import open_spinner
|
||||
from pip._internal.utils.unpacking import unpack_file
|
||||
|
||||
if MYPY_CHECK_RUNNING:
|
||||
from typing import (
|
||||
|
@ -1153,7 +1153,7 @@ class WheelBuilder(object):
|
|||
req.link = Link(path_to_url(wheel_file))
|
||||
assert req.link.is_wheel
|
||||
# extract the wheel into the dir
|
||||
unpack_file_url(link=req.link, location=req.source_dir)
|
||||
unpack_file(req.link.file_path, req.source_dir)
|
||||
else:
|
||||
build_failure.append(req)
|
||||
|
||||
|
|
|
@ -369,10 +369,8 @@ def test_wheel_version(tmpdir, data):
|
|||
broken_wheel = 'brokenwheel-1.0-py2.py3-none-any.whl'
|
||||
future_version = (1, 9)
|
||||
|
||||
unpack_file(data.packages.joinpath(future_wheel),
|
||||
tmpdir + 'future', None)
|
||||
unpack_file(data.packages.joinpath(broken_wheel),
|
||||
tmpdir + 'broken', None)
|
||||
unpack_file(data.packages.joinpath(future_wheel), tmpdir + 'future')
|
||||
unpack_file(data.packages.joinpath(broken_wheel), tmpdir + 'broken')
|
||||
|
||||
assert wheel.wheel_version(tmpdir + 'future') == future_version
|
||||
assert not wheel.wheel_version(tmpdir + 'broken')
|
||||
|
@ -593,7 +591,7 @@ class TestWheelFile(object):
|
|||
def test_unpack_wheel_no_flatten(self, tmpdir):
|
||||
filepath = os.path.join(DATA_DIR, 'packages',
|
||||
'meta-1.0-py2.py3-none-any.whl')
|
||||
unpack_file(filepath, tmpdir, 'application/zip')
|
||||
unpack_file(filepath, tmpdir)
|
||||
assert os.path.isdir(os.path.join(tmpdir, 'meta-1.0.dist-info'))
|
||||
|
||||
def test_purelib_platlib(self, data):
|
||||
|
@ -633,7 +631,7 @@ class TestMoveWheelFiles(object):
|
|||
self.req = Requirement('sample')
|
||||
self.src = os.path.join(tmpdir, 'src')
|
||||
self.dest = os.path.join(tmpdir, 'dest')
|
||||
unpack_file(self.wheelpath, self.src, None)
|
||||
unpack_file(self.wheelpath, self.src)
|
||||
self.scheme = {
|
||||
'scripts': os.path.join(self.dest, 'bin'),
|
||||
'purelib': os.path.join(self.dest, 'lib'),
|
||||
|
|
Loading…
Reference in a new issue