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

803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
1
# IVLE - Informatics Virtual Learning Environment
2
# Copyright (C) 2007-2008 The University of Melbourne
3
#
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17
18
# Module: setup/build
19
# Author: Matt Giuca, Refactored by David Coles
20
# Date:   02/07/2008
21
22
import optparse
23
import os
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
24
import sys
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
25
import compileall
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
26
27
from setup import util
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
28
29
def build(args):
30
    usage = """usage: %prog build [options]
31
(requires root)
1092.1.1 by William Grant
[Uber-commit of holiday work because I lacked a local copy of the branch.]
32
Compiles platform-specific code, and optionally Python too.
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
33
Details:
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
34
Compiles (GCC) bin/trampoline/trampoline.c to bin/trampoline/trampoline.
35
Compiles (GCC) bin/timount/timount.c to bin/timount/timount.
1092.1.1 by William Grant
[Uber-commit of holiday work because I lacked a local copy of the branch.]
36
Optionally generates .pyc files for all the IVLE .py files."""
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
37
38
    # Parse arguments
39
    parser = optparse.OptionParser(usage)
40
    parser.add_option("-n", "--dry",
41
        action="store_true", dest="dry",
42
        help="Print out the actions but don't do anything.")
1092.1.1 by William Grant
[Uber-commit of holiday work because I lacked a local copy of the branch.]
43
    parser.add_option("--no-compile",
44
        action="store_true", dest="nocompile",
45
        help="Don't byte-compile .py files.")
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
46
    (options, args) = parser.parse_args(args)
47
48
    # Call the real function
1092.1.1 by William Grant
[Uber-commit of holiday work because I lacked a local copy of the branch.]
49
    return __build(options.dry, options.nocompile)
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
50
1092.1.1 by William Grant
[Uber-commit of holiday work because I lacked a local copy of the branch.]
51
def __build(dry=False, no_compile=None):
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
52
    install_list = util.InstallList()
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
53
54
    if dry:
55
        print "Dry run (no actions will be executed)\n"
1050 by wagrant
setup: Don't give possible options in the top-level usage string.
56
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
57
    # Compile the trampoline
58
    curdir = os.getcwd()
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
59
    os.chdir('bin/trampoline')
60
    util.action_runprog('make', [], dry)
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
61
    os.chdir(curdir)
62
813 by William Grant
Merge jails-redux branch. We now use aufs rather than hardlinking tens
63
    # Compile timount
64
    curdir = os.getcwd()
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
65
    os.chdir('bin/timount')
66
    util.action_runprog('make', [], dry)
813 by William Grant
Merge jails-redux branch. We now use aufs rather than hardlinking tens
67
    os.chdir(curdir)
68
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
69
    # Compile .py files into .pyc or .pyo files
1092.1.1 by William Grant
[Uber-commit of holiday work because I lacked a local copy of the branch.]
70
    if not no_compile:
71
        compileall.compile_dir('www', quiet=True)
72
        compileall.compile_dir('ivle', quiet=True)
73
        compileall.compile_dir('services', quiet=True)
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
74
75
    return 0
76