Add function to install directly from wheel files
This will help us avoid some complicated directory-changing logic in
WheelBuilder.
@@ -28,7 +28,9 @@ from pip._vendor.six import StringIO
from pip._internal.exceptions import InstallationError, UnsupportedWheel
from pip._internal.locations import get_major_minor_version
from pip._internal.utils.misc import captured_stdout, ensure_dir, hash_file
+from pip._internal.utils.temp_dir import TempDirectory
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
+from pip._internal.utils.unpacking import unpack_file
if MYPY_CHECK_RUNNING:
from typing import (
@@ -618,6 +620,27 @@ def install_unpacked_wheel(
shutil.move(temp_record, record)
+def install_wheel(
+ name, # type: str
+ wheel_path, # type: str
+ scheme, # type: Scheme
+ req_description, # type: str
+ pycompile=True, # type: bool
+ warn_script_location=True, # type: bool
+):
+ # type: (...) -> None
+ with TempDirectory(kind="unpacked-wheel") as unpacked_dir:
+ unpack_file(wheel_path, unpacked_dir)
+ install_unpacked_wheel(
+ name=name,
+ wheeldir=unpacked_dir,
+ scheme=scheme,
+ req_description=req_description,
+ pycompile=pycompile,
+ warn_script_location=warn_script_location,
+ )
+
+
def wheel_version(source_dir):
# type: (Optional[str]) -> Optional[Tuple[int, ...]]
"""Return the Wheel-Version of an extracted wheel, if possible.
