Skip to content

Commit

Permalink
use csv module to write RECORD from editable builder
Browse files Browse the repository at this point in the history
  • Loading branch information
dimbleby committed Jun 12, 2022
1 parent b5e3fd8 commit fe05323
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/poetry/masonry/builders/editable.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import csv
import hashlib
import json
import os
Expand Down Expand Up @@ -255,14 +256,15 @@ def _add_dist_info(self, added_files: list[Path]) -> None:
added_files.append(direct_url_json)

record = dist_info.joinpath("RECORD")
with record.open("w", encoding="utf-8") as f:
with record.open("w", encoding="utf-8", newline="") as f:
csv_writer = csv.writer(f)
for path in added_files:
hash = self._get_file_hash(path)
size = path.stat().st_size
f.write(f"{path!s},sha256={hash},{size}\n")
csv_writer.writerow((path, f"sha256={hash}", size))

# RECORD itself is recorded with no hash or size
f.write(f"{record},,\n")
csv_writer.writerow((record, "", ""))

def _get_file_hash(self, filepath: Path) -> str:
hashsum = hashlib.sha256()
Expand Down

0 comments on commit fe05323

Please sign in to comment.