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

« back to all changes in this revision

Viewing changes to setup/build.py

Replaced Python config files (conf.py) with new config files system, using
    configobj (INI-file style config files).

setup.py config now produces ./etc/ivle.conf, a new-style config file.
ivle/conf/conf.py is now part of the IVLE source code. It reads the new config
file and provides the same legacy interface, so all of IVLE still functions,
including setup.py config.

Added /etc to the source tree (config files will be stored here).
Added configobj as a dependency in doc/setup/install_proc.txt.

setup.py install copies ./etc/ivle.conf into /etc/ivle/ivle.conf.

Removed boilerplate code generation from setup/configure.py (that code is now
part of ivle/conf/conf.py which is now in the source tree).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
24
import sys
 
25
import compileall
 
26
 
 
27
from setup import util
 
28
 
 
29
def build(args):
 
30
    usage = """usage: %prog build [options]
 
31
(requires root)
 
32
Compiles platform-specific code, and optionally Python too.
 
33
Details:
 
34
Compiles (GCC) bin/trampoline/trampoline.c to bin/trampoline/trampoline.
 
35
Compiles (GCC) bin/timount/timount.c to bin/timount/timount.
 
36
Optionally generates .pyc files for all the IVLE .py files."""
 
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.")
 
43
    parser.add_option("--no-compile",
 
44
        action="store_true", dest="nocompile",
 
45
        help="Don't byte-compile .py files.")
 
46
    (options, args) = parser.parse_args(args)
 
47
 
 
48
    # Call the real function
 
49
    return __build(options.dry, options.nocompile)
 
50
 
 
51
def __build(dry=False, no_compile=None):
 
52
    # We need to import the one in the working copy, not in the system path.
 
53
    confmodule = __import__("ivle/conf/conf")
 
54
    install_list = util.InstallList()
 
55
 
 
56
    if dry:
 
57
        print "Dry run (no actions will be executed)\n"
 
58
 
 
59
    # Compile the trampoline
 
60
    curdir = os.getcwd()
 
61
    os.chdir('bin/trampoline')
 
62
    util.action_runprog('make', [], dry)
 
63
    os.chdir(curdir)
 
64
 
 
65
    # Compile timount
 
66
    curdir = os.getcwd()
 
67
    os.chdir('bin/timount')
 
68
    util.action_runprog('make', [], dry)
 
69
    os.chdir(curdir)
 
70
 
 
71
    # Compile .py files into .pyc or .pyo files
 
72
    if not no_compile:
 
73
        compileall.compile_dir('www', quiet=True)
 
74
        compileall.compile_dir('ivle', quiet=True)
 
75
        compileall.compile_dir('services', quiet=True)
 
76
 
 
77
    return 0
 
78