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