|
@@
-1,51
+1,75
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
|
|
|
|
|
13
|
import platform
|
|
8
|
|
|
14
|
|
|
9
|
# import setuptools if we can
|
|
|
|
|
10
|
try:
|
|
15
|
try:
|
|
11
|
import setuptools
|
|
16
|
import setuptools
|
|
|
|
|
17
|
have_setuptools = True
|
|
12
|
except ImportError:
|
|
18
|
except ImportError:
|
|
13
|
pass
|
|
19
|
have_setuptools = False
|
|
|
|
|
20
|
|
|
|
|
|
21
|
|
|
|
|
|
22
|
pjoin = os.path.join
|
|
|
|
|
23
|
|
|
|
|
|
24
|
# suffix for start menu folder names
|
|
|
|
|
25
|
pyver = "(Py%i.%i %i bit)" % (sys.version_info[0], sys.version_info[1],
|
|
|
|
|
26
|
(32, 64)[sys.maxsize > 2**32])
|
|
14
|
|
|
27
|
|
|
15
|
|
|
28
|
|
|
16
|
def mkshortcut(target,description,link_file,*args,**kw):
|
|
29
|
def mkshortcut(target, description, linkdir, arguments="", iconpath='',
|
|
17
|
"""make a shortcut if it doesn't exist, and register its creation"""
|
|
30
|
workdir="%HOMEDRIVE%%HOMEPATH%", iconindex=0):
|
|
|
|
|
31
|
"""Make a shortcut if it doesn't exist and register its creation."""
|
|
|
|
|
32
|
filename = pjoin(linkdir, description + '.lnk')
|
|
|
|
|
33
|
description = "%s %s" % (description, pyver)
|
|
|
|
|
34
|
create_shortcut(target, description, filename, arguments, workdir,
|
|
|
|
|
35
|
iconpath, iconindex)
|
|
|
|
|
36
|
file_created(filename)
|
|
|
|
|
37
|
|
|
|
|
|
38
|
|
|
|
|
|
39
|
def arguments(scriptsdir, script, scriptargs=''):
|
|
|
|
|
40
|
"""Return command line arguments to be passed to the python executable."""
|
|
|
|
|
41
|
cmdbase = suffix(pjoin(scriptsdir, script))
|
|
|
|
|
42
|
if have_setuptools:
|
|
|
|
|
43
|
cmdbase += '-script.py'
|
|
|
|
|
44
|
return '"%s" %s' % (cmdbase, scriptargs)
|
|
18
|
|
|
45
|
|
|
19
|
create_shortcut(target, description, link_file,*args,**kw)
|
|
|
|
|
20
|
file_created(link_file)
|
|
|
|
|
21
|
|
|
46
|
|
|
22
|
def suffix(s):
|
|
47
|
def suffix(s):
|
|
23
|
"""add '3' suffix to programs for Python 3"""
|
|
48
|
"""Add '3' suffix to programs for Python 3."""
|
|
24
|
if sys.version_info[0] == 3:
|
|
49
|
if sys.version_info[0] == 3:
|
|
25
|
s = s+'3'
|
|
50
|
s = s + '3'
|
|
26
|
return s
|
|
51
|
return s
|
|
27
|
|
|
52
|
|
|
|
|
|
53
|
|
|
28
|
def install():
|
|
54
|
def install():
|
|
29
|
"""Routine to be run by the win32 installer with the -install switch."""
|
|
55
|
"""Routine to be run by the win32 installer with the -install switch."""
|
|
30
|
|
|
|
|
|
31
|
# Get some system constants
|
|
56
|
# Get some system constants
|
|
32
|
prefix = sys.prefix
|
|
57
|
python = pjoin(sys.prefix, 'python.exe')
|
|
33
|
python = pjoin(prefix, 'python.exe')
|
|
58
|
pythonw = pjoin(sys.prefix, 'pythonw.exe')
|
|
34
|
pythonw = pjoin(prefix, 'pythonw.exe')
|
|
|
|
|
35
|
have_setuptools = 'setuptools' in sys.modules
|
|
|
|
|
36
|
|
|
59
|
|
|
37
|
if not have_setuptools:
|
|
60
|
if not have_setuptools:
|
|
38
|
# This currently doesn't work without setuptools,
|
|
61
|
# This currently doesn't work without setuptools,
|
|
39
|
# so don't bother making broken links
|
|
62
|
# so don't bother making broken links
|
|
40
|
print("Distribute (setuptools) is required to create Start Menu items.", file=sys.stderr)
|
|
63
|
print("Distribute (setuptools) is required to"
|
|
41
|
print("Re-run this installer after installing distribute to get Start Menu items.", file=sys.stderr)
|
|
64
|
" create Start Menu items.", file=sys.stderr)
|
|
|
|
|
65
|
print("Re-run this installer after installing"
|
|
|
|
|
66
|
" distribute to get Start Menu items.", file=sys.stderr)
|
|
42
|
return
|
|
67
|
return
|
|
43
|
|
|
68
|
|
|
44
|
# Lookup path to common startmenu ...
|
|
69
|
# Lookup path to common startmenu ...
|
|
45
|
ip_start_menu = pjoin(get_special_folder_path('CSIDL_COMMON_PROGRAMS'),
|
|
70
|
ip_start_menu = pjoin(get_special_folder_path('CSIDL_COMMON_PROGRAMS'),
|
|
46
|
'IPython (Py%i.%i %i bit)' % (sys.version_info[0],
|
|
71
|
'IPython %s' % pyver)
|
|
47
|
sys.version_info[1],
|
|
72
|
|
|
48
|
8*tuple.__itemsize__))
|
|
|
|
|
49
|
# Create IPython entry ...
|
|
73
|
# Create IPython entry ...
|
|
50
|
if not os.path.isdir(ip_start_menu):
|
|
74
|
if not os.path.isdir(ip_start_menu):
|
|
51
|
os.mkdir(ip_start_menu)
|
|
75
|
os.mkdir(ip_start_menu)
|
|
@@
-60,10
+84,10
b' def install():'
|
|
60
|
'ipcontroller',
|
|
84
|
'ipcontroller',
|
|
61
|
'ipengine',
|
|
85
|
'ipengine',
|
|
62
|
'ipcluster',
|
|
86
|
'ipcluster',
|
|
63
|
'irunner'
|
|
87
|
'irunner',
|
|
64
|
]
|
|
88
|
]
|
|
65
|
programs = [ suffix(p) for p in programs ]
|
|
89
|
programs = [suffix(p) for p in programs]
|
|
66
|
scripts = pjoin(prefix,'scripts')
|
|
90
|
scripts = pjoin(sys.prefix, 'scripts')
|
|
67
|
if not have_setuptools:
|
|
91
|
if not have_setuptools:
|
|
68
|
# only create .bat files if we don't have setuptools
|
|
92
|
# only create .bat files if we don't have setuptools
|
|
69
|
for program in programs:
|
|
93
|
for program in programs:
|
|
@@
-77,61
+101,44
b' def install():'
|
|
77
|
bat_file.write("@%s %s %%*" % (python, py))
|
|
101
|
bat_file.write("@%s %s %%*" % (python, py))
|
|
78
|
bat_file.close()
|
|
102
|
bat_file.close()
|
|
79
|
|
|
103
|
|
|
80
|
# Now move onto setting the Start Menu up
|
|
104
|
# Create Start Menu shortcuts
|
|
81
|
ipybase = suffix(pjoin(scripts, 'ipython'))
|
|
105
|
iconpath = pjoin(scripts, 'ipython.ico')
|
|
82
|
if have_setuptools:
|
|
106
|
mkshortcut(python, 'IPython', ip_start_menu,
|
|
83
|
# let setuptools take care of the scripts:
|
|
107
|
arguments(scripts, 'ipython'), iconpath)
|
|
84
|
ipybase = ipybase + '-script.py'
|
|
108
|
mkshortcut(python, 'IPython (pylab mode)', ip_start_menu,
|
|
85
|
workdir = "%HOMEDRIVE%%HOMEPATH%"
|
|
109
|
arguments(scripts, 'ipython', '--pylab'), iconpath)
|
|
|
|
|
110
|
mkshortcut(python, 'IPython Controller', ip_start_menu,
|
|
|
|
|
111
|
arguments(scripts, 'ipcontroller'), iconpath)
|
|
|
|
|
112
|
mkshortcut(python, 'IPython Engine', ip_start_menu,
|
|
|
|
|
113
|
arguments(scripts, 'ipengine'), iconpath)
|
|
|
|
|
114
|
mkshortcut(pythonw, 'IPython Qt Console', ip_start_menu,
|
|
|
|
|
115
|
arguments(scripts, 'ipython', 'qtconsole'), iconpath)
|
|
|
|
|
116
|
mkshortcut(pythonw, 'IPython Qt Console (pylab mode)', ip_start_menu,
|
|
|
|
|
117
|
arguments(scripts, 'ipython', 'qtconsole --pylab=inline'),
|
|
|
|
|
118
|
iconpath)
|
|
|
|
|
119
|
|
|
|
|
|
120
|
iconpath = pjoin(scripts, 'ipython_nb.ico')
|
|
|
|
|
121
|
mkshortcut(python, 'IPython Notebook', ip_start_menu,
|
|
|
|
|
122
|
arguments(scripts, 'ipython', 'notebook'), iconpath)
|
|
|
|
|
123
|
mkshortcut(python, 'IPython Notebook (pylab mode)', ip_start_menu,
|
|
|
|
|
124
|
arguments(scripts, 'ipython', 'notebook --pylab=inline'),
|
|
|
|
|
125
|
iconpath)
|
|
86
|
|
|
126
|
|
|
87
|
link = pjoin(ip_start_menu, 'IPython.lnk')
|
|
127
|
try:
|
|
88
|
cmd = '"%s"' % ipybase
|
|
128
|
import IPython
|
|
89
|
mkshortcut(python, 'IPython', link, cmd, workdir)
|
|
129
|
mkshortcut(pythonw, 'IPython Documentation', ip_start_menu,
|
|
|
|
|
130
|
'-m webbrowser -t "http://ipython.org/ipython-doc/'
|
|
|
|
|
131
|
'rel-%s/index.html"' % IPython.__version__,
|
|
|
|
|
132
|
iconpath='url.dll')
|
|
|
|
|
133
|
except Exception:
|
|
|
|
|
134
|
pass
|
|
90
|
|
|
135
|
|
|
91
|
# Disable pysh Start item until the profile restores functionality
|
|
136
|
# Disable pysh Start item until the profile restores functionality
|
|
92
|
# Most of this code is in IPython/deathrow, and needs to be updated
|
|
137
|
# Most of this code is in IPython/deathrow, and needs to be updated
|
|
93
|
# to 0.11 APIs
|
|
138
|
# to 0.11 APIs
|
|
|
|
|
139
|
#mkshortcut(python, 'IPython%s (command prompt mode)', ip_start_menu,
|
|
|
|
|
140
|
# arguments(scripts, 'ipython', 'profile=pysh --init'))
|
|
94
|
|
|
141
|
|
|
95
|
# link = pjoin(ip_start_menu, 'pysh.lnk')
|
|
|
|
|
96
|
# cmd = '"%s" profile=pysh --init' % ipybase
|
|
|
|
|
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
|
|
|
|
|
|
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
|
|
|
142
|
|
|
136
|
def remove():
|
|
143
|
def remove():
|
|
137
|
"""Routine to be run by the win32 installer with the -remove switch."""
|
|
144
|
"""Routine to be run by the win32 installer with the -remove switch."""
|
|
@@
-144,8
+151,10
b' if len(sys.argv) > 1:'
|
|
144
|
try:
|
|
151
|
try:
|
|
145
|
install()
|
|
152
|
install()
|
|
146
|
except OSError:
|
|
153
|
except OSError:
|
|
147
|
print("Failed to create Start Menu items, try running installer as administrator.", file=sys.stderr)
|
|
154
|
print("Failed to create Start Menu items, try running the"
|
|
|
|
|
155
|
" installer as administrator.", file=sys.stderr)
|
|
148
|
elif sys.argv[1] == '-remove':
|
|
156
|
elif sys.argv[1] == '-remove':
|
|
149
|
remove()
|
|
157
|
remove()
|
|
150
|
else:
|
|
158
|
else:
|
|
151
|
print("Script was called with option %s" % sys.argv[1], file=sys.stderr)
|
|
159
|
print("Script was called with option %s" % sys.argv[1],
|
|
|
|
|
160
|
file=sys.stderr)
|