##// END OF EJS Templates
remove another py2 only test
remove another py2 only test

File last commit:

r21229:80c619a1
r22962:c05c1799
Show More
ipython_win_post_install.py
138 lines | 4.5 KiB | text/x-python | PythonLexer
/ scripts / ipython_win_post_install.py
Ville M. Vainio
crlf -> lf
r1032 #!python
Christoph Gohlke
Improve Windows start menu shortcuts
r8814 """Distutils post installation script for Windows.
http://docs.python.org/2/distutils/builtdist.html#the-postinstallation-script
"""
Ville M. Vainio
crlf -> lf
r1032
MinRK
py3 fixes for win_post_install.py
r5680 from __future__ import print_function
Christoph Gohlke
Improve Windows start menu shortcuts
r8814 import os
import sys
import shutil
Ville M. Vainio
crlf -> lf
r1032
Min RK
wininst post install script updated and requires setuptools...
r4094 try:
import setuptools
Christoph Gohlke
Improve Windows start menu shortcuts
r8814 have_setuptools = True
Min RK
wininst post install script updated and requires setuptools...
r4094 except ImportError:
Christoph Gohlke
Improve Windows start menu shortcuts
r8814 have_setuptools = False
pjoin = os.path.join
# suffix for start menu folder names
pyver = "(Py%i.%i %i bit)" % (sys.version_info[0], sys.version_info[1],
(32, 64)[sys.maxsize > 2**32])
Min RK
wininst post install script updated and requires setuptools...
r4094
Fernando Perez
Disable PDF manual building for distribution and installation....
r4453
Christoph Gohlke
Improve Windows start menu shortcuts
r8814 def mkshortcut(target, description, linkdir, arguments="", iconpath='',
workdir="%HOMEDRIVE%%HOMEPATH%", iconindex=0):
"""Make a shortcut if it doesn't exist and register its creation."""
filename = pjoin(linkdir, description + '.lnk')
description = "%s %s" % (description, pyver)
create_shortcut(target, description, filename, arguments, workdir,
iconpath, iconindex)
file_created(filename)
def arguments(scriptsdir, script, scriptargs=''):
"""Return command line arguments to be passed to the python executable."""
cmdbase = suffix(pjoin(scriptsdir, script))
if have_setuptools:
cmdbase += '-script.py'
return '"%s" %s' % (cmdbase, scriptargs)
Ville M. Vainio
crlf -> lf
r1032
MinRK
py3 fixes for win_post_install.py
r5680 def suffix(s):
Christoph Gohlke
Improve Windows start menu shortcuts
r8814 """Add '3' suffix to programs for Python 3."""
MinRK
py3 fixes for win_post_install.py
r5680 if sys.version_info[0] == 3:
Christoph Gohlke
Improve Windows start menu shortcuts
r8814 s = s + '3'
MinRK
py3 fixes for win_post_install.py
r5680 return s
Fernando Perez
Disable PDF manual building for distribution and installation....
r4453
Christoph Gohlke
Improve Windows start menu shortcuts
r8814
Ville M. Vainio
crlf -> lf
r1032 def install():
"""Routine to be run by the win32 installer with the -install switch."""
Brian Granger
Tried to fix the windows post install script. It now creates...
r1611 # Get some system constants
Christoph Gohlke
Improve Windows start menu shortcuts
r8814 python = pjoin(sys.prefix, 'python.exe')
pythonw = pjoin(sys.prefix, 'pythonw.exe')
Min RK
wininst post install script updated and requires setuptools...
r4094 if not have_setuptools:
# This currently doesn't work without setuptools,
# so don't bother making broken links
Christoph Gohlke
Refer to Setuptools instead of Distribute
r11271 print("Setuptools is required to"
Christoph Gohlke
Improve Windows start menu shortcuts
r8814 " create Start Menu items.", file=sys.stderr)
print("Re-run this installer after installing"
Christoph Gohlke
Refer to Setuptools instead of Distribute
r11271 " Setuptools to get Start Menu items.", file=sys.stderr)
Min RK
wininst post install script updated and requires setuptools...
r4094 return
Christoph Gohlke
Improve Windows start menu shortcuts
r8814
Brian Granger
Tried to fix the windows post install script. It now creates...
r1611 # Lookup path to common startmenu ...
Christoph Gohlke
Windows install fixes...
r4175 ip_start_menu = pjoin(get_special_folder_path('CSIDL_COMMON_PROGRAMS'),
Christoph Gohlke
Improve Windows start menu shortcuts
r8814 'IPython %s' % pyver)
Ville M. Vainio
crlf -> lf
r1032 # Create IPython entry ...
Brian Granger
Tried to fix the windows post install script. It now creates...
r1611 if not os.path.isdir(ip_start_menu):
os.mkdir(ip_start_menu)
directory_created(ip_start_menu)
Christoph Gohlke
Improve Windows start menu shortcuts
r8814
Brian Granger
Tried to fix the windows post install script. It now creates...
r1611 # Create .py and .bat files to make things available from
Brian Granger
Added test in ipcluster.py to see if the platform is win32. If so,...
r1613 # the Windows command line. Thanks to the Twisted project
# for this logic!
Brian Granger
Completely fixed the ipython_win_post_install.py script. It now ...
r1612 programs = [
'ipython',
'iptest',
]
Christoph Gohlke
Improve Windows start menu shortcuts
r8814 programs = [suffix(p) for p in programs]
scripts = pjoin(sys.prefix, 'scripts')
Min RK
wininst post install script updated and requires setuptools...
r4094 if not have_setuptools:
# only create .bat files if we don't have setuptools
for program in programs:
raw = pjoin(scripts, program)
bat = raw + '.bat'
py = raw + '.py'
# Create .py versions of the scripts
shutil.copy(raw, py)
# Create .bat files for each of the scripts
Christoph Gohlke
Improve Windows start menu shortcuts
r8814 bat_file = file(bat, 'w')
Min RK
wininst post install script updated and requires setuptools...
r4094 bat_file.write("@%s %s %%*" % (python, py))
bat_file.close()
Christoph Gohlke
Improve Windows start menu shortcuts
r8814 # Create Start Menu shortcuts
iconpath = pjoin(scripts, 'ipython.ico')
mkshortcut(python, 'IPython', ip_start_menu,
arguments(scripts, 'ipython'), iconpath)
mkshortcut(python, 'IPython (pylab mode)', ip_start_menu,
arguments(scripts, 'ipython', '--pylab'), iconpath)
iconpath = pjoin(scripts, 'ipython_nb.ico')
mkshortcut(python, 'IPython Notebook', ip_start_menu,
arguments(scripts, 'ipython', 'notebook'), iconpath)
Christoph Gohlke
Use base documentation URL
r10210 mkshortcut(pythonw, 'IPython Documentation', ip_start_menu,
'-m webbrowser -t "http://ipython.org/documentation.html',
iconpath='url.dll')
Christoph Gohlke
Improve Windows start menu shortcuts
r8814
MinRK
restore interactive/shell doc with warning...
r4148 # Disable pysh Start item until the profile restores functionality
# Most of this code is in IPython/deathrow, and needs to be updated
# to 0.11 APIs
Christoph Gohlke
Improve Windows start menu shortcuts
r8814 #mkshortcut(python, 'IPython%s (command prompt mode)', ip_start_menu,
# arguments(scripts, 'ipython', 'profile=pysh --init'))
Min RK
wininst post install script updated and requires setuptools...
r4094
Ville M. Vainio
crlf -> lf
r1032 def remove():
"""Routine to be run by the win32 installer with the -remove switch."""
pass
Fernando Perez
Disable PDF manual building for distribution and installation....
r4453
Ville M. Vainio
crlf -> lf
r1032 # main()
if len(sys.argv) > 1:
if sys.argv[1] == '-install':
MinRK
py3 fixes for win_post_install.py
r5680 try:
install()
except OSError:
Christoph Gohlke
Improve Windows start menu shortcuts
r8814 print("Failed to create Start Menu items, try running the"
" installer as administrator.", file=sys.stderr)
Ville M. Vainio
crlf -> lf
r1032 elif sys.argv[1] == '-remove':
remove()
else:
Christoph Gohlke
Improve Windows start menu shortcuts
r8814 print("Script was called with option %s" % sys.argv[1],
file=sys.stderr)