forked from ipython/ipython
-
Notifications
You must be signed in to change notification settings - Fork 2
/
ipython_win_post_install.py
executable file
·85 lines (67 loc) · 2.63 KB
/
ipython_win_post_install.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!python
"""Windows-specific part of the installation"""
import os, sys, shutil
def mkshortcut(target,description,link_file,*args,**kw):
"""make a shortcut if it doesn't exist, and register its creation"""
create_shortcut(target, description, link_file,*args,**kw)
file_created(link_file)
def install():
"""Routine to be run by the win32 installer with the -install switch."""
from IPython.Release import version
# Get some system constants
prefix = sys.prefix
python = prefix + r'\python.exe'
# Lookup path to common startmenu ...
ip_dir = get_special_folder_path('CSIDL_COMMON_PROGRAMS') + r'\IPython'
# Some usability warnings at installation time. I don't want them at the
# top-level, so they don't appear if the user is uninstalling.
try:
import ctypes
except ImportError:
print ('To take full advantage of IPython, you need ctypes from:\n'
'http://sourceforge.net/projects/ctypes')
try:
import win32con
except ImportError:
print ('To take full advantage of IPython, you need pywin32 from:\n'
'http://starship.python.net/crew/mhammond/win32/Downloads.html')
try:
import readline
except ImportError:
print ('To take full advantage of IPython, you need readline from:\n'
'http://sourceforge.net/projects/uncpythontools')
ipybase = '"'+prefix+r'\scripts\ipython"'
# Create IPython entry ...
if not os.path.isdir(ip_dir):
os.mkdir(ip_dir)
directory_created(ip_dir)
# Create program shortcuts ...
f = ip_dir + r'\IPython.lnk'
a = ipybase
mkshortcut(python,'IPython',f,a)
f = ip_dir + r'\pysh.lnk'
a = ipybase+' -p sh'
mkshortcut(python,'IPython command prompt mode',f,a)
f = ip_dir + r'\scipy.lnk'
a = ipybase+' -pylab -p scipy'
mkshortcut(python,'IPython scipy profile',f,a)
# Create documentation shortcuts ...
t = prefix + r'\share\doc\ipython\manual\ipython.pdf'
f = ip_dir + r'\Manual in PDF.lnk'
mkshortcut(t,r'IPython Manual - PDF-Format',f)
t = prefix + r'\share\doc\ipython\manual\ipython.html'
f = ip_dir + r'\Manual in HTML.lnk'
mkshortcut(t,'IPython Manual - HTML-Format',f)
# make ipython.py
shutil.copy(prefix + r'\scripts\ipython', prefix + r'\scripts\ipython.py')
def remove():
"""Routine to be run by the win32 installer with the -remove switch."""
pass
# main()
if len(sys.argv) > 1:
if sys.argv[1] == '-install':
install()
elif sys.argv[1] == '-remove':
remove()
else:
print "Script was called with option %s" % sys.argv[1]