def build_envs_sh(package, target, envvarops_factory=None): """build envs.sh on target's bin directory package: name of the package, eg luban target: path at which the package was installed. for mm user, this is EXPORT_ROOT """ import os target = os.path.abspath(target) print 'building envs.sh for %s' % target # content of the envs.sh opsfactory = envvarops_factory or createEnvVarOps ops = opsfactory(package, target) from ..envvars.renderers.BashScriptor import BashScriptor scriptor = BashScriptor() lines = scriptor.render(ops) content = '\n'.join(lines) # bindir = os.path.join(target, 'bin') # make dir if necessary if not os.path.exists(bindir): os.makedirs(bindir) # envs.sh f = os.path.join(bindir, 'envs.sh') open(f, 'w').write(content) return
def build_envs_sh(package, target, envvarops_factory=None): """build envs.sh on target's bin directory package: name of the package, eg luban target: path at which the package was installed. for mm user, this is EXPORT_ROOT """ import os target = os.path.abspath( target ) print 'building envs.sh for %s' % target # content of the envs.sh opsfactory = envvarops_factory or createEnvVarOps ops = opsfactory(package, target) from ..envvars.renderers.BashScriptor import BashScriptor scriptor = BashScriptor() lines = scriptor.render(ops) content = '\n'.join(lines) # bindir = os.path.join( target, 'bin' ) # make dir if necessary if not os.path.exists(bindir): os.makedirs(bindir) # envs.sh f = os.path.join( bindir, 'envs.sh' ) open(f, 'w').write(content) return
def build_envs_sh( package, target, content=None, template=None): """build envs.sh on target's bin directory package: name of the package, eg luban target: path at which the package was installed. for mm user, this is EXPORT_ROOT """ import os target = os.path.abspath( target ) print 'building envs.sh for %s' % target # content of the envs.sh if content is None: content = envs_sh_content(target, package, template=template) # bindir = os.path.join( target, 'bin' ) # make dir if necessary if not os.path.exists(bindir): os.makedirs(bindir) # envs.sh f = os.path.join( bindir, 'envs.sh' ) open(f, 'w').write(content) return
def build_envs_sh(package, target, content=None, template=None): """build envs.sh on target's bin directory package: name of the package, eg luban target: path at which the package was installed. for mm user, this is EXPORT_ROOT """ import os target = os.path.abspath(target) print 'building envs.sh for %s' % target # content of the envs.sh if content is None: content = envs_sh_content(target, package, template=template) # bindir = os.path.join(target, 'bin') # make dir if necessary if not os.path.exists(bindir): os.makedirs(bindir) # envs.sh f = os.path.join(bindir, 'envs.sh') open(f, 'w').write(content) return
def runall(skip_long_tests=False): # where is the <export>? from utils.datastore import open build_info = open('build_info') export = build_info.get('export_root', 'EXPORT') # set up env vars from build_envs import factory ops = factory('mcvine', export) from utils.envvars import perform perform(ops) # cxx tests cxxfailed = execute( cmd='python run-cxx-tests.py src/mcvine', where='.', ) # python unit tests cmd = 'python run-unittest.py ' args = "-r --exclude-dirs=sansmodel*,obsolete --log=log.verbose".split() if skip_long_tests: args.append(' --skip-long-tests') args.append("src/mcvine/packages") cmd += ' '.join(args) pyunittestfailed = execute( # cmd = 'python run-unittests.py src/mcvine/packages/mcni', cmd=cmd, where='.', ) # failed = cxxfailed or pyunittestfailed # report if failed: print print '=' * 60 if cxxfailed: print '* c++ test failed' if pyunittestfailed: print '* python unit tests failed' print '=' * 60 else: print print '=' * 60 print 'All tests passed' return failed
def main(): getsrc() import sys, os, shlex # find out the "export" directory that user wants from utils.datastore import open build_info = open('build_info') if len(sys.argv) == 2: export_root = sys.argv[1] else: if build_info.get('export_root'): export_root = build_info['export_root'] else: export_root = os.path.abspath('EXPORT') build_info['export_root'] = export_root del build_info # adjust env vars so that <export>/deps is in use deps_root = os.path.join(export_root, 'deps') env = os.environ.copy() env['PATH'] = '%s:%s' % ( os.path.join( deps_root, 'bin' ), env['PATH'] ) env['LD_LIBRARY_PATH'] = '%s:%s' % ( os.path.join( deps_root, 'lib' ), env.get('LD_LIBRARY_PATH') or '' ) env['DYLD_LIBRARY_PATH'] = '%s:%s' % ( os.path.join( deps_root, 'lib' ), env.get('DYLD_LIBRARY_PATH') or '' ) env['PYTHONPATH'] = '%s:%s' % ( os.path.join( deps_root, 'python' ), env.get('PYTHONPATH', '') ) # open a sub process to run the build cmd = 'python -c "from utils.scripts.build import build; build(%r)"' % export_root args = shlex.split(cmd) import subprocess p = subprocess.Popen(args, env=env) while 1: p.communicate() rt = p.poll() if rt is not None: break continue if rt: raise RuntimeError, "Command %s failed or aborted" % cmd
def main(): usage = 'usage: %prog ' + 'path-to-%s-installation' % package import optparse parser = optparse.OptionParser(usage=usage) options, args = parser.parse_args() if len(args) > 1: parser.print_usage() return if len(args) == 0: from utils.datastore import open build_info = open('build_info') path = build_info.get('export_root', 'EXPORT') else: path = args[0] build_envs_sh(package, path, envvarops_factory=envvarops_factory) return
def main(): usage = 'usage: %prog ' + 'path-to-%s-installation' % package import optparse parser = optparse.OptionParser(usage=usage) options, args = parser.parse_args() if len(args) > 1: parser.print_usage() return if len(args) == 0: from utils.datastore import open build_info = open('build_info') path = build_info.get('export_root', 'EXPORT') else: path = args[0] build_envs_sh(package, path, template=template) return