#NEWLINE# def register( target , current = True ) : #NEWLINE# #INDENT# 'Register a Python distribution in Windows registry' #NEWLINE# root = ( winreg . HKEY_CURRENT_USER if current else winreg . HKEY_LOCAL_MACHINE ) #NEWLINE# winreg . SetValueEx ( winreg . CreateKey ( root , ( KEY_C % '.py' ) ) , '' , 0 , winreg . REG_SZ , 'Python.File' ) #NEWLINE# winreg . SetValueEx ( winreg . CreateKey ( root , ( KEY_C % '.pyw' ) ) , '' , 0 , winreg . REG_SZ , 'Python.NoConFile' ) #NEWLINE# winreg . SetValueEx ( winreg . CreateKey ( root , ( KEY_C % '.pyc' ) ) , '' , 0 , winreg . REG_SZ , 'Python.CompiledFile' ) #NEWLINE# winreg . SetValueEx ( winreg . CreateKey ( root , ( KEY_C % '.pyo' ) ) , '' , 0 , winreg . REG_SZ , 'Python.CompiledFile' ) #NEWLINE# winreg . SetValueEx ( winreg . CreateKey ( root , ( KEY_C % '.py' ) ) , 'Content Type' , 0 , winreg . REG_SZ , 'text/plain' ) #NEWLINE# winreg . SetValueEx ( winreg . CreateKey ( root , ( KEY_C % '.pyw' ) ) , 'Content Type' , 0 , winreg . REG_SZ , 'text/plain' ) #NEWLINE# python = osp . abspath ( osp . join ( target , 'python.exe' ) ) #NEWLINE# pythonw = osp . abspath ( osp . join ( target , 'pythonw.exe' ) ) #NEWLINE# spyder = osp . abspath ( osp . join ( target , os . pardir , 'Spyder.exe' ) ) #NEWLINE# if ( not osp . isfile ( spyder ) ) : #NEWLINE# #INDENT# spyder = ( '%s" "%s\\Scripts\\spyder' % ( pythonw , target ) ) #NEWLINE# #UNINDENT# winreg . SetValueEx ( winreg . CreateKey ( root , ( KEY_C2 % ( '' , 'open' ) ) ) , '' , 0 , winreg . REG_SZ , ( '"%s" "%%1" %%*' % python ) ) #NEWLINE# winreg . SetValueEx ( winreg . CreateKey ( root , ( KEY_C2 % ( 'NoCon' , 'open' ) ) ) , '' , 0 , winreg . REG_SZ , ( '"%s" "%%1" %%*' % pythonw ) ) #NEWLINE# winreg . SetValueEx ( winreg . CreateKey ( root , ( KEY_C2 % ( 'Compiled' , 'open' ) ) ) , '' , 0 , winreg . REG_SZ , ( '"%s" "%%1" %%*' % python ) ) #NEWLINE# winreg . SetValueEx ( winreg . CreateKey ( root , ( KEY_C2 % ( '' , EWI ) ) ) , '' , 0 , winreg . REG_SZ , ( '"%s" "%s\\Lib\\idlelib\\idle.pyw" -n -e "%%1"' % ( pythonw , target ) ) ) #NEWLINE# winreg . SetValueEx ( winreg . CreateKey ( root , ( KEY_C2 % ( 'NoCon' , EWI ) ) ) , '' , 0 , winreg . REG_SZ , ( '"%s" "%s\\Lib\\idlelib\\idle.pyw" -n -e "%%1"' % ( pythonw , target ) ) ) #NEWLINE# winreg . SetValueEx ( winreg . CreateKey ( root , ( KEY_C2 % ( '' , EWS ) ) ) , '' , 0 , winreg . REG_SZ , ( '"%s" "%%1"' % spyder ) ) #NEWLINE# winreg . SetValueEx ( winreg . CreateKey ( root , ( KEY_C2 % ( 'NoCon' , EWS ) ) ) , '' , 0 , winreg . REG_SZ , ( '"%s" "%%1"' % spyder ) ) #NEWLINE# handler = '{60254CA5-953B-11CF-8C96-00AA00B8708C}' #NEWLINE# for ftype in ( '' , 'NoCon' , 'Compiled' ) : #NEWLINE# #INDENT# winreg . SetValueEx ( winreg . CreateKey ( root , ( KEY_DROP1 % ftype ) ) , '' , 0 , winreg . REG_SZ , handler ) #NEWLINE# #UNINDENT# dlls = osp . join ( target , 'DLLs' ) #NEWLINE# winreg . SetValueEx ( winreg . CreateKey ( root , ( KEY_I % '' ) ) , '' , 0 , winreg . REG_SZ , ( '%s\\py.ico' % dlls ) ) #NEWLINE# winreg . SetValueEx ( winreg . CreateKey ( root , ( KEY_I % 'NoCon' ) ) , '' , 0 , winreg . REG_SZ , ( '%s\\py.ico' % dlls ) ) #NEWLINE# winreg . SetValueEx ( winreg . CreateKey ( root , ( KEY_I % 'Compiled' ) ) , '' , 0 , winreg . REG_SZ , ( '%s\\pyc.ico' % dlls ) ) #NEWLINE# winreg . SetValueEx ( winreg . CreateKey ( root , ( KEY_D % '' ) ) , '' , 0 , winreg . REG_SZ , 'Python File' ) #NEWLINE# winreg . SetValueEx ( winreg . CreateKey ( root , ( KEY_D % 'NoCon' ) ) , '' , 0 , winreg . REG_SZ , 'Python File (no console)' ) #NEWLINE# winreg . SetValueEx ( winreg . CreateKey ( root , ( KEY_D % 'Compiled' ) ) , '' , 0 , winreg . REG_SZ , 'Compiled Python File' ) #NEWLINE# short_version = utils . get_python_infos ( target ) [ 0 ] #NEWLINE# long_version = utils . get_python_long_version ( target ) #NEWLINE# key_core = ( ( KEY_S1 % short_version ) + '\\%s' ) #NEWLINE# winreg . SetValueEx ( winreg . CreateKey ( root , ( key_core % 'InstallPath' ) ) , '' , 0 , winreg . REG_SZ , target ) #NEWLINE# winreg . SetValueEx ( winreg . CreateKey ( root , ( key_core % 'InstallPath\\InstallGroup' ) ) , '' , 0 , winreg . REG_SZ , ( 'Python %s' % short_version ) ) #NEWLINE# winreg . SetValueEx ( winreg . CreateKey ( root , ( key_core % 'Modules' ) ) , '' , 0 , winreg . REG_SZ , '' ) #NEWLINE# winreg . SetValueEx ( winreg . CreateKey ( root , ( key_core % 'PythonPath' ) ) , '' , 0 , winreg . REG_SZ , ( '%s\\Lib;%s\\DLLs' % ( target , target ) ) ) #NEWLINE# winreg . SetValueEx ( winreg . CreateKey ( root , ( key_core % 'Help\\Main Python Documentation' ) ) , '' , 0 , winreg . REG_SZ , ( '%s\\Doc\\python%s.chm' % ( target , long_version ) ) ) #NEWLINE# for ( path , desc , fname ) in _get_shortcut_data ( target , current = current ) : #NEWLINE# #INDENT# utils . create_shortcut ( path , desc , fname ) #NEWLINE# #UNINDENT# axscript = osp . join ( target , 'Lib' , 'site-packages' , 'win32comext' , 'axscript' , 'client' , 'pyscript.py' ) #NEWLINE# if osp . isfile ( axscript ) : #NEWLINE# #INDENT# subprocess . call ( ( '"%s" "%s"' % ( python , axscript ) ) , cwd = target ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# print ( 'Unable to register ActiveX: please install pywin32' , file = sys . stderr )