Skip to content

Commit

Permalink
fixup! delete for compat
Browse files Browse the repository at this point in the history
  • Loading branch information
webknjaz committed Dec 12, 2024
1 parent c0f352e commit fe6248a
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions piptools/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,16 +217,24 @@ def _temporary_constraints_file_set_for_pip(
) -> Iterator[None]:
with tempfile.NamedTemporaryFile(
mode="w+t",
delete_on_close=False,
delete=False, # FIXME: switch to `delete_on_close` in Python 3.12+
) as tmpfile:
# Write packages to upgrade to a temporary file to set as
# constraints for the installation to the builder environment,
# in case build requirements are among them
tmpfile.write("\n".join(upgrade_packages))
tmpfile.flush()

with _env_var("PIP_CONSTRAINT", tmpfile.name):
yield
# FIXME: replace `delete` with `delete_on_close` in Python 3.12+
# FIXME: and replace `.close()` with `.flush()`
tmpfile.close()

try:
with _env_var("PIP_CONSTRAINT", tmpfile.name):
yield
finally:
# FIXME: replace `delete` with `delete_on_close` in Python 3.12+
# FIXME: and drop this manual deletion
os.unlink(tmpfile.name)


@contextlib.contextmanager
Expand Down

0 comments on commit fe6248a

Please sign in to comment.