Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve atomicity when writing PKG-INFO
For the time being, when `setuptools.build_meta` is called, `egg_info.egg_base` is accidentally set to the project root between the several calls to the different build hooks. This means that if the hooks are called, they will try to overwrite `setuptools.egg-info/PKG-INFO`, and for a very short interval of time it will be an empty file. Another process may then try to simultaneously use `importlib.metadata` to list entry-points. However to sort entry-points, `importlib.metadata` will try to read the `Name` field in the `PKG-INFO/METADATA` files and will raise an error/warning if that file is empty. This commit tries to use `os.replace` to avoid having an empty PKG-INFO while `importlib.metadata` is used.
- Loading branch information