~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to setup/install.py

  • Committer: William Grant
  • Date: 2010-02-23 08:55:42 UTC
  • mto: This revision was merged to the branch mainline in revision 1674.
  • Revision ID: grantw@unimelb.edu.au-20100223085542-r8xw14bxxoraza51
Permit underscores in all names.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
import os
24
24
import sys
25
25
import functools
 
26
import distutils.sysconfig
26
27
 
27
28
from setup import util
28
29
 
29
 
PYTHON_VERSION = sys.version[:3]
30
 
 
31
30
def install(args):
32
31
    usage = """usage: %prog install [options]
33
32
(Requires root)
43
42
    parser.add_option("-n", "--dry",
44
43
        action="store_true", dest="dry",
45
44
        help="Print out the actions but don't do anything.")
46
 
    parser.add_option("-R", "--nosvnrevno",
47
 
        action="store_true", dest="nosvnrevno",
48
 
        help="Don't write out the Subversion revision to the share directory.")
49
45
    parser.add_option("--root",
50
46
        action="store", dest="rootdir",
51
47
        help="Install into a different root directory.",
57
53
    parser.add_option("--python-site-packages",
58
54
        action="store", dest="python_site_packages",
59
55
        help="Path to Python site packages directory.",
60
 
        default='/usr/local/lib/python%s/site-packages' % PYTHON_VERSION)
 
56
        default=None)
61
57
    (options, args) = parser.parse_args(args)
62
58
 
 
59
    # Prefix must be absolute (not really necessary, but since a relative
 
60
    # prefix will be taken relative to *root* not working directory, it is
 
61
    # confusing if we allow it).
 
62
    if options.prefix[:1] not in (os.path.sep, os.path.altsep):
 
63
        print >>sys.stderr, """prefix must be an absolute path.
 
64
    (This will be interpreted relative to root, so provide --root=. if you
 
65
    want a path relative to the working directory)."""
 
66
        return 1
 
67
 
 
68
    # Calculate python_site_packages using the supplied prefix
 
69
    if options.python_site_packages is None:
 
70
        options.python_site_packages = distutils.sysconfig.get_python_lib(
 
71
            prefix=options.prefix)
 
72
 
63
73
    # Call the real function
64
74
    return __install(prefix=options.prefix,
65
75
                     python_site_packages=options.python_site_packages,
66
 
                     dry=options.dry, rootdir=options.rootdir,
67
 
                     nosvnrevno=options.nosvnrevno)
 
76
                     dry=options.dry, rootdir=options.rootdir)
68
77
 
69
 
def __install(prefix, python_site_packages, dry=False, rootdir=None,
70
 
              nosvnrevno=False):
 
78
def __install(prefix, python_site_packages, dry=False, rootdir=None):
71
79
    install_list = util.InstallList()
72
80
 
73
81
    # We need to apply make_install_path with the rootdir to an awful lot of
116
124
    # Copy the lib directory (using the list)
117
125
    util.action_copylist(install_list.list_ivle_lib, python_site_packages, dry)
118
126
 
119
 
    if not nosvnrevno:
120
 
        # Create the ivle working revision record file
121
 
        ivle_revision_file = os.path.join(share_path, 'revision.txt')
122
 
        if not dry:
123
 
            try:
124
 
                conf = open(ivle_revision_file, "w")
125
 
 
126
 
                conf.write("""# SVN revision r%s
127
 
# Source tree location: %s
128
 
# Modified files:
129
 
""" % (util.get_svn_revision(), os.getcwd()))
130
 
 
131
 
                conf.close()
132
 
            except IOError, (errno, strerror):
133
 
                print "IO error(%s): %s" % (errno, strerror)
134
 
                sys.exit(1)
135
 
 
136
 
            os.system("svn status . >> %s" % ivle_revision_file)
137
 
 
138
 
        print "Wrote IVLE code revision status to %s" % ivle_revision_file
139
 
 
140
127
    return 0
141
128