summaryrefslogtreecommitdiff
path: root/setuptools/monkey.py
diff options
context:
space:
mode:
authorPaul Ganssle <paul@ganssle.io>2018-11-05 10:23:15 -0500
committerPaul Ganssle <paul@ganssle.io>2018-11-07 17:38:41 -0500
commit386fcdbe02c4170a560d67742f2ac1319430ff43 (patch)
treeceb7f45963660ee9e9fd8e60598f57071cc0bf10 /setuptools/monkey.py
parente5d362d3736bc5972835a55bcb165d8c55913547 (diff)
downloadpython-setuptools-git-386fcdbe02c4170a560d67742f2ac1319430ff43.tar.gz
Start patching DistributionMetadata.read_pkg_file
This turns get_metadata_version into a method on DistributionMetadata, populated either by inferrence (in the case of package metadata specified in `setup`) or from the data in a specified PKG-INFO file. To populate metadata_version from PKG-INFO, we need to monkey patch read_pkg_file in addition to write_pkg_file.
Diffstat (limited to 'setuptools/monkey.py')
-rw-r--r--setuptools/monkey.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/setuptools/monkey.py b/setuptools/monkey.py
index 05a738b0..3c77f8cf 100644
--- a/setuptools/monkey.py
+++ b/setuptools/monkey.py
@@ -84,7 +84,7 @@ def patch_all():
warehouse = 'https://upload.pypi.org/legacy/'
distutils.config.PyPIRCCommand.DEFAULT_REPOSITORY = warehouse
- _patch_distribution_metadata_write_pkg_file()
+ _patch_distribution_metadata()
# Install Distribution throughout the distutils
for module in distutils.dist, distutils.core, distutils.cmd:
@@ -101,11 +101,11 @@ def patch_all():
patch_for_msvc_specialized_compiler()
-def _patch_distribution_metadata_write_pkg_file():
- """Patch write_pkg_file to also write Requires-Python/Requires-External"""
- distutils.dist.DistributionMetadata.write_pkg_file = (
- setuptools.dist.write_pkg_file
- )
+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'):
+ new_val = getattr(setuptools.dist, attr)
+ setattr(distutils.dist.DistributionMetadata, attr, new_val)
def patch_func(replacement, target_mod, func_name):