##// END OF EJS Templates
Merge pull request #1128 from minrk/pylab...
Min RK -
r5708:d6447c1d merge
parent child Browse files
Show More
@@ -1,142 +1,142 b''
1 1 #!python
2 2 """Windows-specific part of the installation"""
3 3
4 4 from __future__ import print_function
5 5
6 6 import os, sys, shutil
7 7 pjoin = os.path.join
8 8
9 9 # import setuptools if we can
10 10 try:
11 11 import setuptools
12 12 except ImportError:
13 13 pass
14 14
15 15
16 16 def mkshortcut(target,description,link_file,*args,**kw):
17 17 """make a shortcut if it doesn't exist, and register its creation"""
18 18
19 19 create_shortcut(target, description, link_file,*args,**kw)
20 20 file_created(link_file)
21 21
22 22 def suffix(s):
23 23 """add '3' suffix to programs for Python 3"""
24 24 if sys.version_info[0] == 3:
25 25 s = s+'3'
26 26 return s
27 27
28 28 def install():
29 29 """Routine to be run by the win32 installer with the -install switch."""
30 30
31 31 # Get some system constants
32 32 prefix = sys.prefix
33 33 python = pjoin(prefix, 'python.exe')
34 34 pythonw = pjoin(prefix, 'pythonw.exe')
35 35 have_setuptools = 'setuptools' in sys.modules
36 36
37 37 if not have_setuptools:
38 38 # This currently doesn't work without setuptools,
39 39 # so don't bother making broken links
40 40 return
41 41
42 42 # Lookup path to common startmenu ...
43 43 ip_start_menu = pjoin(get_special_folder_path('CSIDL_COMMON_PROGRAMS'),
44 44 'IPython (Py%i.%i %i bit)' % (sys.version_info[0],
45 45 sys.version_info[1],
46 46 8*tuple.__itemsize__))
47 47 # Create IPython entry ...
48 48 if not os.path.isdir(ip_start_menu):
49 49 os.mkdir(ip_start_menu)
50 50 directory_created(ip_start_menu)
51 51
52 52 # Create .py and .bat files to make things available from
53 53 # the Windows command line. Thanks to the Twisted project
54 54 # for this logic!
55 55 programs = [
56 56 'ipython',
57 57 'iptest',
58 58 'ipcontroller',
59 59 'ipengine',
60 60 'ipcluster',
61 61 'irunner'
62 62 ]
63 63 programs = [ suffix(p) for p in programs ]
64 64 scripts = pjoin(prefix,'scripts')
65 65 if not have_setuptools:
66 66 # only create .bat files if we don't have setuptools
67 67 for program in programs:
68 68 raw = pjoin(scripts, program)
69 69 bat = raw + '.bat'
70 70 py = raw + '.py'
71 71 # Create .py versions of the scripts
72 72 shutil.copy(raw, py)
73 73 # Create .bat files for each of the scripts
74 74 bat_file = file(bat,'w')
75 75 bat_file.write("@%s %s %%*" % (python, py))
76 76 bat_file.close()
77 77
78 78 # Now move onto setting the Start Menu up
79 79 ipybase = suffix(pjoin(scripts, 'ipython'))
80 80 if have_setuptools:
81 81 # let setuptools take care of the scripts:
82 82 ipybase = ipybase + '-script.py'
83 83 workdir = "%HOMEDRIVE%%HOMEPATH%"
84 84
85 85 link = pjoin(ip_start_menu, 'IPython.lnk')
86 86 cmd = '"%s"' % ipybase
87 87 mkshortcut(python, 'IPython', link, cmd, workdir)
88 88
89 89 # Disable pysh Start item until the profile restores functionality
90 90 # Most of this code is in IPython/deathrow, and needs to be updated
91 91 # to 0.11 APIs
92 92
93 93 # link = pjoin(ip_start_menu, 'pysh.lnk')
94 94 # cmd = '"%s" profile=pysh --init' % ipybase
95 95 # mkshortcut(python, 'IPython (command prompt mode)', link, cmd, workdir)
96 96
97 97 link = pjoin(ip_start_menu, 'pylab.lnk')
98 cmd = '"%s" profile=pylab --init' % ipybase
99 mkshortcut(python, 'IPython (pylab profile)', link, cmd, workdir)
98 cmd = '"%s" --pylab' % ipybase
99 mkshortcut(python, 'IPython (pylab mode)', link, cmd, workdir)
100 100
101 101 link = pjoin(ip_start_menu, 'ipcontroller.lnk')
102 102 cmdbase = suffix(pjoin(scripts, 'ipcontroller'))
103 103 if have_setuptools:
104 104 cmdbase += '-script.py'
105 105 cmd = '"%s"' % cmdbase
106 106 mkshortcut(python, 'IPython controller', link, cmd, workdir)
107 107
108 108 link = pjoin(ip_start_menu, 'ipengine.lnk')
109 109 cmdbase = suffix(pjoin(scripts, 'ipengine'))
110 110 if have_setuptools:
111 111 cmdbase += '-script.py'
112 112 cmd = '"%s"' % cmdbase
113 113 mkshortcut(python, 'IPython engine', link, cmd, workdir)
114 114
115 115 link = pjoin(ip_start_menu, 'ipythonqt.lnk')
116 116 cmdbase = suffix(pjoin(scripts, 'ipython')) + '-qtconsole'
117 117 if have_setuptools:
118 118 cmdbase += '-script.pyw'
119 119 cmd = '"%s"' % cmdbase
120 120 mkshortcut(pythonw, 'IPython Qt Console', link, cmd, workdir)
121 121 # Create documentation shortcuts ...
122 122 t = prefix + r'\share\doc\ipython\manual\index.html'
123 123 f = ip_start_menu + r'\Manual in HTML.lnk'
124 124 mkshortcut(t,'IPython Manual - HTML-Format',f)
125 125
126 126
127 127 def remove():
128 128 """Routine to be run by the win32 installer with the -remove switch."""
129 129 pass
130 130
131 131
132 132 # main()
133 133 if len(sys.argv) > 1:
134 134 if sys.argv[1] == '-install':
135 135 try:
136 136 install()
137 137 except OSError:
138 138 print("Failed to create Start Menu items, try running installer as administrator.", file=sys.stderr)
139 139 elif sys.argv[1] == '-remove':
140 140 remove()
141 141 else:
142 142 print("Script was called with option %s" % sys.argv[1], file=sys.stderr)
1 NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now