Example #1
0
import time
import xml.dom.minidom as xml
from datetime import datetime
from optparse import OptionParser

import easybuild
import easybuild.tools.build_log as build_log
import easybuild.tools.config as config
import easybuild.tools.parallelbuild as parbuild
import easybuild.tools.systemtools as systemtools
from easybuild.tools.build_log import getLog, EasyBuildError, initLogger
from easybuild.build import findEasyconfigs, processEasyconfig, resolveDependencies
from easybuild.tools.filetools import modifyEnv

# some variables used by different functions
initLogger(filename=None, debug=True, typ=None)
log = getLog("ParallelBuild")
test_results = []
build_stopped = {}


def main():
    """ main entry point """
    # assume default config path
    config.init('easybuild/easybuild_config.py')
    cur_dir = os.getcwd()

    # Option parsing
    parser = OptionParser()
    parser.add_option("--no-parallel", action="store_false", dest="parallel", default=True,
            help="specify this option if you want to prevent parallel build")
Example #2
0
def main():
    """
    Main function:
    - parse command line options
    - initialize logger
    - read easyconfig
    - build software
    """
    # disallow running EasyBuild as root
    if os.getuid() == 0:
        sys.stderr.write(
            "ERROR: You seem to be running EasyBuild with root priveleges.\n"
            "That's not wise, so let's end this here.\n"
            "Exiting.\n"
        )
        sys.exit(1)

    # options parser
    parser = OptionParser()

    parser.usage = "%prog [options] easyconfig [..]"
    parser.description = (
        "Builds software package based on easyconfig (or parse a directory)\n"
        "Provide one or more easyconfigs or directories, use -h or --help more information."
    )

    add_build_options(parser)

    (options, paths) = parser.parse_args()

    ## mkstemp returns (fd,filename), fd is from os.open, not regular open!
    fd, logFile = tempfile.mkstemp(suffix=".log", prefix="easybuild-")
    os.close(fd)

    if options.stdoutLog:
        os.remove(logFile)
        logFile = None

    global LOGDEBUG
    LOGDEBUG = options.debug

    configOptions = {}
    if options.pretend:
        configOptions["installPath"] = os.path.join(os.environ["HOME"], "easybuildinstall")

    if options.only_blocks:
        blocks = options.only_blocks.split(",")
    else:
        blocks = None

    ## Initialize logger
    logFile, log, hn = initLogger(filename=logFile, debug=options.debug, typ="build")

    ## Show version
    if options.version:
        print_msg("This is EasyBuild %s" % easybuild.VERBOSE_VERSION, log)

    ## Initialize configuration
    # - check environment variable EASYBUILDCONFIG
    # - then, check command line option
    # - last, use default config file easybuild_config.py in build.py directory
    config_file = options.config
    if not config_file and os.getenv("EASYBUILDCONFIG"):
        config_file = os.getenv("EASYBUILDCONFIG")
    else:
        appPath = os.path.dirname(os.path.realpath(sys.argv[0]))
        config_file = os.path.join(appPath, "easybuild_config.py")
    config.init(config_file, **configOptions)

    # Dump possible options
    if options.avail_easyconfig_params:
        app = get_class(options.easyblock, log)
        extra = app.extra_options()
        default = EasyBlock.default_config

        print "DEFAULT OPTIONS:"
        for key in sorted(default):
            tabs = "\t" * (3 - (len(key) + 1) / 8)
            print "%s:%s%s" % (key, tabs, default[key][1])

        if extra:
            print "EXTRA OPTIONS:"
            for key in sorted(extra):
                tabs = "\t" * (3 - (len(key) + 1) / 8)
                print "%s:%s%s" % (key, tabs, extra[key][1])

    ## Dump available classes
    if options.dump_classes:
        dumpClasses("easybuild.easyblocks")

    ## Search for modules
    if options.search:
        if not options.robot:
            error("Please provide a search-path to --robot when using --search")
        searchModule(options.robot, options.search)

    if options.avail_easyconfig_params or options.dump_classes or options.search or options.version:
        if logFile:
            os.remove(logFile)
        sys.exit(0)

    # set strictness of filetools module
    if options.strict:
        filetools.strictness = options.strict

    ## Read easyconfig files
    packages = []
    if len(paths) == 0:
        error("Please provide one or more easyconfig files", optparser=parser)

    for path in paths:
        path = os.path.abspath(path)
        if not (os.path.exists(path)):
            error("Can't find path %s" % path)

        try:
            files = findEasyconfigs(path, log)
            for eb_file in files:
                packages.extend(processEasyconfig(eb_file, log, blocks))
        except IOError, err:
            log.error("Processing easyconfigs in path %s failed: %s" % (path, err))