<s> """<STR_LIT>""" <EOL> from distutils import log <EOL> __revision__ = "<STR_LIT>" <EOL> import sys , os , string <EOL> from types import * <EOL> from distutils . core import Command <EOL> from distutils . debug import DEBUG <EOL> from distutils . sysconfig import get_config_vars <EOL> from distutils . errors import DistutilsPlatformError <EOL> from distutils . file_util import write_file <EOL> from distutils . util import convert_path , subst_vars , change_root <EOL> from distutils . util import get_platform <EOL> from distutils . errors import DistutilsOptionError <EOL> from site import USER_BASE <EOL> from site import USER_SITE <EOL> if sys . version < "<STR_LIT>" : <EOL> WINDOWS_SCHEME = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:data>' : '<STR_LIT>' , <EOL> } <EOL> else : <EOL> WINDOWS_SCHEME = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:data>' : '<STR_LIT>' , <EOL> } <EOL> INSTALL_SCHEMES = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:data>' : '<STR_LIT>' , <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:data>' : '<STR_LIT>' , <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:data>' : '<STR_LIT>' , <EOL> } , <EOL> '<STR_LIT>' : WINDOWS_SCHEME , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:data>' : '<STR_LIT>' , <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:data>' : '<STR_LIT>' , <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:data>' : '<STR_LIT>' , <EOL> } , <EOL> } <EOL> SCHEME_KEYS = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:data>' ) <EOL> class install ( Command ) : <EOL> description = "<STR_LIT>" <EOL> user_options = [ <EOL> ( '<STR_LIT>' , None , <EOL> "<STR_LIT>" ) , <EOL> ( '<STR_LIT>' , None , <EOL> "<STR_LIT>" ) , <EOL> ( '<STR_LIT>' , None , <EOL> "<STR_LIT>" ) , <EOL> ( '<STR_LIT:user>' , None , <EOL> "<STR_LIT>" % USER_SITE ) , <EOL> ( '<STR_LIT>' , None , <EOL> "<STR_LIT>" ) , <EOL> ( '<STR_LIT>' , None , <EOL> "<STR_LIT>" + <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>" ) , <EOL> ( '<STR_LIT>' , None , <EOL> "<STR_LIT>" ) , <EOL> ( '<STR_LIT>' , None , <EOL> "<STR_LIT>" ) , <EOL> ( '<STR_LIT>' , None , <EOL> "<STR_LIT>" ) , <EOL> ( '<STR_LIT>' , '<STR_LIT:c>' , "<STR_LIT>" ) , <EOL> ( '<STR_LIT>' , None , "<STR_LIT>" ) , <EOL> ( '<STR_LIT>' , '<STR_LIT:O>' , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> ( '<STR_LIT>' , '<STR_LIT:f>' , <EOL> "<STR_LIT>" ) , <EOL> ( '<STR_LIT>' , None , <EOL> "<STR_LIT>" ) , <EOL> ( '<STR_LIT>' , None , <EOL> "<STR_LIT>" ) , <EOL> ] <EOL> boolean_options = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:user>' ] <EOL> negative_opt = { '<STR_LIT>' : '<STR_LIT>' } <EOL> def initialize_options ( self ) : <EOL> self . prefix = None <EOL> self . exec_prefix = None <EOL> self . home = None <EOL> self . user = <NUM_LIT:0> <EOL> self . install_base = None <EOL> self . install_platbase = None <EOL> self . root = None <EOL> self . install_purelib = None <EOL> self . install_platlib = None <EOL> self . install_headers = None <EOL> self . install_lib = None <EOL> self . install_scripts = None <EOL> self . install_data = None <EOL> self . install_userbase = USER_BASE <EOL> self . install_usersite = USER_SITE <EOL> self . compile = None <EOL> self . optimize = None <EOL> self . extra_path = None <EOL> self . install_path_file = <NUM_LIT:1> <EOL> self . force = <NUM_LIT:0> <EOL> self . skip_build = <NUM_LIT:0> <EOL> self . warn_dir = <NUM_LIT:1> <EOL> self . build_base = None <EOL> self . build_lib = None <EOL> self . record = None <EOL> def finalize_options ( self ) : <EOL> if ( ( self . prefix or self . exec_prefix or self . home ) and <EOL> ( self . install_base or self . install_platbase ) ) : <EOL> raise DistutilsOptionError , ( "<STR_LIT>" + <EOL> "<STR_LIT>" ) <EOL> if self . home and ( self . prefix or self . exec_prefix ) : <EOL> raise DistutilsOptionError , "<STR_LIT>" <EOL> if self . user and ( self . prefix or self . exec_prefix or self . home or <EOL> self . install_base or self . install_platbase ) : <EOL> raise DistutilsOptionError ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> if os . name != "<STR_LIT>" : <EOL> if self . exec_prefix : <EOL> self . warn ( "<STR_LIT>" ) <EOL> self . exec_prefix = None <EOL> self . dump_dirs ( "<STR_LIT>" ) <EOL> if os . name == '<STR_LIT>' : <EOL> self . finalize_unix ( ) <EOL> else : <EOL> self . finalize_other ( ) <EOL> self . dump_dirs ( "<STR_LIT>" ) <EOL> py_version = ( string . split ( sys . version ) ) [ <NUM_LIT:0> ] <EOL> ( prefix , exec_prefix ) = get_config_vars ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . config_vars = { '<STR_LIT>' : self . distribution . get_name ( ) , <EOL> '<STR_LIT>' : self . distribution . get_version ( ) , <EOL> '<STR_LIT>' : self . distribution . get_fullname ( ) , <EOL> '<STR_LIT>' : py_version , <EOL> '<STR_LIT>' : py_version [ <NUM_LIT:0> : <NUM_LIT:3> ] , <EOL> '<STR_LIT>' : py_version [ <NUM_LIT:0> ] + py_version [ <NUM_LIT:2> ] , <EOL> '<STR_LIT>' : prefix , <EOL> '<STR_LIT>' : prefix , <EOL> '<STR_LIT>' : exec_prefix , <EOL> '<STR_LIT>' : exec_prefix , <EOL> '<STR_LIT>' : self . install_userbase , <EOL> '<STR_LIT>' : self . install_usersite , <EOL> } <EOL> self . expand_basedirs ( ) <EOL> self . dump_dirs ( "<STR_LIT>" ) <EOL> self . config_vars [ '<STR_LIT>' ] = self . install_base <EOL> self . config_vars [ '<STR_LIT>' ] = self . install_platbase <EOL> if DEBUG : <EOL> from pprint import pprint <EOL> print "<STR_LIT>" <EOL> pprint ( self . config_vars ) <EOL> self . expand_dirs ( ) <EOL> self . dump_dirs ( "<STR_LIT>" ) <EOL> if self . user : <EOL> self . create_home_path ( ) <EOL> if self . install_lib is None : <EOL> if self . distribution . ext_modules : <EOL> self . install_lib = self . install_platlib <EOL> else : <EOL> self . install_lib = self . install_purelib <EOL> self . convert_paths ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT:data>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . handle_extra_path ( ) <EOL> self . install_libbase = self . install_lib <EOL> self . install_lib = os . path . join ( self . install_lib , self . extra_dirs ) <EOL> if self . root is not None : <EOL> self . change_roots ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT:data>' , '<STR_LIT>' ) <EOL> self . dump_dirs ( "<STR_LIT>" ) <EOL> self . set_undefined_options ( '<STR_LIT>' , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> def dump_dirs ( self , msg ) : <EOL> if DEBUG : <EOL> from distutils . fancy_getopt import longopt_xlate <EOL> print msg + "<STR_LIT::>" <EOL> for opt in self . user_options : <EOL> opt_name = opt [ <NUM_LIT:0> ] <EOL> if opt_name [ - <NUM_LIT:1> ] == "<STR_LIT:=>" : <EOL> opt_name = opt_name [ <NUM_LIT:0> : - <NUM_LIT:1> ] <EOL> if opt_name in self . negative_opt : <EOL> opt_name = string . translate ( self . negative_opt [ opt_name ] , <EOL> longopt_xlate ) <EOL> val = not getattr ( self , opt_name ) <EOL> else : <EOL> opt_name = string . translate ( opt_name , longopt_xlate ) <EOL> val = getattr ( self , opt_name ) <EOL> print "<STR_LIT>" % ( opt_name , val ) <EOL> def finalize_unix ( self ) : <EOL> if self . install_base is not None or self . install_platbase is not None : <EOL> if ( ( self . install_lib is None and <EOL> self . install_purelib is None and <EOL> self . install_platlib is None ) or <EOL> self . install_headers is None or <EOL> self . install_scripts is None or <EOL> self . install_data is None ) : <EOL> raise DistutilsOptionError , ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> return <EOL> if self . user : <EOL> if self . install_userbase is None : <EOL> raise DistutilsPlatformError ( <EOL> "<STR_LIT>" ) <EOL> self . install_base = self . install_platbase = self . install_userbase <EOL> self . select_scheme ( "<STR_LIT>" ) <EOL> elif self . home is not None : <EOL> self . install_base = self . install_platbase = self . home <EOL> self . select_scheme ( "<STR_LIT>" ) <EOL> else : <EOL> if self . prefix is None : <EOL> if self . exec_prefix is not None : <EOL> raise DistutilsOptionError , "<STR_LIT>" <EOL> self . prefix = os . path . normpath ( sys . prefix ) <EOL> self . exec_prefix = os . path . normpath ( sys . exec_prefix ) <EOL> else : <EOL> if self . exec_prefix is None : <EOL> self . exec_prefix = self . prefix <EOL> self . install_base = self . prefix <EOL> self . install_platbase = self . exec_prefix <EOL> self . select_scheme ( "<STR_LIT>" ) <EOL> def finalize_other ( self ) : <EOL> if self . user : <EOL> if self . install_userbase is None : <EOL> raise DistutilsPlatformError ( <EOL> "<STR_LIT>" ) <EOL> self . install_base = self . install_platbase = self . install_userbase <EOL> self . select_scheme ( os . name + "<STR_LIT>" ) <EOL> elif self . home is not None : <EOL> self . install_base = self . install_platbase = self . home <EOL> self . select_scheme ( "<STR_LIT>" ) <EOL> else : <EOL> if self . prefix is None : <EOL> self . prefix = os . path . normpath ( sys . prefix ) <EOL> self . install_base = self . install_platbase = self . prefix <EOL> try : <EOL> self . select_scheme ( os . name ) <EOL> except KeyError : <EOL> raise DistutilsPlatformError , "<STR_LIT>" % os . name <EOL> def select_scheme ( self , name ) : <EOL> scheme = INSTALL_SCHEMES [ name ] <EOL> for key in SCHEME_KEYS : <EOL> attrname = '<STR_LIT>' + key <EOL> if getattr ( self , attrname ) is None : <EOL> setattr ( self , attrname , scheme [ key ] ) <EOL> def _expand_attrs ( self , attrs ) : <EOL> for attr in attrs : <EOL> val = getattr ( self , attr ) <EOL> if val is not None : <EOL> if os . name == '<STR_LIT>' or os . name == '<STR_LIT>' : <EOL> val = os . path . expanduser ( val ) <EOL> val = subst_vars ( val , self . config_vars ) <EOL> setattr ( self , attr , val ) <EOL> def expand_basedirs ( self ) : <EOL> self . _expand_attrs ( [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:root>' ] ) <EOL> def expand_dirs ( self ) : <EOL> self . _expand_attrs ( [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , ] ) <EOL> def convert_paths ( self , * names ) : <EOL> for name in names : <EOL> attr = "<STR_LIT>" + name <EOL> setattr ( self , attr , convert_path ( getattr ( self , attr ) ) ) <EOL> def handle_extra_path ( self ) : <EOL> if self . extra_path is None : <EOL> self . extra_path = self . distribution . extra_path <EOL> if self . extra_path is not None : <EOL> if type ( self . extra_path ) is StringType : <EOL> self . extra_path = string . split ( self . extra_path , '<STR_LIT:U+002C>' ) <EOL> if len ( self . extra_path ) == <NUM_LIT:1> : <EOL> path_file = extra_dirs = self . extra_path [ <NUM_LIT:0> ] <EOL> elif len ( self . extra_path ) == <NUM_LIT:2> : <EOL> ( path_file , extra_dirs ) = self . extra_path <EOL> else : <EOL> raise DistutilsOptionError , ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> extra_dirs = convert_path ( extra_dirs ) <EOL> else : <EOL> path_file = None <EOL> extra_dirs = '<STR_LIT>' <EOL> self . path_file = path_file <EOL> self . extra_dirs = extra_dirs <EOL> def change_roots ( self , * names ) : <EOL> for name in names : <EOL> attr = "<STR_LIT>" + name <EOL> setattr ( self , attr , change_root ( self . root , getattr ( self , attr ) ) ) <EOL> def create_home_path ( self ) : <EOL> """<STR_LIT>""" <EOL> if not self . user : <EOL> return <EOL> home = convert_path ( os . path . expanduser ( "<STR_LIT>" ) ) <EOL> for name , path in self . config_vars . iteritems ( ) : <EOL> if path . startswith ( home ) and not os . path . isdir ( path ) : <EOL> self . debug_print ( "<STR_LIT>" % path ) <EOL> os . makedirs ( path , <NUM_LIT:0> <NUM_LIT> ) <EOL> def run ( self ) : <EOL> if not self . skip_build : <EOL> self . run_command ( '<STR_LIT>' ) <EOL> build_plat = self . distribution . get_command_obj ( '<STR_LIT>' ) . plat_name <EOL> if self . warn_dir and build_plat != get_platform ( ) : <EOL> raise DistutilsPlatformError ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> for cmd_name in self . get_sub_commands ( ) : <EOL> self . run_command ( cmd_name ) <EOL> if self . path_file : <EOL> self . create_path_file ( ) <EOL> if self . record : <EOL> outputs = self . get_outputs ( ) <EOL> if self . root : <EOL> root_len = len ( self . root ) <EOL> for counter in xrange ( len ( outputs ) ) : <EOL> outputs [ counter ] = outputs [ counter ] [ root_len : ] <EOL> self . execute ( write_file , <EOL> ( self . record , outputs ) , <EOL> "<STR_LIT>" % <EOL> self . record ) <EOL> sys_path = map ( os . path . normpath , sys . path ) <EOL> sys_path = map ( os . path . normcase , sys_path ) <EOL> install_lib = os . path . normcase ( os . path . normpath ( self . install_lib ) ) <EOL> if ( self . warn_dir and <EOL> not ( self . path_file and self . install_path_file ) and <EOL> install_lib not in sys_path ) : <EOL> log . debug ( ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> self . install_lib ) <EOL> def create_path_file ( self ) : <EOL> filename = os . path . join ( self . install_libbase , <EOL> self . path_file + "<STR_LIT>" ) <EOL> if self . install_path_file : <EOL> self . execute ( write_file , <EOL> ( filename , [ self . extra_dirs ] ) , <EOL> "<STR_LIT>" % filename ) <EOL> else : <EOL> self . warn ( "<STR_LIT>" % filename ) <EOL> def get_outputs ( self ) : <EOL> outputs = [ ] <EOL> for cmd_name in self . get_sub_commands ( ) : <EOL> cmd = self . get_finalized_command ( cmd_name ) <EOL> for filename in cmd . get_outputs ( ) : <EOL> if filename not in outputs : <EOL> outputs . append ( filename ) <EOL> if self . path_file and self . install_path_file : <EOL> outputs . append ( os . path . join ( self . install_libbase , <EOL> self . path_file + "<STR_LIT>" ) ) <EOL> return outputs <EOL> def get_inputs ( self ) : <EOL> inputs = [ ] <EOL> for cmd_name in self . get_sub_commands ( ) : <EOL> cmd = self . get_finalized_command ( cmd_name ) <EOL> inputs . extend ( cmd . get_inputs ( ) ) <EOL> return inputs <EOL> def has_lib ( self ) : <EOL> """<STR_LIT>""" <EOL> return ( self . distribution . has_pure_modules ( ) or <EOL> self . distribution . has_ext_modules ( ) ) <EOL> def has_headers ( self ) : <EOL> return self . distribution . has_headers ( ) <EOL> def has_scripts ( self ) : <EOL> return self . distribution . has_scripts ( ) <EOL> def has_data ( self ) : <EOL> return self . distribution . has_data_files ( ) <EOL> sub_commands = [ ( '<STR_LIT>' , has_lib ) , <EOL> ( '<STR_LIT>' , has_headers ) , <EOL> ( '<STR_LIT>' , has_scripts ) , <EOL> ( '<STR_LIT>' , has_data ) , <EOL> ( '<STR_LIT>' , lambda self : True ) , <EOL> ] </s>
