Closed
Description
What's the problem this feature will solve?
There are several issues around file locking that have been filed over the years, specifically related to:
- Underlying OS/filesystem does not support hardlinks as used by the file lock (Pip Issues on Windows + ReFS #2993, infinite loop after pip install on Android API 24 #5322, pip does not work on Haiku #6761)
- Lingering lock files and/or lock files in an inconsistent state can cause pip to hang when attempting to acquire the lock (some of Infinite loop on pip when lockfile can't acquire a lock #3532, Pip locks up after failing to download a package due to network error. #5034)
- lockfile uses hostname when creating its unique name, which can result in invalid paths when hostname includes a
/
(pip hangs, lockfile can't acquire a lock, forward-slash in hostname #6938)
Describe the solution you'd like
- Write a selfcheck state file per-prefix, to remove the need to read and then write the file within a lock
- Write the file atomically (write to a separate tmp file and then move into place) to avoid partial writes if the process is killed
This will satisfy the linked issues and help us progress on #4766 to remove lockfile entirely.
Alternative Solutions
- Switch to
MkdirLockFile
as currently used in the HTTP cache - the downside of this approach is that it is not backwards-compatible, so we would need to use a separate file to track the information for modern pip versions. If we would need to use a separate file anyway, we might as well go one step further to progress Moving off lockfile #4766.
Additional context
- PR Write separate statefiles per prefix. #6855 - writes per-prefix selfcheck state files
- PR Don't use lockfile to protect updates to selfcheck file. #6879 - removes file locking