From d6efc9424328b42a3c7aeae758bab35bc7df5014 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 4 Sep 2016 19:09:42 -0400 Subject: Introduce a new monkey module to encapsulate the monkeypatching. --- setuptools/monkey.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 setuptools/monkey.py (limited to 'setuptools/monkey.py') 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 -- cgit v1.2.3