def activate_venv():
    venv_dir = chpl_home_utils.get_chpl_test_venv()
    default_venv_dir = chpl_home_utils.get_chpl_venv()

    # user asserts that system already has the required dependencies installed:
    if venv_dir == 'none':
        log('Skipping virtualenv activation because CHPL_TEST_VENV_DIR={0}. '
            'test-venv requirements must be available.'.format(venv_dir))

    else:
        # using custom venv, does not check that our test requirements are met
        if venv_dir != default_venv_dir:
            log('Using custom virtualenv because CHPL_TEST_VENV_DIR={0}. '
                'test-venv requirements must be available'.format(venv_dir))

        # check Chapel test-venv for successful installation sentinel
        else:
            sentinel_file = os.path.join(venv_dir, 'chpl-test-reqs')
            if not os.path.isfile(sentinel_file):
                error('Chapel test virtualenv not available, run a top-level '
                      '`{0} test-venv`'.format(chpl_make.get()))

        activation_file = os.path.join(venv_dir, 'bin', 'activate_this.py')
        if not os.path.isfile(activation_file):
            error('Activation file {0} is missing'.format(activation_file))

        # actually activate
        with open(activation_file) as f:
            code = compile(f.read(), activation_file, 'exec')
            exec(code, dict(__file__=activation_file))
예제 #2
0
def activate_venv():
    venv_dir = chpl_home_utils.get_chpl_test_venv()
    default_venv_dir = chpl_home_utils.get_chpl_venv()

    # user asserts that system already has the required dependencies installed:
    if venv_dir == 'none':
        log('Skipping virtualenv activation because CHPL_TEST_VENV_DIR={0}. '
            'test-venv requirements must be available.'.format(venv_dir))

    else:
        # using custom venv, does not check that our test requirements are met
        if venv_dir != default_venv_dir:
            log('Using custom virtualenv because CHPL_TEST_VENV_DIR={0}. '
                'test-venv requirements must be available'.format(venv_dir))

        # check Chapel test-venv for successful installation sentinel
        else:
            sentinel_file = os.path.join(venv_dir, 'chpl-test-reqs')
            if not os.path.isfile(sentinel_file):
                error('Chapel test virtualenv not available, run a top-level '
                      '`{0} test-venv`'.format(chpl_make.get()))

        activation_file = os.path.join(venv_dir, 'bin', 'activate_this.py')
        if not os.path.isfile(activation_file):
            error('Activation file {0} is missing'.format(activation_file))

        # actually activate
        with open(activation_file) as f:
            code = compile(f.read(), activation_file, 'exec')
            exec(code, dict(__file__=activation_file))
예제 #3
0
def build_chpl(chpl_home, build_config, env, parallel=False, verbose=False):
    """Build Chapel with the provided environment.

    :type chpl_home: str
    :arg chpl_home: CHPL_HOME env var

    :type build_config: Config
    :arg build_config: build configuration to build

    :type env: dict
    :arg env: Dictionary of key/value pairs to set as the environment.

    :type parallel: bool
    :arg parallel: enable parallel execution for build

    :type verbose: bool
    :arg verbose: if True, increase output

    :rtype: int
    :returns: exit code from building configuration
    """
    build_env = build_config.get_env(env)
    logging.info('Building config: {0}'.format(build_config))

    make_cmd = chpl_make.get()
    if parallel:
        make_cmd += ' --jobs={0}'.format(multiprocessing.cpu_count())
    logging.debug('Using make command: {0}'.format(make_cmd))

    with elapsed_time(build_config):
        result, output, error = check_output(make_cmd,
                                             chpl_home,
                                             build_env,
                                             verbose=verbose)
        logging.debug('Exit code for config {0}: {1}'.format(
            build_config, result))
    logging.info('Finished config:\n{0}'.format(build_config.verbose_str()))

    if result != 0:
        if output is not None:
            logging.error('stdout:\n{0}'.format(output))
        if error is not None:
            logging.error('stderr:\n{0}'.format(error))
        logging.error(
            'Non-zero exit code when building config {0}: {1}'.format(
                build_config, result))

    return result
예제 #4
0
def build_chpl(chpl_home, build_config, env, parallel=False, verbose=False):
    """Build Chapel with the provided environment.

    :type chpl_home: str
    :arg chpl_home: CHPL_HOME env var

    :type build_config: Config
    :arg build_config: build configuration to build

    :type env: dict
    :arg env: Dictionary of key/value pairs to set as the environment.

    :type parallel: bool
    :arg parallel: enable parallel execution for build

    :type verbose: bool
    :arg verbose: if True, increase output

    :rtype: int
    :returns: exit code from building configuration
    """
    build_env = build_config.get_env(env)
    logging.info('Building config: {0}'.format(build_config))

    make_cmd = chpl_make.get()
    if parallel:
        make_cmd += ' --jobs={0}'.format(multiprocessing.cpu_count())
    logging.debug('Using make command: {0}'.format(make_cmd))

    with elapsed_time(build_config):
        result, output, error = check_output(
            make_cmd, chpl_home, build_env, verbose=verbose)
        logging.debug('Exit code for config {0}: {1}'.format(
            build_config, result))
    logging.info('Finished config:\n{0}'.format(build_config.verbose_str()))

    if result != 0:
        if output is not None:
            logging.error('stdout:\n{0}'.format(output))
        if error is not None:
            logging.error('stderr:\n{0}'.format(error))
        logging.error('Non-zero exit code when building config {0}: {1}'.format(
            build_config, result))

    return result
