<s> import sys <EOL> import distutils . core <EOL> import distutils . extension <EOL> from setuptools . dist import _get_unpatched <EOL> _Extension = _get_unpatched ( distutils . core . Extension ) <EOL> def have_pyrex ( ) : <EOL> """<STR_LIT>""" <EOL> pyrex_impls = '<STR_LIT>' , '<STR_LIT>' <EOL> for pyrex_impl in pyrex_impls : <EOL> try : <EOL> __import__ ( pyrex_impl , fromlist = [ '<STR_LIT>' ] ) . build_ext <EOL> return True <EOL> except Exception : <EOL> pass <EOL> return False <EOL> class Extension ( _Extension ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , * args , ** kw ) : <EOL> _Extension . __init__ ( self , * args , ** kw ) <EOL> if not have_pyrex ( ) : <EOL> self . _convert_pyx_sources_to_c ( ) <EOL> def _convert_pyx_sources_to_c ( self ) : <EOL> "<STR_LIT>" <EOL> def pyx_to_c ( source ) : <EOL> if source . endswith ( '<STR_LIT>' ) : <EOL> source = source [ : - <NUM_LIT:4> ] + '<STR_LIT>' <EOL> return source <EOL> self . sources = map ( pyx_to_c , self . sources ) <EOL> class Library ( Extension ) : <EOL> """<STR_LIT>""" <EOL> distutils . core . Extension = Extension <EOL> distutils . extension . Extension = Extension <EOL> if '<STR_LIT>' in sys . modules : <EOL> sys . modules [ '<STR_LIT>' ] . Extension = Extension </s>
