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