File: install-pythoncard.py

package info (click to toggle)
pythoncard 0.8.2-2
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 8,452 kB
  • sloc: python: 56,787; makefile: 56; sh: 22
file content (121 lines) | stat: -rw-r--r-- 3,827 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121

"""
__version__ = "$Revision: 1.9 $"
__date__ = "$Date: 2006/01/13 22:01:29 $"
"""

# THIS FILE IS ONLY FOR USE WITH MS WINDOWS
# It is run as parts of the bdist_wininst installer
# Be sure to build the installer with
# 'python setup.py --install-script=install-pythoncard.py'
# or insert this into setup.cfg:
# [bdist_wininst]
# install-script=install-pythoncard.py

import sys, os
from distutils.sysconfig import get_python_lib

if not sys.platform.startswith('win'):
    sys.exit()

try:
    prg = get_special_folder_path("CSIDL_COMMON_PROGRAMS")
except OSError:
    try:
        prg = get_special_folder_path("CSIDL_PROGRAMS")
    except OSError, reason:
        # give up - cannot install shortcuts
        print "cannot install shortcuts: %s" % reason
        sys.exit()

lib_dir = get_python_lib(plat_specific=1)

dest_dir = os.path.join(prg, "PythonCard")

pythonw = os.path.join(sys.prefix, "pythonw.exe")

if __name__ == '__main__':
    if "-install" == sys.argv[1]:

        try:
            os.mkdir(dest_dir)
            directory_created(dest_dir)
        except OSError:
            pass

        # create_shortcut(target, description, filename[, arguments[, \
        #                 workdir[, iconpath[, iconindex]]]])
        
        # file_created(path)
        #  - register 'path' so that the uninstaller removes it
        
        # directory_created(path)
        #  - register 'path' so that the uninstaller removes it
        
        # get_special_folder_location(csidl_string)

        target = os.path.join(lib_dir,
                              "PythonCard\\samples\\samples.pyw")
        path = os.path.join(dest_dir, "Sample Launcher.lnk")

        create_shortcut(target, "Sample Launcher", path)
        file_created(path)


        path = os.path.join(dest_dir, "Layout Editor.lnk")
        arguments = os.path.join(lib_dir,
             "PythonCard\\tools\\resourceEditor\\layoutEditor.py")
        create_shortcut(pythonw, "Layout Editor", path, arguments)
        file_created(path)

        path = os.path.join(dest_dir, "Resource Editor.lnk")
        arguments = os.path.join(lib_dir,
             "PythonCard\\tools\\resourceEditor\\resourceEditor.py")
        create_shortcut(pythonw, "Resource Editor", path, arguments)
        file_created(path)


        path = os.path.join(dest_dir, "Code Editor.lnk")
        arguments = os.path.join(lib_dir,
             "PythonCard\\tools\\codeEditor\\codeEditor.py")

        create_shortcut(pythonw, "Code Editor", path, arguments)
        file_created(path)

        path = os.path.join(dest_dir, "Tabbed Code Editor.lnk")
        arguments = os.path.join(lib_dir,
             "PythonCard\\tools\\oneEditor\\tabcodeEditor.py")

        create_shortcut(pythonw, "Tabbed Code Editor", path, arguments)
        file_created(path)


        path = os.path.join(dest_dir, "Find Files.lnk")
        arguments = os.path.join(lib_dir,
             "PythonCard\\tools\\findfiles\\findfiles.py")

        create_shortcut(pythonw, "Find Files", path, arguments)
        file_created(path)


        target = os.path.join(lib_dir,
                              "PythonCard\\docs\\html\\index.html")
        path = os.path.join(dest_dir, "Documentation.lnk")

        create_shortcut(target, "Documentation", path)
        file_created(path)


        target = os.path.join(sys.prefix, "RemovePythonCard.exe")
        path = os.path.join(dest_dir, "Uninstall PythonCard.lnk")
        arguments = "-u " + os.path.join(sys.prefix,
                                         "PythonCard-wininst.log")

        create_shortcut(target, "Uninstall PythonCard",
                        path, arguments)
        file_created(path)

        print "See the shortcuts installed in the PythonCard Programs Group"

    elif "-remove" == sys.argv[1]:
        pass