예제 #5
0
def activate_venv():

    custom_venv_dir_var = 'CHPL_TEST_VENV_DIR'
    custom_venv_dir = os.getenv(custom_venv_dir_var, '').strip()

    # user asserts that system already has the required dependencies installed:
    if custom_venv_dir == 'none':
        print('[Skipping virtualenv activation because {0}={1}. test-venv '
              'requirements must be available.]'.format(custom_venv_dir_var,
              custom_venv_dir))

    else:
        venv_dir = None

        # using custom venv, does not check that our test requirements are met
        if custom_venv_dir:
            venv_dir = custom_venv_dir
            print('[Using custom  virtualenv because {0}={1}. test-venv '
                  'requirements must be available]'.format(custom_venv_dir_var,
                  custom_venv_dir))

        # check Chapel test-venv for successful installation sentinel
        else:
            chpl_home = os.path.join(utils.get_chpl_home(), '')
            third_party = os.path.join(chpl_home, 'third-party')
            target_platform = chpl_platform.get('target')

            venv_dir = os.path.join(third_party, 'chpl-venv', 'install',
                                    target_platform, 'chpl-virtualenv')
            sentinel_file = os.path.join(venv_dir, 'chpl-test-reqs')
            if not os.path.isfile(sentinel_file):
                error('Chapel test virtualenv is not available, run `{0} '
                      'test-venv` from {1}'.format(chpl_make.get(), chpl_home))

        activation_file = os.path.join(venv_dir, 'bin', 'activate_this.py')
        if not os.path.isfile(activation_file):
            error('Activation file {0} is missing'.format(activation_file))

        # actually activate
        execfile(activation_file, dict(__file__=activation_file))
예제 #6
0
def build_chpl(chpl_home,
               build_config,
               env,
               parallel=False,
               verbose=False,
               dry_run=False):
    """Build Chapel with the provided environment.

    :type chpl_home: str
    :arg chpl_home: CHPL_HOME env var

    :type build_config: Config
    :arg build_config: build configuration to build

    :type env: dict
    :arg env: Dictionary of key/value pairs to set as the environment.

    :type parallel: bool
    :arg parallel: enable parallel execution for build

    :type verbose: bool
    :arg verbose: if True, increase output

    :rtype: int
    :returns: exit code from building configuration
    """
    build_env = build_config.get_env(env)
    logging.info('Building config: {0}'.format(build_config))

    make_cmd = chpl_make.get()
    if parallel:

        def _cpu_count():
            """ return Python cpu_count(), optionally capped by env var CHPL_MAKE_MAX_CPU_COUNT
            """
            cpus = multiprocessing.cpu_count()
            try:
                max = os.getenv('CHPL_MAKE_MAX_CPU_COUNT', '0')
                if int(max) > 0:
                    cpus = min(int(max), cpus)
            except:
                pass
            return cpus

        make_cmd += ' --jobs={0}'.format(_cpu_count())
    logging.debug('Using make command: {0}'.format(make_cmd))

    if dry_run:
        logging.info('dry-run config:\n{0}\n{1}'.format(
            build_config, make_cmd))
        return 0
    else:
        with elapsed_time(build_config):
            result, output, error = check_output(make_cmd,
                                                 chpl_home,
                                                 build_env,
                                                 verbose=verbose)
            logging.debug('Exit code for config {0}: {1}'.format(
                build_config, result))
        logging.info('Finished config:\n{0}'.format(
            build_config.verbose_str()))

        if result != 0:
            if output is not None:
                logging.error('stdout:\n{0}'.format(output))
            if error is not None:
                logging.error('stderr:\n{0}'.format(error))
            logging.error(
                'Non-zero exit code when building config {0}: {1}'.format(
                    build_config, result))

        return result
