From d441f9518b4c70ee75384dc5811679ace70b2805 Mon Sep 17 00:00:00 2001 From: Chris Hunt Date: Fri, 3 Jul 2020 20:49:16 -0400 Subject: [PATCH 1/2] Get wheel RECORD directly from wheel file This reduces our dependence on disk files, and removes some complexity around Python 2/3 compatibility with the csv module. --- src/pip/_internal/operations/install/wheel.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pip/_internal/operations/install/wheel.py b/src/pip/_internal/operations/install/wheel.py index 0adeb3229b0..9fa0c28d399 100644 --- a/src/pip/_internal/operations/install/wheel.py +++ b/src/pip/_internal/operations/install/wheel.py @@ -644,10 +644,11 @@ def _generate_file(path, **kwargs): pass generated.append(requested_path) + record_text = distribution.get_metadata('RECORD') + record_rows = list(csv.reader(record_text.splitlines())) + # Record details of all files installed record_path = os.path.join(dest_info_dir, 'RECORD') - with open(record_path, **csv_io_kwargs('r')) as record_file: - record_rows = list(csv.reader(record_file)) rows = get_csv_rows_for_installed( record_rows, From d7b5a776b3df79cbe63673ec248a40f9871a68f4 Mon Sep 17 00:00:00 2001 From: Chris Hunt Date: Fri, 3 Jul 2020 20:53:56 -0400 Subject: [PATCH 2/2] Move record_path closer to first use --- src/pip/_internal/operations/install/wheel.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pip/_internal/operations/install/wheel.py b/src/pip/_internal/operations/install/wheel.py index 9fa0c28d399..99edfa08187 100644 --- a/src/pip/_internal/operations/install/wheel.py +++ b/src/pip/_internal/operations/install/wheel.py @@ -647,9 +647,6 @@ def _generate_file(path, **kwargs): record_text = distribution.get_metadata('RECORD') record_rows = list(csv.reader(record_text.splitlines())) - # Record details of all files installed - record_path = os.path.join(dest_info_dir, 'RECORD') - rows = get_csv_rows_for_installed( record_rows, installed=installed, @@ -657,6 +654,9 @@ def _generate_file(path, **kwargs): generated=generated, lib_dir=lib_dir) + # Record details of all files installed + record_path = os.path.join(dest_info_dir, 'RECORD') + with _generate_file(record_path, **csv_io_kwargs('w')) as record_file: # The type mypy infers for record_file is different for Python 3 # (typing.IO[Any]) and Python 2 (typing.BinaryIO). We explicitly