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
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 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"), classy_repo_name, classy_repo_version, repo_rename=classy_repo_rename, no_progress_bars=no_progress_bars) if not success: log.error("Could not download classy.") return False classy_path = os.path.join(path, "code", classy_repo_rename) log.info("Compiling classy...") from subprocess import Popen, PIPE process_make = Popen(["make"], cwd=classy_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
def install(cls, path=None, data=True, no_progress_bars=False, **_kwargs): if not data: return True log = logging.getLogger(cls.get_qualified_class_name()) opts = cls.get_install_options() if not opts: log.info("No install options. Nothing to do.") return True repo = opts.get("github_repository", None) if repo: from cobaya.install import download_github_release log.info("Downloading %s data..." % repo) return download_github_release(os.path.join(path, "data"), repo, opts.get("github_release", "master"), no_progress_bars=no_progress_bars, logger=log) else: full_path = cls.get_path(path) if not os.path.exists(full_path): os.makedirs(full_path) if not data: return True url = opts["download_url"] log.info("Downloading likelihood data file: %s...", url) from cobaya.install import download_file if not download_file(url, full_path, decompress=True, logger=log, no_progress_bars=no_progress_bars): return False log.info("Likelihood data downloaded and uncompressed correctly.") return True
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 classy_path = cls.get_path(path) 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
def install(cls, path=None, force=False, code=False, data=False, no_progress_bars=False): if not code: return True log = get_logger(__name__) log.info("Downloading PolyChord...") success = download_github_release(os.path.join(path, "code"), cls._pc_repo_name, cls._pc_repo_version, no_progress_bars=no_progress_bars, logger=log) if not success: log.error("Could not download PolyChord.") return False log.info("Compiling (Py)PolyChord...") from subprocess import Popen, PIPE # Needs to re-define os' PWD, # because MakeFile calls it and is not affected by the cwd of Popen cwd = os.path.join(path, "code", cls._pc_repo_name[cls._pc_repo_name.find("/") + 1:]) my_env = os.environ.copy() my_env.update({"PWD": cwd}) if "CC" not in my_env: my_env["CC"] = "mpicc" if "CXX" not in my_env: my_env["CXX"] = "mpicxx" process_make = Popen([sys.executable, "setup.py", "build"], cwd=cwd, env=my_env, stdout=PIPE, stderr=PIPE) out, err = process_make.communicate() if process_make.returncode: log.info(out.decode("utf-8")) log.info(err.decode("utf-8")) log.error("Python build failed!") return False return True
def install(path=None, force=False, code=False, data=True, no_progress_bars=False): if not data: return True log = logging.getLogger(__name__.split(".")[-1]) log.info("Downloading DES data...") return download_github_release(os.path.join(path, "data"), des_data_name, des_data_version, no_progress_bars=no_progress_bars)
def install(path=None, force=False, code=False, data=False, no_progress_bars=False): if not code: return True log = logging.getLogger(__name__.split(".")[-1]) log.info("Downloading PolyChord...") success = download_github_release(os.path.join(path, "code"), pc_repo_name, pc_repo_version, no_progress_bars=no_progress_bars) if not success: log.error("Could not download PolyChord.") return False log.info("Compiling (Py)PolyChord...") from subprocess import Popen, PIPE # Needs to re-define os' PWD, # because MakeFile calls it and is not affected by the cwd of Popen cwd = os.path.join(path, "code", pc_repo_name[pc_repo_name.find("/")+1:]) my_env = os.environ.copy() my_env.update({"PWD": cwd}) process_make = Popen(["make", "pypolychord", "MPI=1"], cwd=cwd, env=my_env, 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 my_env.update({"CC": "mpicc", "CXX": "mpicxx"}) process_make = Popen(["python", "setup.py", "build"], cwd=cwd, env=my_env, stdout=PIPE, stderr=PIPE) out, err = process_make.communicate() if process_make.returncode: log.info(out) log.info(err) log.error("Python build failed!") return False return True
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 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(["python", "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
def install(path=None, force=False, code=False, data=True, no_progress_bars=False): if not data: return True log = logging.getLogger(__name__.split(".")[-1]) log.info("Downloading supplementary likelihood data and covmats...") return download_github_release(os.path.join(path, "data"), supp_data_name, supp_data_version, no_progress_bars=no_progress_bars)
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
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
def install(cls, path=None, force=False, code=False, data=True, no_progress_bars=False): if not data: return True log = logging.getLogger(cls.get_module_name()) opts = cls.get_install_options() repo = opts.get("github_repository", None) if repo: from cobaya.install import download_github_release log.info("Downloading %s data..." % repo) return download_github_release(os.path.join(path, "data"), repo, opts.get("github_release", "master"), no_progress_bars=no_progress_bars, logger=log) else: full_path = cls.get_path(path) if not os.path.exists(full_path): os.makedirs(full_path) if not data: return True filename = opts["download_url"] log.info("Downloading likelihood data file: %s...", filename) from cobaya.install import download_file if not download_file(filename, full_path, decompress=True, logger=log, no_progress_bars=no_progress_bars): return False log.info("Likelihood data downloaded and uncompressed correctly.") return True