diff --git a/src/pip/_internal/network/cache.py b/src/pip/_internal/network/cache.py index eaa51141834..40e6bb9b14f 100644 --- a/src/pip/_internal/network/cache.py +++ b/src/pip/_internal/network/cache.py @@ -77,6 +77,8 @@ def _write(self, path: str, data: bytes) -> None: with adjacent_tmp_file(path) as f: f.write(data) + # `& 0o666` selects the read/write permissions of the directory. + # `| 0o600` sets owner read/write permissions. os.chmod(f.name, os.stat(self.directory).st_mode & 0o666 | 0o600) replace(f.name, path)