<s> """<STR_LIT>""" <EOL> __revision__ = "<STR_LIT>" <EOL> import sys <EOL> import os <EOL> from distutils . errors import DistutilsPlatformError <EOL> from distutils . dep_util import newer , newer_group <EOL> from distutils import log <EOL> from distutils . command import build_ext as _build_ext <EOL> from distutils import sysconfig <EOL> try : <EOL> from __builtin__ import basestring <EOL> except ImportError : <EOL> basestring = str <EOL> extension_name_re = _build_ext . extension_name_re <EOL> show_compilers = _build_ext . show_compilers <EOL> class Optimization ( object ) : <EOL> def __init__ ( self ) : <EOL> self . flags = ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ) <EOL> self . state = sysconfig . get_config_vars ( * self . flags ) <EOL> self . config_vars = sysconfig . get_config_vars ( ) <EOL> def disable_optimization ( self ) : <EOL> "<STR_LIT>" <EOL> badoptions = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> for flag , option in zip ( self . flags , self . state ) : <EOL> if option is not None : <EOL> L = [ opt for opt in option . split ( ) if opt not in badoptions ] <EOL> self . config_vars [ flag ] = '<STR_LIT:U+0020>' . join ( L ) <EOL> def restore_state ( self ) : <EOL> "<STR_LIT>" <EOL> for flag , option in zip ( self . flags , self . state ) : <EOL> if option is not None : <EOL> self . config_vars [ flag ] = option <EOL> optimization = Optimization ( ) <EOL> class build_ext ( _build_ext . build_ext ) : <EOL> description = "<STR_LIT>" <EOL> sep_by = _build_ext . build_ext . sep_by <EOL> user_options = _build_ext . build_ext . user_options <EOL> boolean_options = _build_ext . build_ext . boolean_options <EOL> help_options = _build_ext . build_ext . help_options <EOL> user_options . extend ( [ <EOL> ( '<STR_LIT>' , None , <EOL> "<STR_LIT>" ) , <EOL> ( '<STR_LIT>' , None , <EOL> "<STR_LIT>" ) , <EOL> ( '<STR_LIT>' , None , <EOL> "<STR_LIT>" ) , <EOL> ( '<STR_LIT>' , None , <EOL> "<STR_LIT>" + sep_by ) , <EOL> ( '<STR_LIT>' , None , <EOL> "<STR_LIT>" ) , <EOL> ( '<STR_LIT>' , None , <EOL> "<STR_LIT>" ) , <EOL> ( '<STR_LIT>' , None , <EOL> "<STR_LIT>" ) , <EOL> ( '<STR_LIT>' , None , <EOL> "<STR_LIT>" ) , <EOL> ( '<STR_LIT>' , None , <EOL> "<STR_LIT>" ) , <EOL> ( '<STR_LIT>' , None , <EOL> "<STR_LIT>" ) , <EOL> ( '<STR_LIT>' , None , <EOL> "<STR_LIT>" ) , <EOL> ( '<STR_LIT>' , None , <EOL> "<STR_LIT>" ) , <EOL> ( '<STR_LIT>' , None , <EOL> "<STR_LIT>" + sep_by ) , <EOL> ( '<STR_LIT>' , None , <EOL> "<STR_LIT>" ) , <EOL> ( '<STR_LIT>' , None , <EOL> "<STR_LIT>" ) , <EOL> ( '<STR_LIT>' , None , <EOL> "<STR_LIT>" ) , <EOL> ( '<STR_LIT>' , None , <EOL> "<STR_LIT>" ) , <EOL> ] ) <EOL> boolean_options . extend ( [ <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> ] ) <EOL> def initialize_options ( self ) : <EOL> _build_ext . build_ext . initialize_options ( self ) <EOL> self . cython_cplus = <NUM_LIT:0> <EOL> self . cython_create_listing = <NUM_LIT:0> <EOL> self . cython_line_directives = <NUM_LIT:0> <EOL> self . cython_include_dirs = None <EOL> self . cython_directives = None <EOL> self . cython_c_in_temp = <NUM_LIT:0> <EOL> self . cython_gen_pxi = <NUM_LIT:0> <EOL> self . cython_gdb = False <EOL> self . no_c_in_traceback = <NUM_LIT:0> <EOL> self . cython_compile_time_env = None <EOL> def __getattr__ ( self , name ) : <EOL> if name [ : <NUM_LIT:6> ] == '<STR_LIT>' : <EOL> return getattr ( self , '<STR_LIT>' + name [ <NUM_LIT:6> : ] ) <EOL> else : <EOL> return _build_ext . build_ext . __getattr__ ( self , name ) <EOL> def __setattr__ ( self , name , value ) : <EOL> if name [ : <NUM_LIT:6> ] == '<STR_LIT>' : <EOL> return setattr ( self , '<STR_LIT>' + name [ <NUM_LIT:6> : ] , value ) <EOL> else : <EOL> self . __dict__ [ name ] = value <EOL> def finalize_options ( self ) : <EOL> _build_ext . build_ext . finalize_options ( self ) <EOL> if self . cython_include_dirs is None : <EOL> self . cython_include_dirs = [ ] <EOL> elif isinstance ( self . cython_include_dirs , basestring ) : <EOL> self . cython_include_dirs = self . cython_include_dirs . split ( os . pathsep ) <EOL> if self . cython_directives is None : <EOL> self . cython_directives = { } <EOL> def run ( self ) : <EOL> if self . cython_gdb or [ <NUM_LIT:1> for ext in self . extensions <EOL> if getattr ( ext , '<STR_LIT>' , False ) ] : <EOL> optimization . disable_optimization ( ) <EOL> _build_ext . build_ext . run ( self ) <EOL> def build_extensions ( self ) : <EOL> self . check_extensions_list ( self . extensions ) <EOL> for ext in self . extensions : <EOL> ext . sources = self . cython_sources ( ext . sources , ext ) <EOL> self . build_extension ( ext ) <EOL> def cython_sources ( self , sources , extension ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> from Cython . Compiler . Main import CompilationOptions , default_options as cython_default_options , compile as cython_compile <EOL> from Cython . Compiler . Errors import PyrexError <EOL> except ImportError : <EOL> e = sys . exc_info ( ) [ <NUM_LIT:1> ] <EOL> print ( "<STR_LIT>" % e ) <EOL> raise DistutilsPlatformError ( "<STR_LIT>" ) <EOL> new_sources = [ ] <EOL> cython_sources = [ ] <EOL> cython_targets = { } <EOL> create_listing = self . cython_create_listing or getattr ( extension , '<STR_LIT>' , <NUM_LIT:0> ) <EOL> line_directives = self . cython_line_directives or getattr ( extension , '<STR_LIT>' , <NUM_LIT:0> ) <EOL> no_c_in_traceback = self . no_c_in_traceback or getattr ( extension , '<STR_LIT>' , <NUM_LIT:0> ) <EOL> cplus = self . cython_cplus or getattr ( extension , '<STR_LIT>' , <NUM_LIT:0> ) or ( extension . language and extension . language . lower ( ) == '<STR_LIT>' ) <EOL> cython_gen_pxi = self . cython_gen_pxi or getattr ( extension , '<STR_LIT>' , <NUM_LIT:0> ) <EOL> cython_gdb = self . cython_gdb or getattr ( extension , '<STR_LIT>' , False ) <EOL> cython_compile_time_env = self . cython_compile_time_env or getattr ( extension , '<STR_LIT>' , None ) <EOL> includes = self . cython_include_dirs <EOL> try : <EOL> for i in extension . cython_include_dirs : <EOL> if not i in includes : <EOL> includes . append ( i ) <EOL> except AttributeError : <EOL> pass <EOL> extension . include_dirs = list ( extension . include_dirs ) <EOL> for i in extension . include_dirs : <EOL> if not i in includes : <EOL> includes . append ( i ) <EOL> directives = self . cython_directives <EOL> if hasattr ( extension , "<STR_LIT>" ) : <EOL> directives . update ( extension . cython_directives ) <EOL> if cplus : <EOL> target_ext = '<STR_LIT>' <EOL> else : <EOL> target_ext = '<STR_LIT>' <EOL> if not self . inplace and ( self . cython_c_in_temp <EOL> or getattr ( extension , '<STR_LIT>' , <NUM_LIT:0> ) ) : <EOL> target_dir = os . path . join ( self . build_temp , "<STR_LIT>" ) <EOL> for package_name in extension . name . split ( '<STR_LIT:.>' ) [ : - <NUM_LIT:1> ] : <EOL> target_dir = os . path . join ( target_dir , package_name ) <EOL> else : <EOL> target_dir = None <EOL> newest_dependency = None <EOL> for source in sources : <EOL> ( base , ext ) = os . path . splitext ( os . path . basename ( source ) ) <EOL> if ext == "<STR_LIT>" : <EOL> ext = '<STR_LIT>' <EOL> if ext == "<STR_LIT>" : <EOL> output_dir = target_dir or os . path . dirname ( source ) <EOL> new_sources . append ( os . path . join ( output_dir , base + target_ext ) ) <EOL> cython_sources . append ( source ) <EOL> cython_targets [ source ] = new_sources [ - <NUM_LIT:1> ] <EOL> elif ext == '<STR_LIT>' or ext == '<STR_LIT>' : <EOL> if newest_dependency is None or newer ( source , newest_dependency ) : <EOL> newest_dependency = source <EOL> else : <EOL> new_sources . append ( source ) <EOL> if not cython_sources : <EOL> return new_sources <EOL> module_name = extension . name <EOL> for source in cython_sources : <EOL> target = cython_targets [ source ] <EOL> depends = [ source ] + list ( extension . depends or ( ) ) <EOL> if ( source [ - <NUM_LIT:4> : ] . lower ( ) == "<STR_LIT>" and os . path . isfile ( source [ : - <NUM_LIT:3> ] + "<STR_LIT>" ) ) : <EOL> depends += [ source [ : - <NUM_LIT:3> ] + "<STR_LIT>" ] <EOL> rebuild = self . force or newer_group ( depends , target , '<STR_LIT>' ) <EOL> if not rebuild and newest_dependency is not None : <EOL> rebuild = newer ( newest_dependency , target ) <EOL> if rebuild : <EOL> log . info ( "<STR_LIT>" , source , target ) <EOL> self . mkpath ( os . path . dirname ( target ) ) <EOL> if self . inplace : <EOL> output_dir = os . curdir <EOL> else : <EOL> output_dir = self . build_lib <EOL> options = CompilationOptions ( cython_default_options , <EOL> use_listing_file = create_listing , <EOL> include_path = includes , <EOL> compiler_directives = directives , <EOL> output_file = target , <EOL> cplus = cplus , <EOL> emit_linenums = line_directives , <EOL> c_line_in_traceback = not no_c_in_traceback , <EOL> generate_pxi = cython_gen_pxi , <EOL> output_dir = output_dir , <EOL> gdb_debug = cython_gdb , <EOL> compile_time_env = cython_compile_time_env ) <EOL> result = cython_compile ( source , options = options , <EOL> full_module_name = module_name ) <EOL> else : <EOL> log . info ( "<STR_LIT>" , target ) <EOL> return new_sources </s>
