#NEWLINE# def move_wheel_files( name , req , wheeldir , user = False , home = None , root = None , pycompile = True , scheme = None , isolated = False ) : #NEWLINE# #INDENT# 'Install a wheel' #NEWLINE# if ( not scheme ) : #NEWLINE# #INDENT# scheme = distutils_scheme ( name , user = user , home = home , root = root , isolated = isolated ) #NEWLINE# #UNINDENT# if root_is_purelib ( name , wheeldir ) : #NEWLINE# #INDENT# lib_dir = scheme [ 'purelib' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# lib_dir = scheme [ 'platlib' ] #NEWLINE# #UNINDENT# info_dir = [ ] #NEWLINE# data_dirs = [ ] #NEWLINE# source = ( wheeldir . rstrip ( os . path . sep ) + os . path . sep ) #NEWLINE# installed = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# changed = set ( ) #NEWLINE# generated = [ ] #NEWLINE# if pycompile : #NEWLINE# #INDENT# with captured_stdout ( ) as stdout : #NEWLINE# #INDENT# with warnings . catch_warnings ( ) : #NEWLINE# #INDENT# warnings . filterwarnings ( 'ignore' ) #NEWLINE# compileall . compile_dir ( source , force = True , quiet = True ) #NEWLINE# #UNINDENT# #UNINDENT# logger . debug ( stdout . getvalue ( ) ) #NEWLINE# #UNINDENT# def normpath( src , p ) : #NEWLINE# #INDENT# return make_path_relative ( src , p ) . replace ( os . path . sep , '/' ) #NEWLINE# #UNINDENT# def record_installed( srcfile , destfile , modified = False ) : #NEWLINE# #INDENT# 'Map archive RECORD paths to installation RECORD paths.' #NEWLINE# oldpath = normpath ( srcfile , wheeldir ) #NEWLINE# newpath = normpath ( destfile , lib_dir ) #NEWLINE# installed [ oldpath ] = newpath #NEWLINE# if modified : #NEWLINE# #INDENT# changed . add ( destfile ) #NEWLINE# #UNINDENT# #UNINDENT# def clobber( source , dest , is_base , fixer = None , filter = None ) : #NEWLINE# #INDENT# ensure_dir ( dest ) #NEWLINE# for ( dir , subdirs , files ) in os . walk ( source ) : #NEWLINE# #INDENT# basedir = dir [ len ( source ) : ] . lstrip ( os . path . sep ) #NEWLINE# destdir = os . path . join ( dest , basedir ) #NEWLINE# if ( is_base and basedir . split ( os . path . sep , 1 ) [ 0 ] . endswith ( '.data' ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# for s in subdirs : #NEWLINE# #INDENT# destsubdir = os . path . join ( dest , basedir , s ) #NEWLINE# if ( is_base and ( basedir == '' ) and destsubdir . endswith ( '.data' ) ) : #NEWLINE# #INDENT# data_dirs . append ( s ) #NEWLINE# continue #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( is_base and s . endswith ( '.dist-info' ) and s . lower ( ) . startswith ( req . project_name . replace ( '-' , '_' ) . lower ( ) ) ) : #NEWLINE# #INDENT# assert ( not info_dir ) , 'Multiple .dist-info directories' #NEWLINE# info_dir . append ( destsubdir ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# for f in files : #NEWLINE# #INDENT# if ( filter and filter ( f ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# srcfile = os . path . join ( dir , f ) #NEWLINE# destfile = os . path . join ( dest , basedir , f ) #NEWLINE# ensure_dir ( destdir ) #NEWLINE# shutil . copyfile ( srcfile , destfile ) #NEWLINE# st = os . stat ( srcfile ) #NEWLINE# if hasattr ( os , 'utime' ) : #NEWLINE# #INDENT# os . utime ( destfile , ( st . st_atime , st . st_mtime ) ) #NEWLINE# #UNINDENT# if os . access ( srcfile , os . X_OK ) : #NEWLINE# #INDENT# st = os . stat ( srcfile ) #NEWLINE# permissions = ( ( ( st . st_mode | stat . S_IXUSR ) | stat . S_IXGRP ) | stat . S_IXOTH ) #NEWLINE# os . chmod ( destfile , permissions ) #NEWLINE# #UNINDENT# changed = False #NEWLINE# if fixer : #NEWLINE# #INDENT# changed = fixer ( destfile ) #NEWLINE# #UNINDENT# record_installed ( srcfile , destfile , changed ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# clobber ( source , lib_dir , True ) #NEWLINE# assert info_dir , ( '%s .dist-info directory not found' % req ) #NEWLINE# ep_file = os . path . join ( info_dir [ 0 ] , 'entry_points.txt' ) #NEWLINE# ( console , gui ) = get_entrypoints ( ep_file ) #NEWLINE# def is_entrypoint_wrapper( name ) : #NEWLINE# #INDENT# if name . lower ( ) . endswith ( '.exe' ) : #NEWLINE# #INDENT# matchname = name [ : ( - 4 ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if name . lower ( ) . endswith ( '-script.py' ) : #NEWLINE# #INDENT# matchname = name [ : ( - 10 ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if name . lower ( ) . endswith ( '.pya' ) : #NEWLINE# #INDENT# matchname = name [ : ( - 4 ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# matchname = name #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return ( ( matchname in console ) or ( matchname in gui ) ) #NEWLINE# #UNINDENT# for datadir in data_dirs : #NEWLINE# #INDENT# fixer = None #NEWLINE# filter = None #NEWLINE# for subdir in os . listdir ( os . path . join ( wheeldir , datadir ) ) : #NEWLINE# #INDENT# fixer = None #NEWLINE# if ( subdir == 'scripts' ) : #NEWLINE# #INDENT# fixer = fix_script #NEWLINE# filter = is_entrypoint_wrapper #NEWLINE# #UNINDENT# source = os . path . join ( wheeldir , datadir , subdir ) #NEWLINE# dest = scheme [ subdir ] #NEWLINE# clobber ( source , dest , False , fixer = fixer , filter = filter ) #NEWLINE# #UNINDENT# #UNINDENT# maker = ScriptMaker ( None , scheme [ 'scripts' ] ) #NEWLINE# maker . clobber = True #NEWLINE# maker . variants = set ( ( '' , ) ) #NEWLINE# maker . set_mode = True #NEWLINE# def _get_script_text( entry ) : #NEWLINE# #INDENT# return ( maker . script_template % { #NEWLINE# #INDENT# 'module' : entry . prefix , #NEWLINE# 'import_name' : entry . suffix . split ( '.' ) [ 0 ] , #NEWLINE# 'func' : entry . suffix , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# maker . _get_script_text = _get_script_text #NEWLINE# maker . script_template = "# -*- coding: utf-8 -*-\nimport re\nimport sys\n\nfrom %(module)s import %(import_name)s\n\nif __name__ == '__main__':\n    sys.argv[0] = re.sub(r'(-script\\.pyw|\\.exe)?$', '', sys.argv[0])\n    sys.exit(%(func)s())\n" #NEWLINE# pip_script = console . pop ( 'pip' , None ) #NEWLINE# if pip_script : #NEWLINE# #INDENT# if ( 'ENSUREPIP_OPTIONS' not in os . environ ) : #NEWLINE# #INDENT# spec = ( 'pip = ' + pip_script ) #NEWLINE# generated . extend ( maker . make ( spec ) ) #NEWLINE# #UNINDENT# if ( os . environ . get ( 'ENSUREPIP_OPTIONS' , '' ) != 'altinstall' ) : #NEWLINE# #INDENT# spec = ( 'pip%s = %s' % ( sys . version [ : 1 ] , pip_script ) ) #NEWLINE# generated . extend ( maker . make ( spec ) ) #NEWLINE# #UNINDENT# spec = ( 'pip%s = %s' % ( sys . version [ : 3 ] , pip_script ) ) #NEWLINE# generated . extend ( maker . make ( spec ) ) #NEWLINE# pip_ep = [ k for k in console if re . match ( 'pip(\\d(\\.\\d)?)?$' , k ) ] #NEWLINE# for k in pip_ep : #NEWLINE# #INDENT# del console [ k ] #NEWLINE# #UNINDENT# #UNINDENT# easy_install_script = console . pop ( 'easy_install' , None ) #NEWLINE# if easy_install_script : #NEWLINE# #INDENT# if ( 'ENSUREPIP_OPTIONS' not in os . environ ) : #NEWLINE# #INDENT# spec = ( 'easy_install = ' + easy_install_script ) #NEWLINE# generated . extend ( maker . make ( spec ) ) #NEWLINE# #UNINDENT# spec = ( 'easy_install-%s = %s' % ( sys . version [ : 3 ] , easy_install_script ) ) #NEWLINE# generated . extend ( maker . make ( spec ) ) #NEWLINE# easy_install_ep = [ k for k in console if re . match ( 'easy_install(-\\d\\.\\d)?$' , k ) ] #NEWLINE# for k in easy_install_ep : #NEWLINE# #INDENT# del console [ k ] #NEWLINE# #UNINDENT# #UNINDENT# if ( len ( console ) > 0 ) : #NEWLINE# #INDENT# generated . extend ( maker . make_multiple ( [ ( '%s = %s' % kv ) for kv in console . items ( ) ] ) ) #NEWLINE# #UNINDENT# if ( len ( gui ) > 0 ) : #NEWLINE# #INDENT# generated . extend ( maker . make_multiple ( [ ( '%s = %s' % kv ) for kv in gui . items ( ) ] , { #NEWLINE# #INDENT# 'gui' : True , #NEWLINE# #UNINDENT# } ) ) #NEWLINE# #UNINDENT# record = os . path . join ( info_dir [ 0 ] , 'RECORD' ) #NEWLINE# temp_record = os . path . join ( info_dir [ 0 ] , 'RECORD.pip' ) #NEWLINE# with open_for_csv ( record , 'r' ) as record_in : #NEWLINE# #INDENT# with open_for_csv ( temp_record , 'w+' ) as record_out : #NEWLINE# #INDENT# reader = csv . reader ( record_in ) #NEWLINE# writer = csv . writer ( record_out ) #NEWLINE# for row in reader : #NEWLINE# #INDENT# row [ 0 ] = installed . pop ( row [ 0 ] , row [ 0 ] ) #NEWLINE# if ( row [ 0 ] in changed ) : #NEWLINE# #INDENT# ( row [ 1 ] , row [ 2 ] ) = rehash ( row [ 0 ] ) #NEWLINE# #UNINDENT# writer . writerow ( row ) #NEWLINE# #UNINDENT# for f in generated : #NEWLINE# #INDENT# ( h , l ) = rehash ( f ) #NEWLINE# writer . writerow ( ( f , h , l ) ) #NEWLINE# #UNINDENT# for f in installed : #NEWLINE# #INDENT# writer . writerow ( ( installed [ f ] , '' , '' ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# shutil . move ( temp_record , record )