コード例 #1
0
ファイル: camb.py プロジェクト: scamera/cobaya
 def install(cls, path=None, code=True, no_progress_bars=False, **kwargs):
     log = logging.getLogger(cls.__name__)
     if not code:
         log.info("Code not requested. Nothing to do.")
         return True
     log.info("Downloading camb...")
     success = download_github_release(
         os.path.join(path, "code"), cls._camb_repo_name, cls._camb_repo_version,
         no_progress_bars=no_progress_bars, logger=log)
     if not success:
         log.error("Could not download camb.")
         return False
     camb_path = cls.get_path(path)
     log.info("Compiling camb...")
     from subprocess import Popen, PIPE
     process_make = Popen([sys.executable, "setup.py", "build_cluster"],
                          cwd=camb_path, stdout=PIPE, stderr=PIPE)
     out, err = process_make.communicate()
     if process_make.returncode:
         log.info(out.decode())
         log.info(err.decode())
         gcc_check = check_gcc_version(cls._camb_min_gcc_version, error_returns=False)
         if not gcc_check:
             cause = (" Possible cause: it looks like `gcc` does not have the correct "
                      "version number (CAMB requires %s); and `ifort` is also "
                      "probably not available." % cls._camb_min_gcc_version)
         else:
             cause = ""
         log.error("Compilation failed!" + cause)
         return False
     return True
コード例 #2
0
 def install(cls,
             path=None,
             force=False,
             code=True,
             no_progress_bars=False,
             **kwargs):
     log = logging.getLogger(cls.__name__)
     if not code:
         log.info("Code not requested. Nothing to do.")
         return True
     log.info("Installing pre-requisites...")
     exit_status = pip_install("cython")
     if exit_status:
         log.error("Could not install pre-requisite: cython")
         return False
     log.info("Downloading classy...")
     success = download_github_release(os.path.join(path, "code"),
                                       cls._classy_repo_name,
                                       cls._classy_repo_version,
                                       repo_rename=cls.__name__,
                                       no_progress_bars=no_progress_bars,
                                       logger=log)
     if not success:
         log.error("Could not download classy.")
         return False
     # Compilation
     # gcc check after downloading, in case the user wants to change the compiler by
     # hand in the Makefile
     classy_path = cls.get_path(path)
     if not check_gcc_version(cls._classy_min_gcc_version,
                              error_returns=False):
         log.error(
             "Your gcc version is too low! CLASS would probably compile, "
             "but it would leak memory when running a chain. Please use a "
             "gcc version newer than %s. You can still compile CLASS by hand, "
             "maybe changing the compiler in the Makefile. CLASS has been "
             "downloaded into %r", cls._classy_min_gcc_version, classy_path)
         return False
     log.info("Compiling classy...")
     from subprocess import Popen, PIPE
     env = deepcopy(os.environ)
     env.update({"PYTHON": sys.executable})
     process_make = Popen(["make"],
                          cwd=classy_path,
                          stdout=PIPE,
                          stderr=PIPE,
                          env=env)
     out, err = process_make.communicate()
     if process_make.returncode:
         log.info(out)
         log.info(err)
         log.error("Compilation failed!")
         return False
     return True
コード例 #3
0
ファイル: camb.py プロジェクト: nbahti/cobaya
def install(path=None,
            force=False,
            code=True,
            no_progress_bars=False,
            **kwargs):
    log = logging.getLogger(__name__.split(".")[-1])
    if not code:
        log.info("Code not requested. Nothing to do.")
        return True
    gcc_check = check_gcc_version(camb_min_gcc_version, error_returns=-1)
    if gcc_check == -1:
        log.warn("Failed to get gcc version (maybe not using gcc?). "
                 "Going ahead and hoping for the best.")
    elif not gcc_check:
        log.error(
            "CAMB requires a gcc version >= %s, "
            "which is higher than your current one.", camb_min_gcc_version)
        raise HandledException
    log.info("Downloading camb...")
    success = download_github_release(os.path.join(path, "code"),
                                      camb_repo_name,
                                      camb_repo_version,
                                      no_progress_bars=no_progress_bars)
    if not success:
        log.error("Could not download camb.")
        return False
    camb_path = os.path.join(path, "code",
                             camb_repo_name[camb_repo_name.find("/") + 1:])
    log.info("Compiling camb...")
    from subprocess import Popen, PIPE
    process_make = Popen([sys.executable, "setup.py", "build_cluster"],
                         cwd=camb_path,
                         stdout=PIPE,
                         stderr=PIPE)
    out, err = process_make.communicate()
    if process_make.returncode:
        log.info(out)
        log.info(err)
        log.error("Compilation failed!")
        return False
    return True