__all__: list[str] = [] """
Everything is private. Contact the project team if you think you need this functionality. """
def _get_mro(cls): """
Returns the bases classes for cls sorted by the MRO.
Works around an issue on Jython where inspect.getmro will notreturn all
base classes if multiple classes share the same name. Instead, this
function will return a tuple containing the class itself, and the contents
of cls.__bases__. See https://github.com/pypa/setuptools/issues/1024. """ if platform.python_implementation() == "Jython": return (cls,) + cls.__bases__ return inspect.getmro(cls)
@overload def get_unpatched(item: _UnpatchT) -> _UnpatchT: ...
@overload def get_unpatched(item: object) -> None: ... def get_unpatched(
item: type | types.FunctionType | object,
) -> type | types.FunctionType | None: if isinstance(item, type): return get_unpatched_class(item) if isinstance(item, types.FunctionType): return get_unpatched_function(item) returnNone
def get_unpatched_class(cls: type[_T]) -> type[_T]: """Protect against re-patching the distutils if reloaded
Also ensures that no other distutils extension monkeypatched the distutils
first. """
external_bases = (
cast(Type[_T], cls) for cls in _get_mro(cls) ifnot cls.__module__.startswith('setuptools')
)
base = next(external_bases) ifnot base.__module__.startswith('distutils'):
msg = "distutils has already been patched by %r" % cls raise AssertionError(msg) return base
def patch_all(): import setuptools
# we can't patch distutils.cmd, alas
distutils.core.Command = setuptools.Command
_patch_distribution_metadata()
# Install Distribution throughout the distutils for module in distutils.dist, distutils.core, distutils.cmd:
module.Distribution = setuptools.dist.Distribution
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.