Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/installer/destinations.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from installer.records import Hash, RecordEntry
from installer.scripts import Script
from installer.utils import (
_WINDOWS,
Scheme,
construct_record_file,
copyfileobj_with_hashing,
Expand Down Expand Up @@ -267,10 +268,13 @@ def finalize_installation(
def prefix_for_scheme(file_scheme: str) -> Optional[str]:
if file_scheme == scheme:
return None
path = os.path.relpath(
self.scheme_dict[file_scheme],
start=self.scheme_dict[scheme],
)
if _WINDOWS: # pragma: no cover
path = os.path.abspath(self.scheme_dict[file_scheme]) # noqa: PTH100
else: # pragma: no cover
path = os.path.relpath(
self.scheme_dict[file_scheme],
start=self.scheme_dict[scheme],
)
return path + "/"

record_list = list(records)
Expand Down
18 changes: 11 additions & 7 deletions tests/test_destinations.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,16 @@ def test_finalize_write_record(self, destination):
file_path = Path(destination.scheme_dict["purelib"]) / "RECORD"

data = file_path.read_bytes()
assert data == (
expected_data = (
b"RECORD,,\n"
b"../data/my_data1.bin,sha256=NV0A-M4OPuqTsHjeD6Wth_-UqrpAAAdyplcustFZ8s4,9\n"
b"../data/my_data2.bin,sha256=lP7V8oWLqgyXCbdASNiPdsUogzPUZhht_7F8T5bC3eQ,9\n"
b'"../data/my_data3,my_data4.bin",sha256=18krruu1gr01x-WM_9ChSASoHv0mfRAV6-B2bd9sxpo,9\n'
b"../scripts/my_entrypoint,sha256=_p_9nwmeIeoMBfQ0akhr1KbKn3laDydg0J7cy0Fs6JI,216\n"
b"../scripts/my_script,sha256=M60fWvUSMJkPtw2apUvjWWwOcnRPcVy_zO4-4lpH08o,9\n"
b"../scripts/my_script2,sha256=k9_997kTbTYQm7EXFLclVZL1m2N98rU90QX46XeMvjY,22\n"
b"data/my_data1.bin,sha256=NV0A-M4OPuqTsHjeD6Wth_-UqrpAAAdyplcustFZ8s4,9\n"
b"data/my_data2.bin,sha256=lP7V8oWLqgyXCbdASNiPdsUogzPUZhht_7F8T5bC3eQ,9\n"
b'data/my_data3,my_data4.bin",sha256=18krruu1gr01x-WM_9ChSASoHv0mfRAV6-B2bd9sxpo,9\n'
b"scripts/my_entrypoint,sha256=_p_9nwmeIeoMBfQ0akhr1KbKn3laDydg0J7cy0Fs6JI,216\n"
b"scripts/my_script,sha256=M60fWvUSMJkPtw2apUvjWWwOcnRPcVy_zO4-4lpH08o,9\n"
b"scripts/my_script2,sha256=k9_997kTbTYQm7EXFLclVZL1m2N98rU90QX46XeMvjY,22\n"
)
assert all(
real.endswith(expected)
for real, expected in zip(data.split(b"\n"), expected_data.split(b"\n"))
)