From: <sv...@ww...> - 2006-12-30 18:57:27
|
Author: mkrose Date: 2006-12-30 10:57:20 -0800 (Sat, 30 Dec 2006) New Revision: 2044 Modified: trunk/csp/SConstruct trunk/csp/tools/build/__init__.py trunk/csp/tools/build/setup.py trunk/csp/tools/setup.py Log: Make tools/setup.py work as a standalone script and remove 'scons setup'. The latter required scons to be run as root, which caused various scons metadata files to be created with root as owner. This prevented scons from working correctly when run as a normal user. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=2044 Modified: trunk/csp/SConstruct =================================================================== --- trunk/csp/SConstruct 2006-12-20 20:22:43 UTC (rev 2043) +++ trunk/csp/SConstruct 2006-12-30 18:57:20 UTC (rev 2044) @@ -116,7 +116,6 @@ scons indexserver build the master server needed for multiplayer scons dox generate doxygen documentation scons runtests build and run all unittests - scons setup configure the workspace (only needs to be run once) """ INCLUDE = ['#/..', build.GetPythonInclude()] Modified: trunk/csp/tools/build/__init__.py =================================================================== --- trunk/csp/tools/build/__init__.py 2006-12-20 20:22:43 UTC (rev 2043) +++ trunk/csp/tools/build/__init__.py 2006-12-30 18:57:20 UTC (rev 2044) @@ -68,13 +68,12 @@ print 'intended to be run as a standalone program.' sys.exit(1) -# csp bootstrap module may not be installed yet, so manually adjust the module -# search path if necessary. +# Before doing any real work, check that the csp bootstrap module is installed. try: import csp except ImportError: - csp_parent = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..')) - sys.path.insert(0, csp_parent) + print 'The CSP build environment has not been initialized. Please' + print 'run "python tools/setup.py" as root or admin.' from csp.tools.build.setup import Environment Modified: trunk/csp/tools/build/setup.py =================================================================== --- trunk/csp/tools/build/setup.py 2006-12-20 20:22:43 UTC (rev 2043) +++ trunk/csp/tools/build/setup.py 2006-12-30 18:57:20 UTC (rev 2044) @@ -241,15 +241,19 @@ def SetupClientWorkspace(force): - sys.path.insert(0, scons.Dir('#').abspath) - import tools.setup - del sys.path[0] - setup_log = logging.Logger('setup', logging.INFO) - setup_log.addHandler(logging.FileHandler('.setup.log', mode='wt')) - if tools.setup.SetupClientWorkspace(force, log=setup_log): - print 'Setup complete.' - else: - print 'Setup failed; see .setup.log for details.' + print '"scons setup" is no longer supported, since running scons' + print 'as root causes permissions problems for metadata files' + print 'created by scons. Run "python tools/setup.py" as root' + print 'or admin instead.' + #sys.path.insert(0, scons.Dir('#').abspath) + #import tools.setup + #del sys.path[0] + #setup_log = logging.Logger('setup', logging.INFO) + #setup_log.addHandler(logging.FileHandler('.setup.log', mode='wt')) + #if tools.setup.SetupClientWorkspace(force, log=setup_log): + # print 'Setup complete.' + #else: + # print 'Setup failed; see .setup.log for details.' def AddSetupTargets(env): Modified: trunk/csp/tools/setup.py =================================================================== --- trunk/csp/tools/setup.py 2006-12-20 20:22:43 UTC (rev 2043) +++ trunk/csp/tools/setup.py 2006-12-30 18:57:20 UTC (rev 2044) @@ -18,22 +18,28 @@ """ -Installs a stub module csp.py into the Python site-packages directory, -allowing csp and its submodules to be imported from the current client -workspace without modifying the default Python module path. +Prepares the development workspace for building and running CSP +and related tools. In particular, this script installs a stub +module named csp.py into the Python site-packages directory, +allowing csp and its submodules to be imported from the current +client workspace without modifying the default Python module path. -Also prepares the build environment for the current platform. (Not -fully implemented yet.) +This script should be run once as root or admin for each CSP +subversion client.""" -This module is used by the scons build environment. See the top-level -README for details. -""" +# This module is used by the scons build environment. See the top-level +# README for details. Note that using scons to install the bootstrap +# module is deprecated, and support for 'scons setup' will be removed. +# This is because running scons as root causes a number of scons +# metadata files to be owned by root, which breaks the build when +# later running scons as a normal user. import sys import os import os.path import commands import logging +import optparse from distutils import sysconfig from distutils import file_util from distutils import util @@ -115,3 +121,29 @@ installer = BootstrapInstaller(log) return installer.install(force) + +if __name__ == '__main__': + USAGE = '%s [options]\n%s' % (sys.argv[0], __doc__) + + # parse commandline options + opt = optparse.OptionParser(usage=USAGE) + opt.add_option('-f', '--force', action='store_true', default=False, help='overwrite existing csp module') + opt.add_option('--logfile', type='string', default='', help='log messages to this file (instead of stdout)') + options, args = opt.parse_args() + + # initialize logging + formatter = logging.Formatter('%(levelname)s : %(message)s') + setup_log = logging.Logger('setup', logging.INFO) + logstream = sys.stdout + if options.logfile: + logstream = open(options.logfile, 'wt') + loghandler = logging.StreamHandler(logstream) + loghandler.setFormatter(formatter) + setup_log.addHandler(loghandler) + + # setup the client workspace + if SetupClientWorkspace(options.force, log=setup_log): + print 'Setup complete.' + else: + print 'Setup failed.' + sys.exit(1) |