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