Skip to content

Commit

Permalink
Explicitly close the wheel temp file after it's written
Browse files Browse the repository at this point in the history
This resolves a crash that occurs on PyPy3 on Windows

Closes python-poetry/poetry#3545
  • Loading branch information
kurtmckee committed Jan 7, 2021
1 parent ad15921 commit ae6ac0b
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions poetry/core/masonry/builders/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,19 @@ def build(self):
new_mode = normalize_file_permissions(st_mode)
os.chmod(temp_path, new_mode)

with zipfile.ZipFile(
os.fdopen(fd, "w+b"), mode="w", compression=zipfile.ZIP_DEFLATED
) as zip_file:
if not self._poetry.package.build_should_generate_setup():
self._build(zip_file)
self._copy_module(zip_file)
else:
self._copy_module(zip_file)
self._build(zip_file)

self._write_metadata(zip_file)
self._write_record(zip_file)
with os.fdopen(fd, "w+b") as fd_file:
with zipfile.ZipFile(
fd_file, mode="w", compression=zipfile.ZIP_DEFLATED
) as zip_file:
if not self._poetry.package.build_should_generate_setup():
self._build(zip_file)
self._copy_module(zip_file)
else:
self._copy_module(zip_file)
self._build(zip_file)

self._write_metadata(zip_file)
self._write_record(zip_file)

wheel_path = dist_dir / self.wheel_filename
if wheel_path.exists():
Expand Down

0 comments on commit ae6ac0b

Please sign in to comment.