##// END OF EJS Templates
fix backslash issues
fperez -
Show More
@@ -1,135 +1,136 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
4 import os, sys
5
5
6 try:
6 try:
7 import shutil,pythoncom
7 import shutil,pythoncom
8 from win32com.shell import shell
8 from win32com.shell import shell
9 import _winreg as wreg
9 import _winreg as wreg
10 except ImportError:
10 except ImportError:
11 print """
11 print """
12 You seem to be missing the PythonWin extensions necessary for automatic
12 You seem to be missing the PythonWin extensions necessary for automatic
13 installation. You can get them (free) from
13 installation. You can get them (free) from
14 http://starship.python.net/crew/mhammond/
14 http://starship.python.net/crew/mhammond/
15
15
16 Please see the manual for details if you want to finish the installation by
16 Please see the manual for details if you want to finish the installation by
17 hand, or get PythonWin and repeat the procedure.
17 hand, or get PythonWin and repeat the procedure.
18
18
19 Press <Enter> to exit this installer."""
19 Press <Enter> to exit this installer."""
20 raw_input()
20 raw_input()
21 sys.exit()
21 sys.exit()
22
22
23
23
24 def make_shortcut(fname,target,args='',start_in='',comment='',icon=None):
24 def make_shortcut(fname,target,args='',start_in='',comment='',icon=None):
25 """Make a Windows shortcut (.lnk) file.
25 """Make a Windows shortcut (.lnk) file.
26
26
27 make_shortcut(fname,target,args='',start_in='',comment='',icon=None)
27 make_shortcut(fname,target,args='',start_in='',comment='',icon=None)
28
28
29 Arguments:
29 Arguments:
30 fname - name of the final shortcut file (include the .lnk)
30 fname - name of the final shortcut file (include the .lnk)
31 target - what the shortcut will point to
31 target - what the shortcut will point to
32 args - additional arguments to pass to the target program
32 args - additional arguments to pass to the target program
33 start_in - directory where the target command will be called
33 start_in - directory where the target command will be called
34 comment - for the popup tooltips
34 comment - for the popup tooltips
35 icon - optional icon file. This must be a tuple of the type
35 icon - optional icon file. This must be a tuple of the type
36 (icon_file,index), where index is the index of the icon you want
36 (icon_file,index), where index is the index of the icon you want
37 in the file. For single .ico files, index=0, but for icon libraries
37 in the file. For single .ico files, index=0, but for icon libraries
38 contained in a single file it can be >0.
38 contained in a single file it can be >0.
39 """
39 """
40
40
41 shortcut = pythoncom.CoCreateInstance(
41 shortcut = pythoncom.CoCreateInstance(
42 shell.CLSID_ShellLink, None,
42 shell.CLSID_ShellLink, None,
43 pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink
43 pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink
44 )
44 )
45 shortcut.SetPath(target)
45 shortcut.SetPath(target)
46 shortcut.SetArguments(args)
46 shortcut.SetArguments(args)
47 shortcut.SetWorkingDirectory(start_in)
47 shortcut.SetWorkingDirectory(start_in)
48 shortcut.SetDescription(comment)
48 shortcut.SetDescription(comment)
49 if icon:
49 if icon:
50 shortcut.SetIconLocation(*icon)
50 shortcut.SetIconLocation(*icon)
51 shortcut.QueryInterface(pythoncom.IID_IPersistFile).Save(fname,0)
51 shortcut.QueryInterface(pythoncom.IID_IPersistFile).Save(fname,0)
52
52
53
53
54 def run(wait=0):
54 def run(wait=0):
55 # Find where the Start Menu and My Documents are on the filesystem
55 # Find where the Start Menu and My Documents are on the filesystem
56 key = wreg.OpenKey(wreg.HKEY_CURRENT_USER,
56 key = wreg.OpenKey(wreg.HKEY_CURRENT_USER,
57 r'Software\Microsoft\Windows\CurrentVersion'
57 r'Software\Microsoft\Windows\CurrentVersion'
58 r'\Explorer\Shell Folders')
58 r'\Explorer\Shell Folders')
59
59
60 programs_dir = wreg.QueryValueEx(key,'Programs')[0]
60 programs_dir = wreg.QueryValueEx(key,'Programs')[0]
61 my_documents_dir = wreg.QueryValueEx(key,'Personal')[0]
61 my_documents_dir = wreg.QueryValueEx(key,'Personal')[0]
62 key.Close()
62 key.Close()
63
63
64 # Find where the 'program files' directory is
64 # Find where the 'program files' directory is
65 key = wreg.OpenKey(wreg.HKEY_LOCAL_MACHINE,
65 key = wreg.OpenKey(wreg.HKEY_LOCAL_MACHINE,
66 r'SOFTWARE\Microsoft\Windows\CurrentVersion')
66 r'SOFTWARE\Microsoft\Windows\CurrentVersion')
67
67
68 program_files_dir = wreg.QueryValueEx(key,'ProgramFilesDir')[0]
68 program_files_dir = wreg.QueryValueEx(key,'ProgramFilesDir')[0]
69 key.Close()
69 key.Close()
70
70
71
71
72 # File and directory names
72 # File and directory names
73 ip_dir = program_files_dir + '\\IPython'
73 ip_dir = program_files_dir + r'\IPython'
74 ip_prog_dir = programs_dir + '\\IPython'
74 ip_prog_dir = programs_dir + r'\IPython'
75 doc_dir = ip_dir+'\\doc'
75 doc_dir = ip_dir+r'\doc'
76 ip_filename = ip_dir+'\\IPython_shell.py'
76 ip_filename = ip_dir+r'\IPython_shell.py'
77 pycon_icon = doc_dir+'\\pycon.ico'
77 pycon_icon = doc_dir+r'\pycon.ico'
78
78
79 if not os.path.isdir(ip_dir):
79 if not os.path.isdir(ip_dir):
80 os.mkdir(ip_dir)
80 os.mkdir(ip_dir)
81
81
82 # Copy startup script and documentation
82 # Copy startup script and documentation
83 shutil.copy(sys.prefix+'\\Scripts\\ipython',ip_filename)
83 shutil.copy(sys.prefix+r'\Scripts\ipython',ip_filename)
84 if os.path.isdir(doc_dir):
84 if os.path.isdir(doc_dir):
85 shutil.rmtree(doc_dir)
85 shutil.rmtree(doc_dir)
86 shutil.copytree('doc',doc_dir)
86 shutil.copytree('doc',doc_dir)
87
87
88 # make shortcuts for IPython, html and pdf docs.
88 # make shortcuts for IPython, html and pdf docs.
89 print 'Making entries for IPython in Start Menu...',
89 print 'Making entries for IPython in Start Menu...',
90
90
91 # Create .bat file in \\Scripts
91 # Create .bat file in \Scripts
92 fic = open(sys.prefix + '\\Scripts\\ipython.bat','w')
92 fic = open(sys.prefix + r'\Scripts\ipython.bat','w')
93 fic.write('"' + sys.prefix + '\\python.exe' + '" -i ' + '"' + sys.prefix + '\\Scripts\ipython" %*')
93 fic.write('"' + sys.prefix + r'\python.exe' + '" -i ' + '"' +
94 sys.prefix + r'\Scripts\ipython" %*')
94 fic.close()
95 fic.close()
95
96
96 # Create shortcuts in Programs\IPython:
97 # Create shortcuts in Programs\IPython:
97 if not os.path.isdir(ip_prog_dir):
98 if not os.path.isdir(ip_prog_dir):
98 os.mkdir(ip_prog_dir)
99 os.mkdir(ip_prog_dir)
99 os.chdir(ip_prog_dir)
100 os.chdir(ip_prog_dir)
100
101
101 man_pdf = doc_dir + '\\manual.pdf'
102 man_pdf = doc_dir + r'\manual.pdf'
102 man_htm = doc_dir + '\\manual\\manual.html'
103 man_htm = doc_dir + r'\manual\manual.html'
103
104
104 make_shortcut('IPython.lnk',sys.executable, '"%s"' % ip_filename,
105 make_shortcut('IPython.lnk',sys.executable, '"%s"' % ip_filename,
105 my_documents_dir,
106 my_documents_dir,
106 'IPython - Enhanced python command line interpreter',
107 'IPython - Enhanced python command line interpreter',
107 (pycon_icon,0))
108 (pycon_icon,0))
108 make_shortcut('pysh.lnk',sys.executable, '"%s" -p pysh' % ip_filename,
109 make_shortcut('pysh.lnk',sys.executable, '"%s" -p pysh' % ip_filename,
109 my_documents_dir,
110 my_documents_dir,
110 'pysh - a system shell with Python syntax (IPython based)',
111 'pysh - a system shell with Python syntax (IPython based)',
111 (pycon_icon,0))
112 (pycon_icon,0))
112 make_shortcut('Manual in HTML format.lnk',man_htm,'','',
113 make_shortcut('Manual in HTML format.lnk',man_htm,'','',
113 'IPython Manual - HTML format')
114 'IPython Manual - HTML format')
114 make_shortcut('Manual in PDF format.lnk',man_pdf,'','',
115 make_shortcut('Manual in PDF format.lnk',man_pdf,'','',
115 'IPython Manual - PDF format')
116 'IPython Manual - PDF format')
116
117
117 print """Done.
118 print """Done.
118
119
119 I created the directory %s. There you will find the
120 I created the directory %s. There you will find the
120 IPython startup script and manuals.
121 IPython startup script and manuals.
121
122
122 An IPython menu was also created in your Start Menu, with entries for
123 An IPython menu was also created in your Start Menu, with entries for
123 IPython itself and the manual in HTML and PDF formats.
124 IPython itself and the manual in HTML and PDF formats.
124
125
125 For reading PDF documents you need the freely available Adobe Acrobat
126 For reading PDF documents you need the freely available Adobe Acrobat
126 Reader. If you don't have it, you can download it from:
127 Reader. If you don't have it, you can download it from:
127 http://www.adobe.com/products/acrobat/readstep2.html
128 http://www.adobe.com/products/acrobat/readstep2.html
128 """ % ip_dir
129 """ % ip_dir
129
130
130 if wait:
131 if wait:
131 print "Finished with IPython installation. Press Enter to exit this installer.",
132 print "Finished with IPython installation. Press Enter to exit this installer.",
132 raw_input()
133 raw_input()
133
134
134 if __name__ == '__main__':
135 if __name__ == '__main__':
135 run()
136 run()
General Comments 0
You need to be logged in to leave comments. Login now