piptools._compat.tempfile_compat module

Compatibility helpers for tempfile usage across platforms and python versions.

piptools._compat.tempfile_compat.named_temp_file(mode: str = 'wt') Iterator[IO[str]]

A safe wrapper over NamedTemporaryFile for usage on Windows as well as POSIX systems.

The issue we have is that we cannot guarantee that pip will open temporary files on Windows with O_TEMPORARY when passed the path, resulting in surprising behavior.