예제 #7
0
def main():

    global chpl_home_dir
    check_file = os.path.relpath(__file__, chpl_home_dir)
    check_path = os.path.join(chpl_home_dir, check_file)
    if not os.path.isfile(check_path):
        sys.stderr.write("Warning: check {0} not found\n".format(check_path))

    if "CHPL_HOME" in os.environ:
        if os.path.abspath(os.environ["CHPL_HOME"]) != chpl_home_dir:
            # to be sure, check that the inode numbers of our check file match
            env_check = os.path.join(os.environ["CHPL_HOME"], check_file)
            rel_check = os.path.join(chpl_home_dir, check_file)
            if os.path.samefile(env_check, rel_check):
                # No warning, it's OK, they are the same file.
                pass
            else:
                sys.stderr.write("Warning: check {0} not found\n".format(check_path))
                sys.stderr.write("Warning: Mismatched CHPL_HOME; got {0} but expected {1}\n".format(os.path.abspath(os.environ["CHPL_HOME"]), chpl_home_dir))

        chpl_home_dir = os.environ["CHPL_HOME"] # use enviro var spelling of it
    else:
        os.environ["CHPL_HOME"] = chpl_home_dir

    os.environ["CHPL_MAKE_HOME"] = chpl_home_dir
    if "CHPL_RUNTIME_LIB" in os.environ:
        os.environ["CHPL_MAKE_RUNTIME_LIB"] = os.environ["CHPL_RUNTIME_LIB"]

    if "CHPL_RUNTIME_INCL" in os.environ:
        os.environ["CHPL_MAKE_RUNTIME_INCL"] = os.environ["CHPL_RUNTIME_INCL"]

    if "CHPL_THIRD_PARTY" in os.environ:
        os.environ["CHPL_MAKE_THIRD_PARTY"] = os.environ["CHPL_THIRD_PARTY"]

    make = chpl_make.get()

    orig_make = make
    # Do not print directory changes.
    make = [make, "--no-print-directory"]

    # Make reasonable defaults for environment settings
    os.environ["COMP_GEN_WARN"] = "0"
    os.environ["COMP_GEN_DEBUG"] = "0"
    os.environ["COMP_GEN_OPT"] = "0"
    os.environ["COMP_GEN_SPECIALIZE"] = "0"
    os.environ["COMP_GEN_IEEE_FLOAT"] = "1"

    actions = parseArguments()

    make_helper = make + ["-f", chpl_home_dir + "/runtime/etc/Makefile.include"]

    for a in actions:
        if a == "home":
            sys.stdout.write("{0}\n".format(chpl_home_dir))
        elif a == "make":
            sys.stdout.write("{0}\n".format(orig_make))
        elif a == "llvm":
            os.environ["CHPL_TARGET_COMPILER_PRGENV"] = chpl_compiler.get_prgenv_compiler()
            os.environ["CHPL_TARGET_COMPILER"] = "llvm"

            llvm = ""
            if "CHPL_LLVM" in os.environ:
                llvm = os.environ["CHPL_LLVM"]
            if "CHPL_MAKE_LLVM" in os.environ:
                llvm = os.environ["CHPL_MAKE_LLVM"]
            if llvm == "":
                llvm = chpl_llvm.get()
            if llvm == "none":
                sys.stderr.write("Cannot get --llvm configuration with CHPL_LLVM=none\n")
                sys.exit(1)
        elif a == "compilecc":
            mysystem(make_helper, "printcompileline")
        elif a == "compilecxx":
            mysystem(make_helper, "printcxxcompileline")
        elif a == "compiler":
            mysystem(make_helper, "printccompiler")
        elif a == "cflags":
            mysystem(make_helper, "printcflags")
        elif a == "cxxflags":
            mysystem(make_helper, "printcxxflags")
        elif a == "includesanddefines":
            mysystem(make_helper, "printincludesanddefines")
        elif a == "libraries":
            mysystem(make_helper, "printlibraries")
        elif a == "linker":
            mysystem(make_helper, "printlinker")
        elif a == "linkershared":
            mysystem(make_helper, "printlinkershared")
        elif a == "maino":
            mysystem(make_helper, "printmaino")
        elif a == "llvminstalldir":
            mysystem(make_helper, "printllvminstall")
        elif a == "clangcc":
            mysystem(make_helper, "printclangcc")
        elif a == "clangcxx":
            mysystem(make_helper, "printclangcxx")
        elif a == "clangsysroot":
            mysystem(make_helper, "printclangcxx")
            llvminstall = myrun(make_helper, "printllvminstall")
            llvminstall = llvminstall.strip()
            fname = os.path.join(llvminstall, "configured-clang-sysroot-arguments")
            if os.path.isfile(fname):
                with open(fname) as f:
                    for line in f:
                        sys.stdout.write(line)
        elif a == "launcherlibdir":
          mysystem(make_helper, "printlauncherlibdir")
        elif a == "multilocale-lib-deps":
          mysystem(make_helper, "printmultilocalelibdeps")
        elif a == "host-c-compiler":
          compiler_family = chpl_compiler.get("host")
          compiler = chpl_compiler.get_compiler_name_c(compiler_family)
          sys.stdout.write("{}\n".format(compiler))
        elif a == "host-cxx-compiler":
          compiler_family = chpl_compiler.get("host")
          compiler = chpl_compiler.get_compiler_name_cxx(compiler_family)
          sys.stdout.write("{}\n".format(compiler))