1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00

Cleanup arguments, add docstring

This commit is contained in:
Chris Hunt 2019-10-11 22:24:50 -04:00
parent 39572ddd12
commit 913f856739
3 changed files with 38 additions and 16 deletions

View file

@ -484,9 +484,9 @@ class InstallRequirement(object):
# type: (...) -> None
wheel.install_unpacked_wheel(
self.name,
str(self.req),
wheeldir,
scheme=scheme,
req_description=str(self.req),
pycompile=pycompile,
warn_script_location=warn_script_location,
)

View file

@ -57,7 +57,6 @@ if MYPY_CHECK_RUNNING:
Dict, List, Optional, Sequence, Mapping, Tuple, IO, Text, Any,
Iterable, Callable, Set,
)
from pip._vendor.packaging.requirements import Requirement
from pip._internal.req.req_install import InstallRequirement
from pip._internal.operations.prepare import (
RequirementPreparer
@ -332,14 +331,24 @@ class PipScriptMaker(ScriptMaker):
def install_unpacked_wheel(
name, # type: str
req, # type: str
wheeldir, # type: str
scheme, # type: Mapping[str, str]
req_description, # type: str
pycompile=True, # type: bool
warn_script_location=True # type: bool
):
# type: (...) -> None
"""Install a wheel"""
"""Install a wheel.
:param name: Name of the project to install
:param wheeldir: Base directory of the unpacked wheel
:param scheme: Distutils scheme dictating the install directories
:param req_description: String used in place of the requirement, for
logging
:param pycompile: Whether to byte-compile installed Python files
:param warn_script_location: Whether to check that scripts are installed
into a directory on PATH
"""
# TODO: Investigate and break this up.
# TODO: Look into moving this into a dedicated class for representing an
# installation.
@ -390,13 +399,16 @@ def install_unpacked_wheel(
if is_base and basedir == '' and destsubdir.endswith('.data'):
data_dirs.append(s)
continue
elif (is_base and
s.endswith('.dist-info') and
canonicalize_name(s).startswith(
canonicalize_name(name))):
assert not info_dir, ('Multiple .dist-info directories: ' +
destsubdir + ', ' +
', '.join(info_dir))
elif (
is_base and
s.endswith('.dist-info') and
canonicalize_name(s).startswith(canonicalize_name(name))
):
assert not info_dir, (
'Multiple .dist-info directories: {}, '.format(
destsubdir
) + ', '.join(info_dir)
)
info_dir.append(destsubdir)
for f in files:
# Skip unwanted files
@ -449,7 +461,9 @@ def install_unpacked_wheel(
clobber(source, lib_dir, True)
assert info_dir, "%s .dist-info directory not found" % req
assert info_dir, "{} .dist-info directory not found".format(
req_description
)
# Get the defined entry points
ep_file = os.path.join(info_dir[0], 'entry_points.txt')
@ -592,7 +606,7 @@ def install_unpacked_wheel(
"Invalid script entry point: {} for req: {} - A callable "
"suffix is required. Cf https://packaging.python.org/en/"
"latest/distributing.html#console-scripts for more "
"information.".format(entry, req)
"information.".format(entry, req_description)
)
if warn_script_location:

View file

@ -661,7 +661,11 @@ class TestInstallUnpackedWheel(object):
def test_std_install(self, data, tmpdir):
self.prep(data, tmpdir)
wheel.install_unpacked_wheel(
self.name, str(self.req), self.src, scheme=self.scheme)
self.name,
self.src,
scheme=self.scheme,
req_description=str(self.req),
)
self.assert_installed()
def test_install_prefix(self, data, tmpdir):
@ -677,9 +681,9 @@ class TestInstallUnpackedWheel(object):
)
wheel.install_unpacked_wheel(
self.name,
str(self.req),
self.src,
scheme=scheme,
req_description=str(self.req),
)
bin_dir = 'Scripts' if WINDOWS else 'bin'
@ -697,7 +701,11 @@ class TestInstallUnpackedWheel(object):
os.makedirs(src_empty_dir)
assert os.path.isdir(src_empty_dir)
wheel.install_unpacked_wheel(
self.name, str(self.req), self.src, scheme=self.scheme)
self.name,
self.src,
scheme=self.scheme,
req_description=str(self.req),
)
self.assert_installed()
assert not os.path.isdir(
os.path.join(self.dest_dist_info, 'empty_dir'))