<s> """<STR_LIT>""" <EOL> __revision__ = "<STR_LIT>" <EOL> import os <EOL> import re <EOL> import string <EOL> import sys <EOL> from distutils . errors import DistutilsPlatformError <EOL> PREFIX = os . path . normpath ( sys . prefix ) <EOL> EXEC_PREFIX = os . path . normpath ( sys . exec_prefix ) <EOL> argv0_path = os . path . dirname ( os . path . abspath ( sys . executable ) ) <EOL> landmark = os . path . join ( argv0_path , "<STR_LIT>" , "<STR_LIT>" ) <EOL> python_build = os . path . isfile ( landmark ) <EOL> del landmark <EOL> def get_python_version ( ) : <EOL> """<STR_LIT>""" <EOL> return sys . version [ : <NUM_LIT:3> ] <EOL> def get_python_inc ( plat_specific = <NUM_LIT:0> , prefix = None ) : <EOL> """<STR_LIT>""" <EOL> if prefix is None : <EOL> prefix = plat_specific and EXEC_PREFIX or PREFIX <EOL> if os . name == "<STR_LIT>" : <EOL> if python_build : <EOL> base = os . path . dirname ( os . path . abspath ( sys . executable ) ) <EOL> if plat_specific : <EOL> inc_dir = base <EOL> else : <EOL> inc_dir = os . path . join ( base , "<STR_LIT>" ) <EOL> if not os . path . exists ( inc_dir ) : <EOL> inc_dir = os . path . join ( os . path . dirname ( base ) , "<STR_LIT>" ) <EOL> return inc_dir <EOL> return os . path . join ( prefix , "<STR_LIT>" , "<STR_LIT>" + get_python_version ( ) ) <EOL> elif os . name == "<STR_LIT>" : <EOL> return os . path . join ( prefix , "<STR_LIT>" ) <EOL> elif os . name == "<STR_LIT>" : <EOL> if plat_specific : <EOL> return os . path . join ( prefix , "<STR_LIT>" , "<STR_LIT>" ) <EOL> else : <EOL> return os . path . join ( prefix , "<STR_LIT>" ) <EOL> elif os . name == "<STR_LIT>" : <EOL> return os . path . join ( prefix , "<STR_LIT>" ) <EOL> else : <EOL> raise DistutilsPlatformError ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % os . name ) <EOL> def get_python_lib ( plat_specific = <NUM_LIT:0> , standard_lib = <NUM_LIT:0> , prefix = None ) : <EOL> """<STR_LIT>""" <EOL> if prefix is None : <EOL> prefix = plat_specific and EXEC_PREFIX or PREFIX <EOL> if os . name == "<STR_LIT>" : <EOL> libpython = os . path . join ( prefix , <EOL> "<STR_LIT>" , "<STR_LIT>" + get_python_version ( ) ) <EOL> if standard_lib : <EOL> return libpython <EOL> else : <EOL> return os . path . join ( libpython , "<STR_LIT>" ) <EOL> elif os . name == "<STR_LIT>" : <EOL> if standard_lib : <EOL> return os . path . join ( prefix , "<STR_LIT>" ) <EOL> else : <EOL> if get_python_version ( ) < "<STR_LIT>" : <EOL> return prefix <EOL> else : <EOL> return os . path . join ( PREFIX , "<STR_LIT>" , "<STR_LIT>" ) <EOL> elif os . name == "<STR_LIT>" : <EOL> if plat_specific : <EOL> if standard_lib : <EOL> return os . path . join ( prefix , "<STR_LIT>" , "<STR_LIT>" ) <EOL> else : <EOL> return os . path . join ( prefix , "<STR_LIT>" , "<STR_LIT>" ) <EOL> else : <EOL> if standard_lib : <EOL> return os . path . join ( prefix , "<STR_LIT>" ) <EOL> else : <EOL> return os . path . join ( prefix , "<STR_LIT>" , "<STR_LIT>" ) <EOL> elif os . name == "<STR_LIT>" : <EOL> if standard_lib : <EOL> return os . path . join ( PREFIX , "<STR_LIT>" ) <EOL> else : <EOL> return os . path . join ( PREFIX , "<STR_LIT>" , "<STR_LIT>" ) <EOL> else : <EOL> raise DistutilsPlatformError ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % os . name ) <EOL> def customize_compiler ( compiler ) : <EOL> """<STR_LIT>""" <EOL> if compiler . compiler_type == "<STR_LIT>" : <EOL> ( cc , cxx , opt , cflags , ccshared , ldshared , so_ext ) = get_config_vars ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> if os . environ . has_key ( '<STR_LIT>' ) : <EOL> cc = os . environ [ '<STR_LIT>' ] <EOL> if os . environ . has_key ( '<STR_LIT>' ) : <EOL> cxx = os . environ [ '<STR_LIT>' ] <EOL> if os . environ . has_key ( '<STR_LIT>' ) : <EOL> ldshared = os . environ [ '<STR_LIT>' ] <EOL> if os . environ . has_key ( '<STR_LIT>' ) : <EOL> cpp = os . environ [ '<STR_LIT>' ] <EOL> else : <EOL> cpp = cc + "<STR_LIT>" <EOL> if os . environ . has_key ( '<STR_LIT>' ) : <EOL> ldshared = ldshared + '<STR_LIT:U+0020>' + os . environ [ '<STR_LIT>' ] <EOL> if os . environ . has_key ( '<STR_LIT>' ) : <EOL> cflags = opt + '<STR_LIT:U+0020>' + os . environ [ '<STR_LIT>' ] <EOL> ldshared = ldshared + '<STR_LIT:U+0020>' + os . environ [ '<STR_LIT>' ] <EOL> if os . environ . has_key ( '<STR_LIT>' ) : <EOL> cpp = cpp + '<STR_LIT:U+0020>' + os . environ [ '<STR_LIT>' ] <EOL> cflags = cflags + '<STR_LIT:U+0020>' + os . environ [ '<STR_LIT>' ] <EOL> ldshared = ldshared + '<STR_LIT:U+0020>' + os . environ [ '<STR_LIT>' ] <EOL> cc_cmd = cc + '<STR_LIT:U+0020>' + cflags <EOL> compiler . set_executables ( <EOL> preprocessor = cpp , <EOL> compiler = cc_cmd , <EOL> compiler_so = cc_cmd + '<STR_LIT:U+0020>' + ccshared , <EOL> compiler_cxx = cxx , <EOL> linker_so = ldshared , <EOL> linker_exe = cc ) <EOL> compiler . shared_lib_extension = so_ext <EOL> def get_config_h_filename ( ) : <EOL> """<STR_LIT>""" <EOL> if python_build : <EOL> inc_dir = argv0_path <EOL> else : <EOL> inc_dir = get_python_inc ( plat_specific = <NUM_LIT:1> ) <EOL> if get_python_version ( ) < '<STR_LIT>' : <EOL> config_h = '<STR_LIT>' <EOL> else : <EOL> config_h = '<STR_LIT>' <EOL> return os . path . join ( inc_dir , config_h ) <EOL> def get_makefile_filename ( ) : <EOL> """<STR_LIT>""" <EOL> if python_build : <EOL> return os . path . join ( os . path . dirname ( sys . executable ) , "<STR_LIT>" ) <EOL> lib_dir = get_python_lib ( plat_specific = <NUM_LIT:1> , standard_lib = <NUM_LIT:1> ) <EOL> return os . path . join ( lib_dir , "<STR_LIT>" , "<STR_LIT>" ) <EOL> def parse_config_h ( fp , g = None ) : <EOL> """<STR_LIT>""" <EOL> if g is None : <EOL> g = { } <EOL> define_rx = re . compile ( "<STR_LIT>" ) <EOL> undef_rx = re . compile ( "<STR_LIT>" ) <EOL> while <NUM_LIT:1> : <EOL> line = fp . readline ( ) <EOL> if not line : <EOL> break <EOL> m = define_rx . match ( line ) <EOL> if m : <EOL> n , v = m . group ( <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> try : v = int ( v ) <EOL> except ValueError : pass <EOL> g [ n ] = v <EOL> else : <EOL> m = undef_rx . match ( line ) <EOL> if m : <EOL> g [ m . group ( <NUM_LIT:1> ) ] = <NUM_LIT:0> <EOL> return g <EOL> _variable_rx = re . compile ( "<STR_LIT>" ) <EOL> _findvar1_rx = re . compile ( r"<STR_LIT>" ) <EOL> _findvar2_rx = re . compile ( r"<STR_LIT>" ) <EOL> def parse_makefile ( fn , g = None ) : <EOL> """<STR_LIT>""" <EOL> from distutils . text_file import TextFile <EOL> fp = TextFile ( fn , strip_comments = <NUM_LIT:1> , skip_blanks = <NUM_LIT:1> , join_lines = <NUM_LIT:1> ) <EOL> if g is None : <EOL> g = { } <EOL> done = { } <EOL> notdone = { } <EOL> while <NUM_LIT:1> : <EOL> line = fp . readline ( ) <EOL> if line is None : <EOL> break <EOL> m = _variable_rx . match ( line ) <EOL> if m : <EOL> n , v = m . group ( <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> v = string . strip ( v ) <EOL> if "<STR_LIT:$>" in v : <EOL> notdone [ n ] = v <EOL> else : <EOL> try : v = int ( v ) <EOL> except ValueError : pass <EOL> done [ n ] = v <EOL> while notdone : <EOL> for name in notdone . keys ( ) : <EOL> value = notdone [ name ] <EOL> m = _findvar1_rx . search ( value ) or _findvar2_rx . search ( value ) <EOL> if m : <EOL> n = m . group ( <NUM_LIT:1> ) <EOL> found = True <EOL> if done . has_key ( n ) : <EOL> item = str ( done [ n ] ) <EOL> elif notdone . has_key ( n ) : <EOL> found = False <EOL> elif os . environ . has_key ( n ) : <EOL> item = os . environ [ n ] <EOL> else : <EOL> done [ n ] = item = "<STR_LIT>" <EOL> if found : <EOL> after = value [ m . end ( ) : ] <EOL> value = value [ : m . start ( ) ] + item + after <EOL> if "<STR_LIT:$>" in after : <EOL> notdone [ name ] = value <EOL> else : <EOL> try : value = int ( value ) <EOL> except ValueError : <EOL> done [ name ] = string . strip ( value ) <EOL> else : <EOL> done [ name ] = value <EOL> del notdone [ name ] <EOL> else : <EOL> del notdone [ name ] <EOL> fp . close ( ) <EOL> g . update ( done ) <EOL> return g <EOL> def expand_makefile_vars ( s , vars ) : <EOL> """<STR_LIT>""" <EOL> while <NUM_LIT:1> : <EOL> m = _findvar1_rx . search ( s ) or _findvar2_rx . search ( s ) <EOL> if m : <EOL> ( beg , end ) = m . span ( ) <EOL> s = s [ <NUM_LIT:0> : beg ] + vars . get ( m . group ( <NUM_LIT:1> ) ) + s [ end : ] <EOL> else : <EOL> break <EOL> return s <EOL> _config_vars = None <EOL> def _init_posix ( ) : <EOL> """<STR_LIT>""" <EOL> g = { } <EOL> try : <EOL> filename = get_makefile_filename ( ) <EOL> parse_makefile ( filename , g ) <EOL> except IOError , msg : <EOL> my_msg = "<STR_LIT>" % filename <EOL> if hasattr ( msg , "<STR_LIT>" ) : <EOL> my_msg = my_msg + "<STR_LIT>" % msg . strerror <EOL> raise DistutilsPlatformError ( my_msg ) <EOL> try : <EOL> filename = get_config_h_filename ( ) <EOL> parse_config_h ( file ( filename ) , g ) <EOL> except IOError , msg : <EOL> my_msg = "<STR_LIT>" % filename <EOL> if hasattr ( msg , "<STR_LIT>" ) : <EOL> my_msg = my_msg + "<STR_LIT>" % msg . strerror <EOL> raise DistutilsPlatformError ( my_msg ) <EOL> if sys . platform == '<STR_LIT>' and g . has_key ( '<STR_LIT>' ) : <EOL> cfg_target = g [ '<STR_LIT>' ] <EOL> cur_target = os . getenv ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> if cur_target == '<STR_LIT>' : <EOL> cur_target = cfg_target <EOL> os . putenv ( '<STR_LIT>' , cfg_target ) <EOL> elif map ( int , cfg_target . split ( '<STR_LIT:.>' ) ) > map ( int , cur_target . split ( '<STR_LIT:.>' ) ) : <EOL> my_msg = ( '<STR_LIT>' <EOL> % ( cur_target , cfg_target ) ) <EOL> raise DistutilsPlatformError ( my_msg ) <EOL> if python_build : <EOL> g [ '<STR_LIT>' ] = g [ '<STR_LIT>' ] <EOL> elif get_python_version ( ) < '<STR_LIT>' : <EOL> if sys . platform == '<STR_LIT>' : <EOL> python_lib = get_python_lib ( standard_lib = <NUM_LIT:1> ) <EOL> ld_so_aix = os . path . join ( python_lib , '<STR_LIT>' , '<STR_LIT>' ) <EOL> python_exp = os . path . join ( python_lib , '<STR_LIT>' , '<STR_LIT>' ) <EOL> g [ '<STR_LIT>' ] = "<STR_LIT>" % ( ld_so_aix , g [ '<STR_LIT>' ] , python_exp ) <EOL> elif sys . platform == '<STR_LIT>' : <EOL> python_lib = get_python_lib ( standard_lib = <NUM_LIT:1> ) <EOL> linkerscript_path = string . split ( g [ '<STR_LIT>' ] ) [ <NUM_LIT:0> ] <EOL> linkerscript_name = os . path . basename ( linkerscript_path ) <EOL> linkerscript = os . path . join ( python_lib , '<STR_LIT>' , <EOL> linkerscript_name ) <EOL> g [ '<STR_LIT>' ] = ( "<STR_LIT>" % <EOL> ( linkerscript , PREFIX , get_python_version ( ) ) ) <EOL> global _config_vars <EOL> _config_vars = g <EOL> def _init_nt ( ) : <EOL> """<STR_LIT>""" <EOL> g = { } <EOL> g [ '<STR_LIT>' ] = get_python_lib ( plat_specific = <NUM_LIT:0> , standard_lib = <NUM_LIT:1> ) <EOL> g [ '<STR_LIT>' ] = get_python_lib ( plat_specific = <NUM_LIT:1> , standard_lib = <NUM_LIT:1> ) <EOL> g [ '<STR_LIT>' ] = get_python_inc ( plat_specific = <NUM_LIT:0> ) <EOL> g [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> g [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> global _config_vars <EOL> _config_vars = g <EOL> def _init_mac ( ) : <EOL> """<STR_LIT>""" <EOL> g = { } <EOL> g [ '<STR_LIT>' ] = get_python_lib ( plat_specific = <NUM_LIT:0> , standard_lib = <NUM_LIT:1> ) <EOL> g [ '<STR_LIT>' ] = get_python_lib ( plat_specific = <NUM_LIT:1> , standard_lib = <NUM_LIT:1> ) <EOL> g [ '<STR_LIT>' ] = get_python_inc ( plat_specific = <NUM_LIT:0> ) <EOL> import MacOS <EOL> if not hasattr ( MacOS , '<STR_LIT>' ) : <EOL> g [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> else : <EOL> g [ '<STR_LIT>' ] = '<STR_LIT>' % MacOS . runtimemodel <EOL> g [ '<STR_LIT>' ] = os . path . join ( EXEC_PREFIX , "<STR_LIT>" ) <EOL> g [ '<STR_LIT>' ] = os . path . join ( EXEC_PREFIX , "<STR_LIT>" , "<STR_LIT>" ) <EOL> g [ '<STR_LIT>' ] = '<STR_LIT::>' <EOL> global _config_vars <EOL> _config_vars = g <EOL> def _init_os2 ( ) : <EOL> """<STR_LIT>""" <EOL> g = { } <EOL> g [ '<STR_LIT>' ] = get_python_lib ( plat_specific = <NUM_LIT:0> , standard_lib = <NUM_LIT:1> ) <EOL> g [ '<STR_LIT>' ] = get_python_lib ( plat_specific = <NUM_LIT:1> , standard_lib = <NUM_LIT:1> ) <EOL> g [ '<STR_LIT>' ] = get_python_inc ( plat_specific = <NUM_LIT:0> ) <EOL> g [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> g [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> global _config_vars <EOL> _config_vars = g <EOL> def get_config_vars ( * args ) : <EOL> """<STR_LIT>""" <EOL> global _config_vars <EOL> if _config_vars is None : <EOL> func = globals ( ) . get ( "<STR_LIT>" + os . name ) <EOL> if func : <EOL> func ( ) <EOL> else : <EOL> _config_vars = { } <EOL> _config_vars [ '<STR_LIT>' ] = PREFIX <EOL> _config_vars [ '<STR_LIT>' ] = EXEC_PREFIX <EOL> if sys . platform == '<STR_LIT>' : <EOL> kernel_version = os . uname ( ) [ <NUM_LIT:2> ] <EOL> major_version = int ( kernel_version . split ( '<STR_LIT:.>' ) [ <NUM_LIT:0> ] ) <EOL> if major_version < <NUM_LIT:8> : <EOL> for key in ( '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) : <EOL> flags = _config_vars [ key ] <EOL> flags = re . sub ( '<STR_LIT>' , '<STR_LIT:U+0020>' , flags ) <EOL> flags = re . sub ( '<STR_LIT>' , '<STR_LIT:U+0020>' , flags ) <EOL> _config_vars [ key ] = flags <EOL> if args : <EOL> vals = [ ] <EOL> for name in args : <EOL> vals . append ( _config_vars . get ( name ) ) <EOL> return vals <EOL> else : <EOL> return _config_vars <EOL> def get_config_var ( name ) : <EOL> """<STR_LIT>""" <EOL> return get_config_vars ( ) . get ( name ) </s>
