Path: blob/master/ invest-robot-contest_TinkoffBotTwitch-main/venv/lib/python3.8/site-packages/setuptools/distutils_patch.py
7738 views
"""1Ensure that the local copy of distutils is preferred over stdlib.23See https://github.com/pypa/setuptools/issues/417#issuecomment-3922984014for more motivation.5"""67import sys8import re9import os10import importlib11import warnings121314is_pypy = '__pypy__' in sys.builtin_module_names151617def warn_distutils_present():18if 'distutils' not in sys.modules:19return20if is_pypy and sys.version_info < (3, 7):21# PyPy for 3.6 unconditionally imports distutils, so bypass the warning22# https://foss.heptapod.net/pypy/pypy/-/blob/be829135bc0d758997b3566062999ee8b23872b4/lib-python/3/site.py#L25023return24warnings.warn(25"Distutils was imported before Setuptools. This usage is discouraged "26"and may exhibit undesirable behaviors or errors. Please use "27"Setuptools' objects directly or at least import Setuptools first.")282930def clear_distutils():31if 'distutils' not in sys.modules:32return33warnings.warn("Setuptools is replacing distutils.")34mods = [name for name in sys.modules if re.match(r'distutils\b', name)]35for name in mods:36del sys.modules[name]373839def enabled():40"""41Allow selection of distutils by environment variable.42"""43which = os.environ.get('SETUPTOOLS_USE_DISTUTILS', 'stdlib')44return which == 'local'454647def ensure_local_distutils():48clear_distutils()49distutils = importlib.import_module('setuptools._distutils')50distutils.__name__ = 'distutils'51sys.modules['distutils'] = distutils5253# sanity check that submodules load as expected54core = importlib.import_module('distutils.core')55assert '_distutils' in core.__file__, core.__file__565758warn_distutils_present()59if enabled():60ensure_local_distutils()616263