##// END OF EJS Templates
py3 fixes for win_post_install.py
MinRK -
Show More
@@ -1,6 +1,8 b''
1 1 #!python
2 2 """Windows-specific part of the installation"""
3 3
4 from __future__ import print_function
5
4 6 import os, sys, shutil
5 7 pjoin = os.path.join
6 8
@@ -17,12 +19,15 b' def mkshortcut(target,description,link_file,*args,**kw):'
17 19 create_shortcut(target, description, link_file,*args,**kw)
18 20 file_created(link_file)
19 21
22 def suffix(s):
23 """add '3' suffix to programs for Python 3"""
24 if sys.version_info[0] == 3:
25 s = s+'3'
26 return s
20 27
21 28 def install():
22 29 """Routine to be run by the win32 installer with the -install switch."""
23 30
24 from IPython.core.release import version
25
26 31 # Get some system constants
27 32 prefix = sys.prefix
28 33 python = pjoin(prefix, 'python.exe')
@@ -55,6 +60,7 b' def install():'
55 60 'ipcluster',
56 61 'irunner'
57 62 ]
63 programs = [ suffix(p) for p in programs ]
58 64 scripts = pjoin(prefix,'scripts')
59 65 if not have_setuptools:
60 66 # only create .bat files if we don't have setuptools
@@ -70,7 +76,7 b' def install():'
70 76 bat_file.close()
71 77
72 78 # Now move onto setting the Start Menu up
73 ipybase = pjoin(scripts, 'ipython')
79 ipybase = suffix(pjoin(scripts, 'ipython'))
74 80 if have_setuptools:
75 81 # let setuptools take care of the scripts:
76 82 ipybase = ipybase + '-script.py'
@@ -93,21 +99,21 b' def install():'
93 99 mkshortcut(python, 'IPython (pylab profile)', link, cmd, workdir)
94 100
95 101 link = pjoin(ip_start_menu, 'ipcontroller.lnk')
96 cmdbase = pjoin(scripts, 'ipcontroller')
102 cmdbase = suffix(pjoin(scripts, 'ipcontroller'))
97 103 if have_setuptools:
98 104 cmdbase += '-script.py'
99 105 cmd = '"%s"' % cmdbase
100 106 mkshortcut(python, 'IPython controller', link, cmd, workdir)
101 107
102 108 link = pjoin(ip_start_menu, 'ipengine.lnk')
103 cmdbase = pjoin(scripts, 'ipengine')
109 cmdbase = suffix(pjoin(scripts, 'ipengine'))
104 110 if have_setuptools:
105 111 cmdbase += '-script.py'
106 112 cmd = '"%s"' % cmdbase
107 113 mkshortcut(python, 'IPython engine', link, cmd, workdir)
108 114
109 115 link = pjoin(ip_start_menu, 'ipythonqt.lnk')
110 cmdbase = pjoin(scripts, 'ipython-qtconsole')
116 cmdbase = suffix(pjoin(scripts, 'ipython')) + '-qtconsole'
111 117 if have_setuptools:
112 118 cmdbase += '-script.pyw'
113 119 cmd = '"%s"' % cmdbase
@@ -126,8 +132,11 b' def remove():'
126 132 # main()
127 133 if len(sys.argv) > 1:
128 134 if sys.argv[1] == '-install':
129 install()
135 try:
136 install()
137 except OSError:
138 print("Failed to create Start Menu items, try running installer as administrator.", file=sys.stderr)
130 139 elif sys.argv[1] == '-remove':
131 140 remove()
132 141 else:
133 print "Script was called with option %s" % sys.argv[1]
142 print("Script was called with option %s" % sys.argv[1], file=sys.stderr)
General Comments 0
You need to be logged in to leave comments. Login now