##// END OF EJS Templates
Merge pull request #2635 from cgohlke/windows-startmenu...
Min RK -
r10211:e9bfcd71 merge
parent child Browse files
Show More
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
@@ -1,56 +1,79 b''
1 #!python
1 #!python
2 """Windows-specific part of the installation"""
2 """Distutils post installation script for Windows.
3
4 http://docs.python.org/2/distutils/builtdist.html#the-postinstallation-script
5
6 """
3
7
4 from __future__ import print_function
8 from __future__ import print_function
5
9
6 import os, sys, shutil
10 import os
7 pjoin = os.path.join
11 import sys
12 import shutil
8
13
9 # import setuptools if we can
10 try:
14 try:
11 import setuptools
15 import setuptools
16 have_setuptools = True
12 except ImportError:
17 except ImportError:
13 pass
18 have_setuptools = False
19
20
21 pjoin = os.path.join
22
23 # suffix for start menu folder names
24 pyver = "(Py%i.%i %i bit)" % (sys.version_info[0], sys.version_info[1],
25 (32, 64)[sys.maxsize > 2**32])
14
26
15
27
16 def mkshortcut(target,description,link_file,*args,**kw):
28 def mkshortcut(target, description, linkdir, arguments="", iconpath='',
17 """make a shortcut if it doesn't exist, and register its creation"""
29 workdir="%HOMEDRIVE%%HOMEPATH%", iconindex=0):
18
30 """Make a shortcut if it doesn't exist and register its creation."""
19 create_shortcut(target, description, link_file,*args,**kw)
31 filename = pjoin(linkdir, description + '.lnk')
20 file_created(link_file)
32 description = "%s %s" % (description, pyver)
33 create_shortcut(target, description, filename, arguments, workdir,
34 iconpath, iconindex)
35 file_created(filename)
36
37
38 def arguments(scriptsdir, script, scriptargs=''):
39 """Return command line arguments to be passed to the python executable."""
40 cmdbase = suffix(pjoin(scriptsdir, script))
41 if have_setuptools:
42 cmdbase += '-script.py'
43 return '"%s" %s' % (cmdbase, scriptargs)
44
21
45
22 def suffix(s):
46 def suffix(s):
23 """add '3' suffix to programs for Python 3"""
47 """Add '3' suffix to programs for Python 3."""
24 if sys.version_info[0] == 3:
48 if sys.version_info[0] == 3:
25 s = s+'3'
49 s = s + '3'
26 return s
50 return s
27
51
52
28 def install():
53 def install():
29 """Routine to be run by the win32 installer with the -install switch."""
54 """Routine to be run by the win32 installer with the -install switch."""
30
31 # Get some system constants
55 # Get some system constants
32 prefix = sys.prefix
56 python = pjoin(sys.prefix, 'python.exe')
33 python = pjoin(prefix, 'python.exe')
57 pythonw = pjoin(sys.prefix, 'pythonw.exe')
34 pythonw = pjoin(prefix, 'pythonw.exe')
58
35 have_setuptools = 'setuptools' in sys.modules
36
37 if not have_setuptools:
59 if not have_setuptools:
38 # This currently doesn't work without setuptools,
60 # This currently doesn't work without setuptools,
39 # so don't bother making broken links
61 # so don't bother making broken links
40 print("Distribute (setuptools) is required to create Start Menu items.", file=sys.stderr)
62 print("Distribute (setuptools) is required to"
41 print("Re-run this installer after installing distribute to get Start Menu items.", file=sys.stderr)
63 " create Start Menu items.", file=sys.stderr)
64 print("Re-run this installer after installing"
65 " distribute to get Start Menu items.", file=sys.stderr)
42 return
66 return
43
67
44 # Lookup path to common startmenu ...
68 # Lookup path to common startmenu ...
45 ip_start_menu = pjoin(get_special_folder_path('CSIDL_COMMON_PROGRAMS'),
69 ip_start_menu = pjoin(get_special_folder_path('CSIDL_COMMON_PROGRAMS'),
46 'IPython (Py%i.%i %i bit)' % (sys.version_info[0],
70 'IPython %s' % pyver)
47 sys.version_info[1],
71
48 8*tuple.__itemsize__))
49 # Create IPython entry ...
72 # Create IPython entry ...
50 if not os.path.isdir(ip_start_menu):
73 if not os.path.isdir(ip_start_menu):
51 os.mkdir(ip_start_menu)
74 os.mkdir(ip_start_menu)
52 directory_created(ip_start_menu)
75 directory_created(ip_start_menu)
53
76
54 # Create .py and .bat files to make things available from
77 # Create .py and .bat files to make things available from
55 # the Windows command line. Thanks to the Twisted project
78 # the Windows command line. Thanks to the Twisted project
56 # for this logic!
79 # for this logic!
@@ -60,10 +83,10 b' def install():'
60 'ipcontroller',
83 'ipcontroller',
61 'ipengine',
84 'ipengine',
62 'ipcluster',
85 'ipcluster',
63 'irunner'
86 'irunner',
64 ]
87 ]
65 programs = [ suffix(p) for p in programs ]
88 programs = [suffix(p) for p in programs]
66 scripts = pjoin(prefix,'scripts')
89 scripts = pjoin(sys.prefix, 'scripts')
67 if not have_setuptools:
90 if not have_setuptools:
68 # only create .bat files if we don't have setuptools
91 # only create .bat files if we don't have setuptools
69 for program in programs:
92 for program in programs:
@@ -73,66 +96,38 b' def install():'
73 # Create .py versions of the scripts
96 # Create .py versions of the scripts
74 shutil.copy(raw, py)
97 shutil.copy(raw, py)
75 # Create .bat files for each of the scripts
98 # Create .bat files for each of the scripts
76 bat_file = file(bat,'w')
99 bat_file = file(bat, 'w')
77 bat_file.write("@%s %s %%*" % (python, py))
100 bat_file.write("@%s %s %%*" % (python, py))
78 bat_file.close()
101 bat_file.close()
79
102
80 # Now move onto setting the Start Menu up
103 # Create Start Menu shortcuts
81 ipybase = suffix(pjoin(scripts, 'ipython'))
104 iconpath = pjoin(scripts, 'ipython.ico')
82 if have_setuptools:
105 mkshortcut(python, 'IPython', ip_start_menu,
83 # let setuptools take care of the scripts:
106 arguments(scripts, 'ipython'), iconpath)
84 ipybase = ipybase + '-script.py'
107 mkshortcut(python, 'IPython (pylab mode)', ip_start_menu,
85 workdir = "%HOMEDRIVE%%HOMEPATH%"
108 arguments(scripts, 'ipython', '--pylab'), iconpath)
86
109 mkshortcut(python, 'IPython Controller', ip_start_menu,
87 link = pjoin(ip_start_menu, 'IPython.lnk')
110 arguments(scripts, 'ipcontroller'), iconpath)
88 cmd = '"%s"' % ipybase
111 mkshortcut(python, 'IPython Engine', ip_start_menu,
89 mkshortcut(python, 'IPython', link, cmd, workdir)
112 arguments(scripts, 'ipengine'), iconpath)
90
113 mkshortcut(pythonw, 'IPython Qt Console', ip_start_menu,
114 arguments(scripts, 'ipython', 'qtconsole'), iconpath)
115
116 iconpath = pjoin(scripts, 'ipython_nb.ico')
117 mkshortcut(python, 'IPython Notebook', ip_start_menu,
118 arguments(scripts, 'ipython', 'notebook'), iconpath)
119
120 mkshortcut(pythonw, 'IPython Documentation', ip_start_menu,
121 '-m webbrowser -t "http://ipython.org/documentation.html',
122 iconpath='url.dll')
123
91 # Disable pysh Start item until the profile restores functionality
124 # Disable pysh Start item until the profile restores functionality
92 # Most of this code is in IPython/deathrow, and needs to be updated
125 # Most of this code is in IPython/deathrow, and needs to be updated
93 # to 0.11 APIs
126 # to 0.11 APIs
94
127 #mkshortcut(python, 'IPython%s (command prompt mode)', ip_start_menu,
95 # link = pjoin(ip_start_menu, 'pysh.lnk')
128 # arguments(scripts, 'ipython', 'profile=pysh --init'))
96 # cmd = '"%s" profile=pysh --init' % ipybase
129
97 # mkshortcut(python, 'IPython (command prompt mode)', link, cmd, workdir)
98
99 link = pjoin(ip_start_menu, 'pylab.lnk')
100 cmd = '"%s" --pylab' % ipybase
101 mkshortcut(python, 'IPython (pylab mode)', link, cmd, workdir)
102
103 link = pjoin(ip_start_menu, 'ipcontroller.lnk')
104 cmdbase = suffix(pjoin(scripts, 'ipcontroller'))
105 if have_setuptools:
106 cmdbase += '-script.py'
107 cmd = '"%s"' % cmdbase
108 mkshortcut(python, 'IPython controller', link, cmd, workdir)
109
110 link = pjoin(ip_start_menu, 'ipengine.lnk')
111 cmdbase = suffix(pjoin(scripts, 'ipengine'))
112 if have_setuptools:
113 cmdbase += '-script.py'
114 cmd = '"%s"' % cmdbase
115 mkshortcut(python, 'IPython engine', link, cmd, workdir)
116
130
117 link = pjoin(ip_start_menu, 'ipythonqt.lnk')
118 cmdbase = suffix(pjoin(scripts, 'ipython'))
119 if have_setuptools:
120 cmdbase += '-script.py'
121 cmd = '"%s" qtconsole' % cmdbase
122 mkshortcut(pythonw, 'IPython Qt Console', link, cmd, workdir)
123
124 # FIXME: These below are commented out because we don't ship the html built
125 # docs anymore. We should make the shortcut to continue existing, but as a
126 # URL to the online the docs for the right version of IPython. The stable
127 # URLs have the pattern:
128 # http://ipython.org/ipython-doc/rel-X.Y.Z/html
129 # For IPython version X.Y.Z.
130
131 ## # Create documentation shortcuts ...
132 ## t = prefix + r'\share\doc\ipython\manual\index.html'
133 ## f = ip_start_menu + r'\Manual in HTML.lnk'
134 ## mkshortcut(t,'IPython Manual - HTML-Format',f)
135
136 def remove():
131 def remove():
137 """Routine to be run by the win32 installer with the -remove switch."""
132 """Routine to be run by the win32 installer with the -remove switch."""
138 pass
133 pass
@@ -144,8 +139,10 b' if len(sys.argv) > 1:'
144 try:
139 try:
145 install()
140 install()
146 except OSError:
141 except OSError:
147 print("Failed to create Start Menu items, try running installer as administrator.", file=sys.stderr)
142 print("Failed to create Start Menu items, try running the"
143 " installer as administrator.", file=sys.stderr)
148 elif sys.argv[1] == '-remove':
144 elif sys.argv[1] == '-remove':
149 remove()
145 remove()
150 else:
146 else:
151 print("Script was called with option %s" % sys.argv[1], file=sys.stderr)
147 print("Script was called with option %s" % sys.argv[1],
148 file=sys.stderr)
@@ -174,7 +174,7 b' from distutils.command.sdist import sdist'
174 from distutils.command.upload import upload
174 from distutils.command.upload import upload
175
175
176 class UploadWindowsInstallers(upload):
176 class UploadWindowsInstallers(upload):
177
177
178 description = "Upload Windows installers to PyPI (only used from tools/release_windows.py)"
178 description = "Upload Windows installers to PyPI (only used from tools/release_windows.py)"
179 user_options = upload.user_options + [
179 user_options = upload.user_options + [
180 ('files=', 'f', 'exe file (or glob) to upload')
180 ('files=', 'f', 'exe file (or glob) to upload')
@@ -187,7 +187,7 b' class UploadWindowsInstallers(upload):'
187 version=meta.get_version()
187 version=meta.get_version()
188 )
188 )
189 self.files = os.path.join('dist', '%s.*.exe' % base)
189 self.files = os.path.join('dist', '%s.*.exe' % base)
190
190
191 def run(self):
191 def run(self):
192 for dist_file in glob(self.files):
192 for dist_file in glob(self.files):
193 self.upload_file('bdist_wininst', 'any', dist_file)
193 self.upload_file('bdist_wininst', 'any', dist_file)
@@ -256,11 +256,13 b" if 'setuptools' in sys.modules:"
256 ('sdist' in sys.argv or 'bdist_rpm' in sys.argv):
256 ('sdist' in sys.argv or 'bdist_rpm' in sys.argv):
257 print >> sys.stderr, "ERROR: bdist_wininst must be run alone. Exiting."
257 print >> sys.stderr, "ERROR: bdist_wininst must be run alone. Exiting."
258 sys.exit(1)
258 sys.exit(1)
259 setup_args['data_files'].append(
260 ['Scripts', ('scripts/ipython.ico', 'scripts/ipython_nb.ico')])
259 setup_args['scripts'] = [pjoin('scripts','ipython_win_post_install.py')]
261 setup_args['scripts'] = [pjoin('scripts','ipython_win_post_install.py')]
260 setup_args['options'] = {"bdist_wininst":
262 setup_args['options'] = {"bdist_wininst":
261 {"install_script":
263 {"install_script":
262 "ipython_win_post_install.py"}}
264 "ipython_win_post_install.py"}}
263
265
264 if PY3:
266 if PY3:
265 setuptools_extra_args['use_2to3'] = True
267 setuptools_extra_args['use_2to3'] = True
266 # we try to make a 2.6, 2.7, and 3.1 to 3.3 python compatible code
268 # we try to make a 2.6, 2.7, and 3.1 to 3.3 python compatible code
General Comments 0
You need to be logged in to leave comments. Login now