1
# postinstall script for Spyder
2
"""Create Spyder start menu entries"""
8
import _winreg as winreg
10
EWS = "Edit with Spyder"
11
KEY_C = r"Software\Classes\%s"
12
KEY_C0 = KEY_C % r"Python.%sFile\shell\%s"
13
KEY_C1 = KEY_C0 + r"\command"
16
"""Function executed when running the script with the -install switch"""
17
# Create Spyder start menu folder
18
start_menu = osp.join(get_special_folder_path('CSIDL_COMMON_PROGRAMS'),
19
'Spyder (Py%i.%i %i bit)' % (sys.version_info[0],
21
struct.calcsize('P')*8))
22
if not osp.isdir(start_menu):
24
directory_created(start_menu)
26
# Create Spyder start menu entries
27
python = osp.abspath(osp.join(sys.prefix, 'python.exe'))
28
pythonw = osp.abspath(osp.join(sys.prefix, 'pythonw.exe'))
29
script = osp.abspath(osp.join(sys.prefix, 'scripts', 'spyder'))
30
workdir = "%HOMEDRIVE%%HOMEPATH%"
31
import distutils.sysconfig
32
lib_dir = distutils.sysconfig.get_python_lib(plat_specific=1)
33
ico_dir = osp.join(lib_dir, 'spyderlib', 'windows')
35
desc = 'Scientific Python Development EnvironmEnt, an alternative to IDLE'
36
fname = osp.join(start_menu, 'Spyder (full).lnk')
37
create_shortcut(python, desc, fname, '"%s"' % script, workdir,
38
osp.join(ico_dir, 'spyder.ico'))
41
desc += '. Light configuration: console and variable explorer only.'
42
fname = osp.join(start_menu, 'Spyder (light).lnk')
43
create_shortcut(python, desc, fname,
44
'"%s" --light' % script, workdir,
45
osp.join(ico_dir, 'spyder_light.ico'))
48
fname = osp.join(start_menu, 'Spyder-Reset all settings.lnk')
49
create_shortcut(python, 'Reset Spyder settings to defaults',
50
fname, '"%s" --reset' % script, workdir)
53
current = True # only affects current user
54
root = winreg.HKEY_CURRENT_USER if current else winreg.HKEY_LOCAL_MACHINE
55
winreg.SetValueEx(winreg.CreateKey(root, KEY_C1 % ("", EWS)),
57
'"%s" "%s\Scripts\spyder" "%%1"' % (pythonw, sys.prefix))
58
winreg.SetValueEx(winreg.CreateKey(root, KEY_C1 % ("NoCon", EWS)),
60
'"%s" "%s\Scripts\spyder" "%%1"' % (pythonw, sys.prefix))
64
"""Function executed when running the script with the -install switch"""
65
current = True # only affects current user
66
root = winreg.HKEY_CURRENT_USER if current else winreg.HKEY_LOCAL_MACHINE
67
for key in (KEY_C1 % ("", EWS), KEY_C1 % ("NoCon", EWS),
68
KEY_C0 % ("", EWS), KEY_C0 % ("NoCon", EWS)):
70
winreg.DeleteKey(root, key)
75
if __name__=='__main__':
77
if sys.argv[1] == '-install':
81
print >>sys.stderr, "Failed to create Start Menu items, "\
82
"try running installer as administrator."
83
elif sys.argv[1] == '-remove':
86
print >>sys.stderr, "Unknown command line option %s" % sys.argv[1]
1
# postinstall script for Spyder
2
"""Create Spyder start menu entries"""
4
from __future__ import print_function
12
import _winreg as winreg
18
EWS = "Edit with Spyder"
19
KEY_C = r"Software\Classes\%s"
20
KEY_C0 = KEY_C % r"Python.%sFile\shell\%s"
21
KEY_C1 = KEY_C0 + r"\command"
24
"""Function executed when running the script with the -install switch"""
25
# Create Spyder start menu folder
26
start_menu = osp.join(get_special_folder_path('CSIDL_COMMON_PROGRAMS'),
27
'Spyder (Py%i.%i %i bit)' % (sys.version_info[0],
29
struct.calcsize('P')*8))
30
if not osp.isdir(start_menu):
32
directory_created(start_menu)
34
# Create Spyder start menu entries
35
python = osp.abspath(osp.join(sys.prefix, 'python.exe'))
36
pythonw = osp.abspath(osp.join(sys.prefix, 'pythonw.exe'))
37
script = osp.abspath(osp.join(sys.prefix, 'scripts', 'spyder'))
38
workdir = "%HOMEDRIVE%%HOMEPATH%"
39
import distutils.sysconfig
40
lib_dir = distutils.sysconfig.get_python_lib(plat_specific=1)
41
ico_dir = osp.join(lib_dir, 'spyderlib', 'windows')
43
desc = 'Scientific Python Development EnvironmEnt, an alternative to IDLE'
44
fname = osp.join(start_menu, 'Spyder (full).lnk')
45
create_shortcut(python, desc, fname, '"%s"' % script, workdir,
46
osp.join(ico_dir, 'spyder.ico'))
49
desc += '. Light configuration: console and variable explorer only.'
50
fname = osp.join(start_menu, 'Spyder (light).lnk')
51
create_shortcut(python, desc, fname,
52
'"%s" --light' % script, workdir,
53
osp.join(ico_dir, 'spyder_light.ico'))
56
fname = osp.join(start_menu, 'Spyder-Reset all settings.lnk')
57
create_shortcut(python, 'Reset Spyder settings to defaults',
58
fname, '"%s" --reset' % script, workdir)
61
current = True # only affects current user
62
root = winreg.HKEY_CURRENT_USER if current else winreg.HKEY_LOCAL_MACHINE
63
winreg.SetValueEx(winreg.CreateKey(root, KEY_C1 % ("", EWS)),
65
'"%s" "%s\Scripts\spyder" "%%1"' % (pythonw, sys.prefix))
66
winreg.SetValueEx(winreg.CreateKey(root, KEY_C1 % ("NoCon", EWS)),
68
'"%s" "%s\Scripts\spyder" "%%1"' % (pythonw, sys.prefix))
72
"""Function executed when running the script with the -install switch"""
73
current = True # only affects current user
74
root = winreg.HKEY_CURRENT_USER if current else winreg.HKEY_LOCAL_MACHINE
75
for key in (KEY_C1 % ("", EWS), KEY_C1 % ("NoCon", EWS),
76
KEY_C0 % ("", EWS), KEY_C0 % ("NoCon", EWS)):
78
winreg.DeleteKey(root, key)
83
if __name__=='__main__':
85
if sys.argv[1] == '-install':
89
print("Failed to create Start Menu items, try running "\
90
"installer as administrator.", file=sys.stderr)
91
elif sys.argv[1] == '-remove':
94
print("Unknown command line option %s" % sys.argv[1],