~ellisonbg/ipython/bugfixes0411409

« back to all changes in this revision

Viewing changes to scripts/ipython_win_post_install.py

  • Committer: ville
  • Date: 2008-02-16 09:50:47 UTC
  • mto: (0.12.1 ipython_main)
  • mto: This revision was merged to the branch mainline in revision 990.
  • Revision ID: ville@ville-pc-20080216095047-500x6dluki1iz40o
initialization (no svn history)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!python
 
2
"""Windows-specific part of the installation"""
 
3
 
 
4
import os, sys, shutil
 
5
 
 
6
def mkshortcut(target,description,link_file,*args,**kw):
 
7
    """make a shortcut if it doesn't exist, and register its creation"""
 
8
    
 
9
    create_shortcut(target, description, link_file,*args,**kw)
 
10
    file_created(link_file)
 
11
 
 
12
def install():
 
13
    """Routine to be run by the win32 installer with the -install switch."""
 
14
 
 
15
    from IPython.Release import version
 
16
 
 
17
    # Get some system constants
 
18
    prefix = sys.prefix
 
19
    python = prefix + r'\python.exe'
 
20
    # Lookup path to common startmenu ...
 
21
    ip_dir = get_special_folder_path('CSIDL_COMMON_PROGRAMS') + r'\IPython'
 
22
    
 
23
    # Some usability warnings at installation time.  I don't want them at the
 
24
    # top-level, so they don't appear if the user is uninstalling.
 
25
    try:
 
26
        import ctypes
 
27
    except ImportError:
 
28
        print ('To take full advantage of IPython, you need ctypes from:\n'
 
29
               'http://sourceforge.net/projects/ctypes')
 
30
 
 
31
    try:
 
32
        import win32con
 
33
    except ImportError:
 
34
        print ('To take full advantage of IPython, you need pywin32 from:\n'
 
35
               'http://starship.python.net/crew/mhammond/win32/Downloads.html')
 
36
 
 
37
    try:
 
38
        import readline
 
39
    except ImportError:
 
40
        print ('To take full advantage of IPython, you need readline from:\n'
 
41
               'http://sourceforge.net/projects/uncpythontools')
 
42
 
 
43
    ipybase = '"'+prefix+r'\scripts\ipython"'
 
44
    # Create IPython entry ...
 
45
    if not os.path.isdir(ip_dir):
 
46
        os.mkdir(ip_dir)
 
47
        directory_created(ip_dir)
 
48
 
 
49
    # Create program shortcuts ...
 
50
    f = ip_dir + r'\IPython.lnk'
 
51
    a = ipybase
 
52
    mkshortcut(python,'IPython',f,a)
 
53
 
 
54
    f = ip_dir + r'\pysh.lnk'
 
55
    a = ipybase+' -p sh'
 
56
    mkshortcut(python,'IPython command prompt mode',f,a)
 
57
 
 
58
    f = ip_dir + r'\scipy.lnk'
 
59
    a = ipybase+' -pylab -p scipy'
 
60
    mkshortcut(python,'IPython scipy profile',f,a)
 
61
 
 
62
    # Create documentation shortcuts ...    
 
63
    t = prefix + r'\share\doc\ipython-%s\manual.pdf' % version
 
64
    f = ip_dir + r'\Manual in PDF.lnk'
 
65
    mkshortcut(t,r'IPython Manual - PDF-Format',f)
 
66
 
 
67
    t = prefix + r'\share\doc\ipython-%s\manual\manual.html' % version
 
68
    f = ip_dir + r'\Manual in HTML.lnk'
 
69
    mkshortcut(t,'IPython Manual - HTML-Format',f)
 
70
 
 
71
    # make ipython.py
 
72
    shutil.copy(prefix + r'\scripts\ipython', prefix + r'\scripts\ipython.py')
 
73
    
 
74
def remove():
 
75
    """Routine to be run by the win32 installer with the -remove switch."""
 
76
    pass
 
77
 
 
78
# main()
 
79
if len(sys.argv) > 1:
 
80
    if sys.argv[1] == '-install':
 
81
        install()
 
82
    elif sys.argv[1] == '-remove':
 
83
        remove()
 
84
    else:
 
85
        print "Script was called with option %s" % sys.argv[1]