if not path: return {} try: import yaml except ImportError: sys.exit("Error: could not import yaml (required to read .condarc " "config file)") return yaml.load(open(path)) or {} rc = load_condarc(rc_path) # ----- local directories ----- root_dir = abspath(expanduser(os.getenv("CONDA_ROOT", rc.get("root_dir", sys.prefix)))) root_writable = try_write(root_dir) root_env_name = "root" def _pathsep_env(name): x = os.getenv(name) if x: return x.split(os.pathsep) else: return [] def _default_envs_dirs(): lst = [join(root_dir, "envs")] if not root_writable: lst.insert(0, "~/envs")
def default_dirs(tp='pkgs'): lst = [join(root_dir, tp)] if not try_write(lst[0]): lst.insert(0, abspath(join(expanduser('~/conda'), tp))) return lst