aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/monkey.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2016-09-04 19:50:27 -0400
committerJason R. Coombs <jaraco@jaraco.com>2016-09-04 19:50:27 -0400
commitcd22ba427f9b201d6bc48586ddf4595312b9e19e (patch)
treef87e4a770496efaffe02510ac6daf14a629936ab /setuptools/monkey.py
parent443cabec148460b3a688923df1a63f689d1164c7 (diff)
downloadexternal_python_setuptools-cd22ba427f9b201d6bc48586ddf4595312b9e19e.tar.gz
external_python_setuptools-cd22ba427f9b201d6bc48586ddf4595312b9e19e.tar.bz2
external_python_setuptools-cd22ba427f9b201d6bc48586ddf4595312b9e19e.zip
Move (much of?) the rest of the monkey patching into the monkey module
Diffstat (limited to 'setuptools/monkey.py')
-rw-r--r--setuptools/monkey.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/setuptools/monkey.py b/setuptools/monkey.py
index 1961dfba..a2cac0e0 100644
--- a/setuptools/monkey.py
+++ b/setuptools/monkey.py
@@ -58,3 +58,44 @@ def patch_all():
if needs_warehouse:
warehouse = 'https://upload.pypi.org/legacy/'
distutils.config.PyPIRCCommand.DEFAULT_REPOSITORY = warehouse
+
+ _patch_distribution_metadata_write_pkg_file()
+ _patch_distribution_metadata_write_pkg_info()
+
+ # Install Distribution throughout the distutils
+ for module in distutils.dist, distutils.core, distutils.cmd:
+ module.Distribution = setuptools.dist.Distribution
+
+ # Install the patched Extension
+ distutils.core.Extension = setuptools.extension.Extension
+ distutils.extension.Extension = setuptools.extension.Extension
+ if 'distutils.command.build_ext' in sys.modules:
+ sys.modules['distutils.command.build_ext'].Extension = (
+ setuptools.extension.Extension
+ )
+
+ # patch MSVC
+ __import__('setuptools.msvc')
+ setuptools.msvc.patch_for_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_write_pkg_info():
+ """
+ Workaround issue #197 - Python 3 prior to 3.2.2 uses an environment-local
+ encoding to save the pkg_info. Monkey-patch its write_pkg_info method to
+ correct this undesirable behavior.
+ """
+ environment_local = (3,) <= sys.version_info[:3] < (3, 2, 2)
+ if not environment_local:
+ return
+
+ distutils.dist.DistributionMetadata.write_pkg_info = (
+ setuptools.dist.write_pkg_info
+ )