Path: blob/master/ invest-robot-contest_TinkoffBotTwitch-main/venv/lib/python3.8/site-packages/setuptools/extension.py
7762 views
import re1import functools2import distutils.core3import distutils.errors4import distutils.extension56from setuptools.extern.six.moves import map78from .monkey import get_unpatched91011def _have_cython():12"""13Return True if Cython can be imported.14"""15cython_impl = 'Cython.Distutils.build_ext'16try:17# from (cython_impl) import build_ext18__import__(cython_impl, fromlist=['build_ext']).build_ext19return True20except Exception:21pass22return False232425# for compatibility26have_pyrex = _have_cython2728_Extension = get_unpatched(distutils.core.Extension)293031class Extension(_Extension):32"""Extension that uses '.c' files in place of '.pyx' files"""3334def __init__(self, name, sources, *args, **kw):35# The *args is needed for compatibility as calls may use positional36# arguments. py_limited_api may be set only via keyword.37self.py_limited_api = kw.pop("py_limited_api", False)38_Extension.__init__(self, name, sources, *args, **kw)3940def _convert_pyx_sources_to_lang(self):41"""42Replace sources with .pyx extensions to sources with the target43language extension. This mechanism allows language authors to supply44pre-converted sources but to prefer the .pyx sources.45"""46if _have_cython():47# the build has Cython, so allow it to compile the .pyx files48return49lang = self.language or ''50target_ext = '.cpp' if lang.lower() == 'c++' else '.c'51sub = functools.partial(re.sub, '.pyx$', target_ext)52self.sources = list(map(sub, self.sources))535455class Library(Extension):56"""Just like a regular Extension, but built as a library instead"""575859