aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/monkey.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2016-09-04 19:09:42 -0400
committerJason R. Coombs <jaraco@jaraco.com>2016-09-04 19:09:42 -0400
commitd6efc9424328b42a3c7aeae758bab35bc7df5014 (patch)
treeef9071de6b6694904b7e3247bb03ac123cd5a0e5 /setuptools/monkey.py
parent64b10c60755b6c7d70d178aeb7ff79ae9daf56bd (diff)
downloadexternal_python_setuptools-d6efc9424328b42a3c7aeae758bab35bc7df5014.tar.gz
external_python_setuptools-d6efc9424328b42a3c7aeae758bab35bc7df5014.tar.bz2
external_python_setuptools-d6efc9424328b42a3c7aeae758bab35bc7df5014.zip
Introduce a new monkey module to encapsulate the monkeypatching.
Diffstat (limited to 'setuptools/monkey.py')
-rw-r--r--setuptools/monkey.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/setuptools/monkey.py b/setuptools/monkey.py
new file mode 100644
index 00000000..b6baf49d
--- /dev/null
+++ b/setuptools/monkey.py
@@ -0,0 +1,22 @@
+"""
+Monkey patching of distutils.
+"""
+
+
+__all__ = []
+"everything is private"
+
+
+def _get_unpatched(cls):
+ """Protect against re-patching the distutils if reloaded
+
+ Also ensures that no other distutils extension monkeypatched the distutils
+ first.
+ """
+ while cls.__module__.startswith('setuptools'):
+ cls, = cls.__bases__
+ if not cls.__module__.startswith('distutils'):
+ raise AssertionError(
+ "distutils has already been patched by %r" % cls
+ )
+ return cls