diff options
author | Anderson Bravalheri <andersonbravalheri@gmail.com> | 2023-05-03 13:18:46 +0100 |
---|---|---|
committer | Anderson Bravalheri <andersonbravalheri@gmail.com> | 2023-05-03 14:09:17 +0100 |
commit | ae8ec5c3f4cfc7f14783b4dd58c436a7ba168138 (patch) | |
tree | 092c426f4747d1451d58dc94775813ad4dbf61bf /setuptools/monkey.py | |
parent | 81498f146f9eb01e04eecc53dc1147c6d21470be (diff) | |
download | python-setuptools-git-dev/core_metadata.tar.gz |
Improve atomicity when writing PKG-INFOdev/core_metadata
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.
Diffstat (limited to 'setuptools/monkey.py')
-rw-r--r-- | setuptools/monkey.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/setuptools/monkey.py b/setuptools/monkey.py index 23a5832d..5154d4c7 100644 --- a/setuptools/monkey.py +++ b/setuptools/monkey.py @@ -100,7 +100,9 @@ def patch_all(): def _patch_distribution_metadata(): """Patch write_pkg_file and read_pkg_file for higher metadata standards""" - for attr in ('write_pkg_file', 'read_pkg_file', 'get_metadata_version'): + for attr in ( + 'write_pkg_info', 'write_pkg_file', 'read_pkg_file', 'get_metadata_version' + ): new_val = getattr(setuptools._core_metadata, attr) setattr(distutils.dist.DistributionMetadata, attr, new_val) |