Skip to content

Commit de1987b

Browse files
Update tools/wheelmaker.py
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent c94eede commit de1987b

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

tools/wheelmaker.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,13 @@ def _zipinfo(self, filename):
228228

229229
def _quote_filename(self, filename: str) -> str:
230230
"""Return a possibly quoted filename for RECORD file."""
231-
# Use csv writer to auto-quote the filename (may contain ",")
231+
filename = filename.lstrip("/")
232+
# Some RECORDs like torch have *all* filenames quoted and we must minimize diff.
233+
# Otherwise, we quote only when necessary (e.g. for filenames with commas).
234+
quoting = csv.QUOTE_ALL if self.quote_all_filenames else csv.QUOTE_MINIMAL
232235
with io.StringIO() as buf:
233-
csv.writer(buf).writerow([filename.lstrip("/")])
234-
filename = buf.getvalue().strip()
235-
# Some RECORDs like torch have *all* filenames quoted and we must minimize diff
236-
if self.quote_all_filenames and not filename.startswith('"'):
237-
filename = f'"{filename}"'
238-
return filename
236+
csv.writer(buf, quoting=quoting).writerow([filename])
237+
return buf.getvalue().strip()
239238

240239
def add_recordfile(self) -> str:
241240
"""Write RECORD file to the distribution."""

0 commit comments

Comments
 (0)