diff options
-rw-r--r-- | setuptools/__init__.py | 6 | ||||
-rw-r--r-- | setuptools/dist.py | 19 | ||||
-rw-r--r-- | setuptools/extension.py | 2 | ||||
-rw-r--r-- | setuptools/monkey.py | 22 |
4 files changed, 28 insertions, 21 deletions
diff --git a/setuptools/__init__.py b/setuptools/__init__.py index 2ca97103..4038ee83 100644 --- a/setuptools/__init__.py +++ b/setuptools/__init__.py @@ -5,7 +5,6 @@ import sys import functools import distutils.core import distutils.filelist -from distutils.core import Command as _Command from distutils.util import convert_path from fnmatch import fnmatchcase @@ -13,7 +12,8 @@ from setuptools.extern.six.moves import filterfalse, map import setuptools.version from setuptools.extension import Extension -from setuptools.dist import Distribution, Feature, _get_unpatched +from setuptools.dist import Distribution, Feature +from setuptools.monkey import _get_unpatched from setuptools.depends import Require __all__ = [ @@ -122,7 +122,7 @@ find_packages = PackageFinder.find setup = distutils.core.setup -_Command = _get_unpatched(_Command) +_Command = _get_unpatched(distutils.core.Command) class Command(_Command): diff --git a/setuptools/dist.py b/setuptools/dist.py index 820df6d5..380b9436 100644 --- a/setuptools/dist.py +++ b/setuptools/dist.py @@ -9,7 +9,6 @@ import distutils.log import distutils.core import distutils.cmd import distutils.dist -from distutils.core import Distribution as _Distribution from distutils.errors import (DistutilsOptionError, DistutilsPlatformError, DistutilsSetupError) from distutils.util import rfc822_escape @@ -20,25 +19,11 @@ from pkg_resources.extern import packaging from setuptools.depends import Require from setuptools import windows_support +from setuptools.monkey import _get_unpatched import pkg_resources -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 - - -_Distribution = _get_unpatched(_Distribution) +_Distribution = _get_unpatched(distutils.core.Distribution) def _patch_distribution_metadata_write_pkg_file(): diff --git a/setuptools/extension.py b/setuptools/extension.py index f8058b72..7ef3fad2 100644 --- a/setuptools/extension.py +++ b/setuptools/extension.py @@ -7,7 +7,7 @@ import distutils.extension from setuptools.extern.six.moves import map -from .dist import _get_unpatched +from .monkey import _get_unpatched from . import msvc _Extension = _get_unpatched(distutils.core.Extension) 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 |