def install():
    """Function executed when running the script with the -install switch"""
    # Create Spyder start menu folder
    # Don't use CSIDL_COMMON_PROGRAMS because it requres admin rights
    # This is consistent with use of CSIDL_DESKTOPDIRECTORY below
    # CSIDL_COMMON_PROGRAMS =
    # C:\ProgramData\Microsoft\Windows\Start Menu\Programs
    # CSIDL_PROGRAMS =
    # C:\Users\<username>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs
    start_menu = osp.join(get_special_folder_path('CSIDL_PROGRAMS'),
                          'Spyder (Py%i.%i %i bit)' % (sys.version_info[0],
                                                       sys.version_info[1],
                                                       struct.calcsize('P')*8))
    if not osp.isdir(start_menu):
        os.mkdir(start_menu)
        directory_created(start_menu)

    # Create Spyder start menu entries
    python = osp.abspath(osp.join(sys.prefix, 'python.exe'))
    pythonw = osp.abspath(osp.join(sys.prefix, 'pythonw.exe'))
    script = osp.abspath(osp.join(sys.prefix, 'scripts', 'spyder'))
    if not osp.exists(script): # if not installed to the site scripts dir
        script = osp.abspath(osp.join(osp.dirname(osp.abspath(__file__)), 'spyder'))
    workdir = "%HOMEDRIVE%%HOMEPATH%"
    import distutils.sysconfig
    lib_dir = distutils.sysconfig.get_python_lib(plat_specific=1)
    ico_dir = osp.join(lib_dir, 'spyder', 'windows')
    # if user is running -install manually then icons are in Scripts/
    if not osp.isdir(ico_dir):
        ico_dir = osp.dirname(osp.abspath(__file__))

    desc = 'The Scientific Python Development Environment'
    fname = osp.join(start_menu, 'Spyder (full).lnk')
    create_shortcut(python, desc, fname, '"%s"' % script, workdir,
                    osp.join(ico_dir, 'spyder.ico'))
    file_created(fname)

    fname = osp.join(start_menu, 'Spyder-Reset all settings.lnk')
    create_shortcut(python, 'Reset Spyder settings to defaults',
                    fname, '"%s" --reset' % script, workdir)
    file_created(fname)

    current = True  # only affects current user
    root = winreg.HKEY_CURRENT_USER if current else winreg.HKEY_LOCAL_MACHINE
    winreg.SetValueEx(winreg.CreateKey(root, KEY_C1 % ("", EWS)),
                      "", 0, winreg.REG_SZ,
                      '"%s" "%s\Scripts\spyder" "%%1"' % (pythonw, sys.prefix))
    winreg.SetValueEx(winreg.CreateKey(root, KEY_C1 % ("NoCon", EWS)),
                      "", 0, winreg.REG_SZ,
                      '"%s" "%s\Scripts\spyder" "%%1"' % (pythonw, sys.prefix))

    # Create desktop shortcut file
    desktop_folder = get_special_folder_path("CSIDL_DESKTOPDIRECTORY")
    fname = osp.join(desktop_folder, 'Spyder.lnk')
    desc = 'The Scientific Python Development Environment'
    create_shortcut(pythonw, desc, fname, '"%s"' % script, workdir,
                    osp.join(ico_dir, 'spyder.ico'))
    file_created(fname)
def install ( ) : start_menu = osp . join ( get_special_folder_path ( 'CSIDL_PROGRAMS' ) , 'Spyder (Py%i.%i %i bit)' % ( sys . version_info [ 0 ] , sys . version_info [ 1 ] , struct . calcsize ( 'P' ) * 8 ) ) if not osp . isdir ( start_menu ) : os . mkdir ( start_menu ) directory_created ( start_menu ) python = osp . abspath ( osp . join ( sys . prefix , 'python.exe' ) ) pythonw = osp . abspath ( osp . join ( sys . prefix , 'pythonw.exe' ) ) script = osp . abspath ( osp . join ( sys . prefix , 'scripts' , 'spyder' ) ) if not osp . exists ( script ) : script = osp . abspath ( osp . join ( osp . dirname ( osp . abspath ( __file__ ) ) , 'spyder' ) ) workdir = "%HOMEDRIVE%%HOMEPATH%" import distutils . sysconfig lib_dir = distutils . sysconfig . get_python_lib ( plat_specific = 1 ) ico_dir = osp . join ( lib_dir , 'spyder' , 'windows' ) if not osp . isdir ( ico_dir ) : ico_dir = osp . dirname ( osp . abspath ( __file__ ) ) desc = 'The Scientific Python Development Environment' fname = osp . join ( start_menu , 'Spyder (full).lnk' ) create_shortcut ( python , desc , fname , '"%s"' % script , workdir , osp . join ( ico_dir , 'spyder.ico' ) ) file_created ( fname ) fname = osp . join ( start_menu , 'Spyder-Reset all settings.lnk' ) create_shortcut ( python , 'Reset Spyder settings to defaults' , fname , '"%s" --reset' % script , workdir ) file_created ( fname ) current = True root = winreg . HKEY_CURRENT_USER if current else winreg . HKEY_LOCAL_MACHINE winreg . SetValueEx ( winreg . CreateKey ( root , KEY_C1 % ( "" , EWS ) ) , "" , 0 , winreg . REG_SZ , '"%s" "%s\Scripts\spyder" "%%1"' % ( pythonw , sys . prefix ) ) winreg . SetValueEx ( winreg . CreateKey ( root , KEY_C1 % ( "NoCon" , EWS ) ) , "" , 0 , winreg . REG_SZ , '"%s" "%s\Scripts\spyder" "%%1"' % ( pythonw , sys . prefix ) ) desktop_folder = get_special_folder_path ( "CSIDL_DESKTOPDIRECTORY" ) fname = osp . join ( desktop_folder , 'Spyder.lnk' ) desc = 'The Scientific Python Development Environment' create_shortcut ( pythonw , desc , fname , '"%s"' % script , workdir , osp . join ( ico_dir , 'spyder.ico' ) ) file_created ( fname )
Function executed when running the script with the -install switch