Read record file once during legacy install
@@ -823,6 +823,12 @@ class InstallRequirement(object):
return
self.install_succeeded = True
+ # We intentionally do not use any encoding to read the file because
+ # setuptools writes the file using distutils.file_util.write_file,
+ # which does not specify an encoding.
+ with open(record_filename) as f:
+ record_lines = f.read().splitlines()
+
def prepend_root(path):
# type: (str) -> str
if root is None or not os.path.isabs(path):
@@ -830,11 +836,7 @@ class InstallRequirement(object):
else:
return change_root(root, path)
- # We intentionally do not use any encoding to read the file because
- # setuptools writes the file using distutils.file_util.write_file,
- # which does not specify an encoding.
- with open(record_filename) as f:
- for line in f:
+ for line in record_lines:
directory = os.path.dirname(line)
if directory.endswith('.egg-info'):
egg_info_dir = prepend_root(directory)
@@ -859,8 +861,7 @@ class InstallRequirement(object):
# FIXME: put the record somewhere
return
new_lines = []
- with open(record_filename) as f:
- for line in f:
+ for line in record_lines:
filename = line.strip()
if os.path.isdir(filename):
filename += os.path.sep
