Skip to content

Commit

Permalink
Get list of files directly from wheel
Browse files Browse the repository at this point in the history
One less dependency on the wheel being extracted.
  • Loading branch information
chrahunt committed Jul 9, 2020
1 parent e0f95f1 commit f943279
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/pip/_internal/operations/install/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,13 +542,16 @@ def record_installed(srcfile, destfile, modified=False):

def all_paths():
# type: () -> Iterable[RecordPath]
for dir, _subdirs, files in os.walk(
ensure_text(source, encoding="utf-8")
):
basedir = dir[len(source):].lstrip(os.path.sep)
for f in files:
path = os.path.join(basedir, f).replace(os.path.sep, "/")
yield cast("RecordPath", path)
names = wheel_zip.namelist()
# If a flag is set, names may be unicode in Python 2. We convert to
# text explicitly so these are valid for lookup in RECORD.
decoded_names = map(ensure_text, names)
for name in decoded_names:
yield cast("RecordPath", name)

def is_dir_path(path):
# type: (RecordPath) -> bool
return path.endswith("/")

def root_scheme_file_maker(source, dest):
# type: (text_type, text_type) -> Callable[[RecordPath], File]
Expand Down Expand Up @@ -586,8 +589,9 @@ def is_data_scheme_path(path):
return path.split("/", 1)[0].endswith(".data")

paths = all_paths()
file_paths = filterfalse(is_dir_path, paths)
root_scheme_paths, data_scheme_paths = partition(
is_data_scheme_path, paths
is_data_scheme_path, file_paths
)

make_root_scheme_file = root_scheme_file_maker(
Expand Down

0 comments on commit f943279

Please sign in to comment.