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

Move info_dir calculation up

This will let us use the value for later processing.
This commit is contained in:
Chris Hunt 2019-12-31 12:12:17 -05:00
parent 69143848b0
commit 918b154518

View file

@ -324,6 +324,31 @@ def install_unpacked_wheel(
# TODO: Look into moving this into a dedicated class for representing an
# installation.
source = wheeldir.rstrip(os.path.sep) + os.path.sep
subdirs = os.listdir(source)
info_dirs = [s for s in subdirs if s.endswith('.dist-info')]
assert info_dirs, "{} .dist-info directory not found".format(
req_description
)
assert len(info_dirs) == 1, (
'{} multiple .dist-info directories found: {}'.format(
req_description, ', '.join(info_dirs)
)
)
info_dir = info_dirs[0]
info_dir_name = canonicalize_name(info_dir)
canonical_name = canonicalize_name(name)
if not info_dir_name.startswith(canonical_name):
raise UnsupportedWheel(
"{} .dist-info directory {!r} does not start with {!r}".format(
req_description, info_dir, canonical_name
)
)
try:
version = wheel_version(wheeldir)
except UnsupportedWheel as e:
@ -338,9 +363,6 @@ def install_unpacked_wheel(
else:
lib_dir = scheme.platlib
source = wheeldir.rstrip(os.path.sep) + os.path.sep
subdirs = os.listdir(source)
info_dirs = [s for s in subdirs if s.endswith('.dist-info')]
data_dirs = [s for s in subdirs if s.endswith('.data')]
# Record details of the files moved
@ -434,27 +456,6 @@ def install_unpacked_wheel(
clobber(source, lib_dir, True)
assert info_dirs, "{} .dist-info directory not found".format(
req_description
)
assert len(info_dirs) == 1, (
'{} multiple .dist-info directories found: {}'.format(
req_description, ', '.join(info_dirs)
)
)
info_dir = info_dirs[0]
info_dir_name = canonicalize_name(info_dir)
canonical_name = canonicalize_name(name)
if not info_dir_name.startswith(canonical_name):
raise UnsupportedWheel(
"{} .dist-info directory {!r} does not start with {!r}".format(
req_description, info_dir, canonical_name
)
)
dest_info_dir = os.path.join(lib_dir, info_dir)
# Get the defined entry points