<s> "<STR_LIT>" <EOL> import os , sys <EOL> import TaskGen , Utils , Utils , Runner , Options , Build <EOL> from Logs import debug , warn , info <EOL> from TaskGen import extension , taskgen , before , after , feature <EOL> from Configure import conf <EOL> EXT_PY = [ '<STR_LIT>' ] <EOL> FRAG_2 = '''<STR_LIT>''' <EOL> @ before ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> @ feature ( '<STR_LIT>' ) <EOL> @ before ( '<STR_LIT>' ) <EOL> def init_pyext ( self ) : <EOL> self . default_install_path = '<STR_LIT>' <EOL> self . uselib = self . to_list ( getattr ( self , '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> if not '<STR_LIT>' in self . uselib : <EOL> self . uselib . append ( '<STR_LIT>' ) <EOL> self . env [ '<STR_LIT>' ] = True <EOL> @ before ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> @ after ( '<STR_LIT>' ) <EOL> @ feature ( '<STR_LIT>' ) <EOL> def pyext_shlib_ext ( self ) : <EOL> self . env [ '<STR_LIT>' ] = self . env [ '<STR_LIT>' ] <EOL> @ before ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> @ feature ( '<STR_LIT>' ) <EOL> def init_pyembed ( self ) : <EOL> self . uselib = self . to_list ( getattr ( self , '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> if not '<STR_LIT>' in self . uselib : <EOL> self . uselib . append ( '<STR_LIT>' ) <EOL> @ extension ( EXT_PY ) <EOL> def process_py ( self , node ) : <EOL> if not ( self . bld . is_install and self . install_path ) : <EOL> return <EOL> def inst_py ( ctx ) : <EOL> install_pyfile ( self , node ) <EOL> self . bld . add_post_fun ( inst_py ) <EOL> def install_pyfile ( self , node ) : <EOL> path = self . bld . get_install_path ( self . install_path + os . sep + node . name , self . env ) <EOL> self . bld . install_files ( self . install_path , [ node ] , self . env , self . chmod , postpone = False ) <EOL> if self . bld . is_install < <NUM_LIT:0> : <EOL> info ( "<STR_LIT>" ) <EOL> for x in '<STR_LIT>' : <EOL> try : <EOL> os . remove ( path + x ) <EOL> except OSError : <EOL> pass <EOL> if self . bld . is_install > <NUM_LIT:0> : <EOL> if self . env [ '<STR_LIT>' ] or self . env [ '<STR_LIT>' ] : <EOL> info ( "<STR_LIT>" % path ) <EOL> if self . env [ '<STR_LIT>' ] : <EOL> program = ( """<STR_LIT>""" ) <EOL> argv = [ self . env [ '<STR_LIT>' ] , '<STR_LIT:-c>' , program , path ] <EOL> ret = Utils . pproc . Popen ( argv ) . wait ( ) <EOL> if ret : <EOL> raise Utils . WafError ( '<STR_LIT>' % path ) <EOL> if self . env [ '<STR_LIT>' ] : <EOL> program = ( """<STR_LIT>""" ) <EOL> argv = [ self . env [ '<STR_LIT>' ] , self . env [ '<STR_LIT>' ] , '<STR_LIT:-c>' , program , path ] <EOL> ret = Utils . pproc . Popen ( argv ) . wait ( ) <EOL> if ret : <EOL> raise Utils . WafError ( '<STR_LIT>' % path ) <EOL> class py_taskgen ( TaskGen . task_gen ) : <EOL> def __init__ ( self , * k , ** kw ) : <EOL> TaskGen . task_gen . __init__ ( self , * k , ** kw ) <EOL> @ before ( '<STR_LIT>' ) <EOL> @ after ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> @ feature ( '<STR_LIT>' ) <EOL> def init_py ( self ) : <EOL> self . default_install_path = '<STR_LIT>' <EOL> def _get_python_variables ( python_exe , variables , imports = [ '<STR_LIT>' ] ) : <EOL> """<STR_LIT>""" <EOL> program = list ( imports ) <EOL> program . append ( '<STR_LIT>' ) <EOL> for v in variables : <EOL> program . append ( "<STR_LIT>" % v ) <EOL> os_env = dict ( os . environ ) <EOL> try : <EOL> del os_env [ '<STR_LIT>' ] <EOL> except KeyError : <EOL> pass <EOL> proc = Utils . pproc . Popen ( [ python_exe , "<STR_LIT:-c>" , '<STR_LIT:\n>' . join ( program ) ] , stdout = Utils . pproc . PIPE , env = os_env ) <EOL> output = proc . communicate ( ) [ <NUM_LIT:0> ] . split ( "<STR_LIT:\n>" ) <EOL> if proc . returncode : <EOL> if Options . options . verbose : <EOL> warn ( "<STR_LIT>" <EOL> % '<STR_LIT:\n>' . join ( [ "<STR_LIT>" % ( lineno + <NUM_LIT:1> , line ) for lineno , line in enumerate ( program ) ] ) ) <EOL> raise RuntimeError <EOL> return_values = [ ] <EOL> for s in output : <EOL> s = s . strip ( ) <EOL> if not s : <EOL> continue <EOL> if s == '<STR_LIT:None>' : <EOL> return_values . append ( None ) <EOL> elif s [ <NUM_LIT:0> ] == "<STR_LIT:'>" and s [ - <NUM_LIT:1> ] == "<STR_LIT:'>" : <EOL> return_values . append ( s [ <NUM_LIT:1> : - <NUM_LIT:1> ] ) <EOL> elif s [ <NUM_LIT:0> ] . isdigit ( ) : <EOL> return_values . append ( int ( s ) ) <EOL> else : break <EOL> return return_values <EOL> @ conf <EOL> def check_python_headers ( conf ) : <EOL> """<STR_LIT>""" <EOL> if not conf . env [ '<STR_LIT>' ] and not conf . env [ '<STR_LIT>' ] : <EOL> conf . fatal ( '<STR_LIT>' ) <EOL> if not conf . env [ '<STR_LIT>' ] : <EOL> conf . check_python_version ( ) <EOL> env = conf . env <EOL> python = env [ '<STR_LIT>' ] <EOL> if not python : <EOL> conf . fatal ( '<STR_LIT>' ) <EOL> if Options . platform == '<STR_LIT>' : <EOL> conf . check_tool ( '<STR_LIT>' ) <EOL> try : <EOL> v = '<STR_LIT>' . split ( ) <EOL> ( python_prefix , python_SO , python_SYSLIBS , python_LDFLAGS , python_SHLIBS , <EOL> python_LIBDIR , python_LIBPL , INCLUDEPY , Py_ENABLE_SHARED , <EOL> python_MACOSX_DEPLOYMENT_TARGET ) = _get_python_variables ( python , [ "<STR_LIT>" % x for x in v ] , <EOL> [ '<STR_LIT>' ] ) <EOL> except RuntimeError : <EOL> conf . fatal ( "<STR_LIT>" ) <EOL> conf . log . write ( """<STR_LIT>""" % ( python , python_prefix , python_SO , python_SYSLIBS , python_LDFLAGS , python_SHLIBS , <EOL> python_LIBDIR , python_LIBPL , INCLUDEPY , Py_ENABLE_SHARED , python_MACOSX_DEPLOYMENT_TARGET ) ) <EOL> if python_MACOSX_DEPLOYMENT_TARGET : <EOL> conf . env [ '<STR_LIT>' ] = python_MACOSX_DEPLOYMENT_TARGET <EOL> conf . environ [ '<STR_LIT>' ] = python_MACOSX_DEPLOYMENT_TARGET <EOL> env [ '<STR_LIT>' ] = '<STR_LIT:%s>' + python_SO <EOL> if python_SYSLIBS is not None : <EOL> for lib in python_SYSLIBS . split ( ) : <EOL> if lib . startswith ( '<STR_LIT>' ) : <EOL> lib = lib [ <NUM_LIT:2> : ] <EOL> env . append_value ( '<STR_LIT>' , lib ) <EOL> if python_SHLIBS is not None : <EOL> for lib in python_SHLIBS . split ( ) : <EOL> if lib . startswith ( '<STR_LIT>' ) : <EOL> env . append_value ( '<STR_LIT>' , lib [ <NUM_LIT:2> : ] ) <EOL> else : <EOL> env . append_value ( '<STR_LIT>' , lib ) <EOL> if Options . platform != '<STR_LIT>' and python_LDFLAGS : <EOL> env . append_value ( '<STR_LIT>' , python_LDFLAGS . split ( ) ) <EOL> result = False <EOL> name = '<STR_LIT>' + env [ '<STR_LIT>' ] <EOL> if python_LIBDIR is not None : <EOL> path = [ python_LIBDIR ] <EOL> conf . log . write ( "<STR_LIT>" % path ) <EOL> result = conf . check ( lib = name , uselib = '<STR_LIT>' , libpath = path ) <EOL> if not result and python_LIBPL is not None : <EOL> conf . log . write ( "<STR_LIT>" ) <EOL> path = [ python_LIBPL ] <EOL> result = conf . check ( lib = name , uselib = '<STR_LIT>' , libpath = path ) <EOL> if not result : <EOL> conf . log . write ( "<STR_LIT>" ) <EOL> path = [ os . path . join ( python_prefix , "<STR_LIT>" ) ] <EOL> name = '<STR_LIT>' + env [ '<STR_LIT>' ] . replace ( '<STR_LIT:.>' , '<STR_LIT>' ) <EOL> result = conf . check ( lib = name , uselib = '<STR_LIT>' , libpath = path ) <EOL> if result : <EOL> env [ '<STR_LIT>' ] = path <EOL> env . append_value ( '<STR_LIT>' , name ) <EOL> else : <EOL> conf . log . write ( "<STR_LIT>" ) <EOL> if ( sys . platform == '<STR_LIT:win32>' or sys . platform . startswith ( '<STR_LIT>' ) <EOL> or sys . platform == '<STR_LIT>' or Py_ENABLE_SHARED ) : <EOL> env [ '<STR_LIT>' ] = env [ '<STR_LIT>' ] <EOL> env [ '<STR_LIT>' ] = env [ '<STR_LIT>' ] <EOL> python_config = conf . find_program ( <EOL> '<STR_LIT>' % ( '<STR_LIT:.>' . join ( env [ '<STR_LIT>' ] . split ( '<STR_LIT:.>' ) [ : <NUM_LIT:2> ] ) ) , <EOL> var = '<STR_LIT>' ) <EOL> if not python_config : <EOL> python_config = conf . find_program ( <EOL> '<STR_LIT>' % ( '<STR_LIT:.>' . join ( env [ '<STR_LIT>' ] . split ( '<STR_LIT:.>' ) [ : <NUM_LIT:2> ] ) ) , <EOL> var = '<STR_LIT>' ) <EOL> includes = [ ] <EOL> if python_config : <EOL> for incstr in Utils . cmd_output ( "<STR_LIT>" % ( python , python_config ) ) . strip ( ) . split ( ) : <EOL> if ( incstr . startswith ( '<STR_LIT>' ) <EOL> or incstr . startswith ( '<STR_LIT>' ) ) : <EOL> incstr = incstr [ <NUM_LIT:2> : ] <EOL> if incstr not in includes : <EOL> includes . append ( incstr ) <EOL> conf . log . write ( "<STR_LIT>" <EOL> "<STR_LIT>" % ( includes , ) ) <EOL> env [ '<STR_LIT>' ] = includes <EOL> env [ '<STR_LIT>' ] = includes <EOL> else : <EOL> conf . log . write ( "<STR_LIT>" <EOL> "<STR_LIT>" % ( INCLUDEPY , ) ) <EOL> env [ '<STR_LIT>' ] = [ INCLUDEPY ] <EOL> env [ '<STR_LIT>' ] = [ INCLUDEPY ] <EOL> if env [ '<STR_LIT>' ] == '<STR_LIT>' : <EOL> env . append_value ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> env . append_value ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> if env [ '<STR_LIT>' ] == '<STR_LIT>' : <EOL> env . append_value ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> env . append_value ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> conf . check ( header_name = '<STR_LIT>' , define_name = '<STR_LIT>' , <EOL> uselib = '<STR_LIT>' , fragment = FRAG_2 , <EOL> errmsg = '<STR_LIT>' , mandatory = <NUM_LIT:1> ) <EOL> @ conf <EOL> def check_python_version ( conf , minver = None ) : <EOL> """<STR_LIT>""" <EOL> assert minver is None or isinstance ( minver , tuple ) <EOL> python = conf . env [ '<STR_LIT>' ] <EOL> if not python : <EOL> conf . fatal ( '<STR_LIT>' ) <EOL> cmd = [ python , "<STR_LIT:-c>" , "<STR_LIT>" ] <EOL> debug ( '<STR_LIT>' % cmd ) <EOL> proc = Utils . pproc . Popen ( cmd , stdout = Utils . pproc . PIPE ) <EOL> lines = proc . communicate ( ) [ <NUM_LIT:0> ] . split ( ) <EOL> assert len ( lines ) == <NUM_LIT:5> , "<STR_LIT>" % ( len ( lines ) , lines ) <EOL> pyver_tuple = ( int ( lines [ <NUM_LIT:0> ] ) , int ( lines [ <NUM_LIT:1> ] ) , int ( lines [ <NUM_LIT:2> ] ) , lines [ <NUM_LIT:3> ] , int ( lines [ <NUM_LIT:4> ] ) ) <EOL> result = ( minver is None ) or ( pyver_tuple >= minver ) <EOL> if result : <EOL> pyver = '<STR_LIT:.>' . join ( [ str ( x ) for x in pyver_tuple [ : <NUM_LIT:2> ] ] ) <EOL> conf . env [ '<STR_LIT>' ] = pyver <EOL> if '<STR_LIT>' in conf . environ : <EOL> pydir = conf . environ [ '<STR_LIT>' ] <EOL> else : <EOL> if sys . platform == '<STR_LIT:win32>' : <EOL> ( python_LIBDEST , pydir ) = _get_python_variables ( python , <EOL> [ "<STR_LIT>" , <EOL> "<STR_LIT>" % conf . env [ '<STR_LIT>' ] ] , <EOL> [ '<STR_LIT>' ] ) <EOL> else : <EOL> python_LIBDEST = None <EOL> ( pydir , ) = _get_python_variables ( python , <EOL> [ "<STR_LIT>" % conf . env [ '<STR_LIT>' ] ] , <EOL> [ '<STR_LIT>' ] ) <EOL> if python_LIBDEST is None : <EOL> if conf . env [ '<STR_LIT>' ] : <EOL> python_LIBDEST = os . path . join ( conf . env [ '<STR_LIT>' ] , "<STR_LIT>" + pyver ) <EOL> else : <EOL> python_LIBDEST = os . path . join ( conf . env [ '<STR_LIT>' ] , "<STR_LIT>" , "<STR_LIT>" + pyver ) <EOL> if hasattr ( conf , '<STR_LIT>' ) : <EOL> conf . define ( '<STR_LIT>' , pydir ) <EOL> conf . env [ '<STR_LIT>' ] = pydir <EOL> pyver_full = '<STR_LIT:.>' . join ( map ( str , pyver_tuple [ : <NUM_LIT:3> ] ) ) <EOL> if minver is None : <EOL> conf . check_message_custom ( '<STR_LIT>' , '<STR_LIT>' , pyver_full ) <EOL> else : <EOL> minver_str = '<STR_LIT:.>' . join ( map ( str , minver ) ) <EOL> conf . check_message ( '<STR_LIT>' , "<STR_LIT>" % minver_str , result , option = pyver_full ) <EOL> if not result : <EOL> conf . fatal ( '<STR_LIT>' % pyver_full ) <EOL> @ conf <EOL> def check_python_module ( conf , module_name ) : <EOL> """<STR_LIT>""" <EOL> result = not Utils . pproc . Popen ( [ conf . env [ '<STR_LIT>' ] , "<STR_LIT:-c>" , "<STR_LIT>" % module_name ] , <EOL> stderr = Utils . pproc . PIPE , stdout = Utils . pproc . PIPE ) . wait ( ) <EOL> conf . check_message ( '<STR_LIT>' , module_name , result ) <EOL> if not result : <EOL> conf . fatal ( '<STR_LIT>' % module_name ) <EOL> def detect ( conf ) : <EOL> if not conf . env . PYTHON : <EOL> conf . env . PYTHON = sys . executable <EOL> python = conf . find_program ( '<STR_LIT>' , var = '<STR_LIT>' ) <EOL> if not python : <EOL> conf . fatal ( '<STR_LIT>' ) <EOL> v = conf . env <EOL> v [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> v [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> v [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> v [ '<STR_LIT>' ] = getattr ( Options . options , '<STR_LIT>' , <NUM_LIT:1> ) <EOL> v [ '<STR_LIT>' ] = getattr ( Options . options , '<STR_LIT>' , <NUM_LIT:1> ) <EOL> def set_options ( opt ) : <EOL> opt . add_option ( '<STR_LIT>' , <EOL> action = '<STR_LIT>' , <EOL> default = <NUM_LIT:1> , <EOL> help = '<STR_LIT>' , <EOL> dest = '<STR_LIT>' ) <EOL> opt . add_option ( '<STR_LIT>' , <EOL> action = '<STR_LIT>' , <EOL> default = <NUM_LIT:1> , <EOL> help = '<STR_LIT>' , <EOL> dest = '<STR_LIT>' ) </s>
