mirror of https://github.com/pypa/pip
Fix the RECORD filename of installed files appearing in the old RECORD.
This commit is contained in:
parent
b6a2be0e0e
commit
ebe2417110
|
@ -0,0 +1,2 @@
|
||||||
|
Fix a regression introduced in 19.0.2 where the filename in a RECORD file
|
||||||
|
of an installed file would not be updated when installing a wheel.
|
|
@ -267,16 +267,23 @@ def get_csv_rows_for_installed(
|
||||||
lib_dir, # type: str
|
lib_dir, # type: str
|
||||||
):
|
):
|
||||||
# type: (...) -> List[InstalledCSVRow]
|
# type: (...) -> List[InstalledCSVRow]
|
||||||
|
"""
|
||||||
|
:param installed: A map from archive RECORD path to installation RECORD
|
||||||
|
path.
|
||||||
|
"""
|
||||||
installed_rows = [] # type: List[InstalledCSVRow]
|
installed_rows = [] # type: List[InstalledCSVRow]
|
||||||
for row in old_csv_rows:
|
for row in old_csv_rows:
|
||||||
if len(row) > 3:
|
if len(row) > 3:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
'RECORD line has more than three elements: {}'.format(row)
|
'RECORD line has more than three elements: {}'.format(row)
|
||||||
)
|
)
|
||||||
fpath = row[0]
|
# Make a copy because we are mutating the row.
|
||||||
fpath = installed.pop(fpath, fpath)
|
row = list(row)
|
||||||
if fpath in changed:
|
old_path = row[0]
|
||||||
digest, length = rehash(fpath)
|
new_path = installed.pop(old_path, old_path)
|
||||||
|
row[0] = new_path
|
||||||
|
if new_path in changed:
|
||||||
|
digest, length = rehash(new_path)
|
||||||
row[1] = digest
|
row[1] = digest
|
||||||
row[2] = length
|
row[2] = length
|
||||||
installed_rows.append(tuple(row))
|
installed_rows.append(tuple(row))
|
||||||
|
|
|
@ -241,7 +241,9 @@ def call_get_csv_rows_for_installed(tmpdir, text):
|
||||||
path = tmpdir.join('temp.txt')
|
path = tmpdir.join('temp.txt')
|
||||||
path.write(text)
|
path.write(text)
|
||||||
|
|
||||||
installed = {}
|
# Test that an installed file appearing in RECORD has its filename
|
||||||
|
# updated in the new RECORD file.
|
||||||
|
installed = {'a': 'z'}
|
||||||
changed = set()
|
changed = set()
|
||||||
generated = []
|
generated = []
|
||||||
lib_dir = '/lib/dir'
|
lib_dir = '/lib/dir'
|
||||||
|
@ -263,7 +265,7 @@ def test_get_csv_rows_for_installed(tmpdir, caplog):
|
||||||
outrows = call_get_csv_rows_for_installed(tmpdir, text)
|
outrows = call_get_csv_rows_for_installed(tmpdir, text)
|
||||||
|
|
||||||
expected = [
|
expected = [
|
||||||
('a', 'b', 'c'),
|
('z', 'b', 'c'),
|
||||||
('d', 'e', 'f'),
|
('d', 'e', 'f'),
|
||||||
]
|
]
|
||||||
assert outrows == expected
|
assert outrows == expected
|
||||||
|
@ -280,7 +282,7 @@ def test_get_csv_rows_for_installed__long_lines(tmpdir, caplog):
|
||||||
outrows = call_get_csv_rows_for_installed(tmpdir, text)
|
outrows = call_get_csv_rows_for_installed(tmpdir, text)
|
||||||
|
|
||||||
expected = [
|
expected = [
|
||||||
('a', 'b', 'c', 'd'),
|
('z', 'b', 'c', 'd'),
|
||||||
('e', 'f', 'g'),
|
('e', 'f', 'g'),
|
||||||
('h', 'i', 'j', 'k'),
|
('h', 'i', 'j', 'k'),
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue