def create_env(prefix, specs, clear_cache=True): ''' Create a conda envrionment for the given prefix and specs. ''' specs = list(specs) for feature, value in feature_list: if value: specs.append('%s@' % feature) for d in config.bldpkgs_dirs: if not isdir(d): os.makedirs(d) update_index(d) if specs: # Don't waste time if there is nothing to do index = get_build_index(clear_cache=True) warn_on_old_conda_build(index) cc.pkgs_dirs = cc.pkgs_dirs[:1] actions = plan.install_actions(prefix, index, specs) plan.display_actions(actions, index) plan.execute_actions(actions, index, verbose=verbose) # ensure prefix exists, even if empty, i.e. when specs are empty if not isdir(prefix): os.makedirs(prefix) if on_win: shell = "cmd.exe" else: shell = "bash" symlink_conda(prefix, sys.prefix, shell)
def gen_test_env_paths(envs, num_test_folders=3): """People need not use all the test folders listed here. This is only for shortening the environment string generation. Also encapsulates paths in double quotes. """ paths = [join(envs, "test{}".format(test_folder+1)) for test_folder in range(num_test_folders)] for path in paths[:2]: # Create symlinks ONLY for the first two folders. symlink_conda(path, sys.prefix) return paths
def gen_test_env_paths(envs, shell, num_test_folders=5): """People need not use all the test folders listed here. This is only for shortening the environment string generation. Also encapsulates paths in double quotes. """ paths = [os.path.join(envs, "test {}".format(test_folder+1)) for test_folder in range(num_test_folders)] for path in paths[:2]: # Create symlinks ONLY for the first two folders. symlink_conda(path, sys.prefix, shell) converter = shells[shell]["path_to"] paths = [converter(path) for path in paths] return paths
def execute(args, parser): name = args.remote_definition or args.name try: spec = specs.detect(name=name, filename=args.file, directory=os.getcwd()) env = spec.environment # FIXME conda code currently requires args to have a name or prefix # don't overwrite name if it's given. gh-254 if args.prefix is None and args.name is None: args.name = env.name except exceptions.SpecNotFound: raise prefix = get_prefix(args, search=False) if args.force and not is_root_prefix(prefix) and os.path.exists(prefix): rm_rf(prefix) cli_install.check_prefix(prefix, json=args.json) # TODO, add capability # common.ensure_override_channels_requires_channel(args) # channel_urls = args.channel or () # special case for empty environment if not env.dependencies: from conda.install import symlink_conda from conda.base.context import context symlink_conda(prefix, context.root_dir) for installer_type, pkg_specs in env.dependencies.items(): try: installer = get_installer(installer_type) installer.install(prefix, pkg_specs, args, env) except InvalidInstaller: sys.stderr.write( textwrap.dedent(""" Unable to install package for {0}. Please double check and ensure you dependencies file has the correct spelling. You might also try installing the conda-env-{0} package to see if provides the required installer. """).lstrip().format(installer_type)) return -1 touch_nonadmin(prefix) if not args.json: print(cli_install.print_activate(args.name if args.name else prefix))
def execute(args, parser): name = args.remote_definition or args.name try: spec = specs.detect(name=name, filename=args.file, directory=os.getcwd()) env = spec.environment # FIXME conda code currently requires args to have a name or prefix # don't overwrite name if it's given. gh-254 if args.prefix is None and args.name is None: args.name = env.name except exceptions.SpecNotFound: raise prefix = get_prefix(args, search=False) if args.force and not is_root_prefix(prefix) and os.path.exists(prefix): rm_rf(prefix) cli_install.check_prefix(prefix, json=args.json) # TODO, add capability # common.ensure_override_channels_requires_channel(args) # channel_urls = args.channel or () # special case for empty environment if not env.dependencies: from conda.install import symlink_conda from conda.base.context import context symlink_conda(prefix, context.root_dir) for installer_type, pkg_specs in env.dependencies.items(): try: installer = get_installer(installer_type) installer.install(prefix, pkg_specs, args, env) except InvalidInstaller: sys.stderr.write(textwrap.dedent(""" Unable to install package for {0}. Please double check and ensure you dependencies file has the correct spelling. You might also try installing the conda-env-{0} package to see if provides the required installer. """).lstrip().format(installer_type) ) return -1 touch_nonadmin(prefix) if not args.json: print(cli_install.print_activate(args.name if args.name else prefix))
def create_env(prefix, specs, clear_cache=True, debug=False): ''' Create a conda envrionment for the given prefix and specs. ''' if not debug: # This squelches a ton of conda output that is not hugely relevant logging.getLogger("conda.install").setLevel(logging.ERROR) logging.getLogger("fetch").setLevel(logging.WARN) logging.getLogger("print").setLevel(logging.WARN) logging.getLogger("progress").setLevel(logging.WARN) logging.getLogger("dotupdate").setLevel(logging.WARN) logging.getLogger("stdoutlog").setLevel(logging.WARN) logging.getLogger("requests.packages.urllib3.connectionpool").setLevel( logging.WARN) specs = list(specs) for feature, value in feature_list: if value: specs.append('%s@' % feature) for d in config.bldpkgs_dirs: if not isdir(d): os.makedirs(d) update_index(d) if specs: # Don't waste time if there is nothing to do # FIXME: stupid hack to put test prefix on PATH so that runtime libs can be found old_path = os.environ['PATH'] os.environ['PATH'] = prepend_bin_path(os.environ.copy(), prefix, True)['PATH'] index = get_build_index(clear_cache=True) warn_on_old_conda_build(index) cc.pkgs_dirs = cc.pkgs_dirs[:1] actions = plan.install_actions(prefix, index, specs) plan.display_actions(actions, index) plan.execute_actions(actions, index, verbose=debug) os.environ['PATH'] = old_path # ensure prefix exists, even if empty, i.e. when specs are empty if not isdir(prefix): os.makedirs(prefix) if on_win: shell = "cmd.exe" else: shell = "bash" symlink_conda(prefix, sys.prefix, shell)
def create_env(prefix, specs, clear_cache=True, debug=False): ''' Create a conda envrionment for the given prefix and specs. ''' if not debug: # This squelches a ton of conda output that is not hugely relevant logging.getLogger("conda.install").setLevel(logging.ERROR) logging.getLogger("fetch").setLevel(logging.WARN) logging.getLogger("print").setLevel(logging.WARN) logging.getLogger("progress").setLevel(logging.WARN) logging.getLogger("dotupdate").setLevel(logging.WARN) logging.getLogger("stdoutlog").setLevel(logging.WARN) logging.getLogger("requests.packages.urllib3.connectionpool").setLevel(logging.WARN) specs = list(specs) for feature, value in feature_list: if value: specs.append('%s@' % feature) for d in config.bldpkgs_dirs: if not isdir(d): os.makedirs(d) update_index(d) if specs: # Don't waste time if there is nothing to do # FIXME: stupid hack to put test prefix on PATH so that runtime libs can be found old_path = os.environ['PATH'] os.environ['PATH'] = prepend_bin_path(os.environ.copy(), prefix, True)['PATH'] index = get_build_index(clear_cache=True) warn_on_old_conda_build(index) cc.pkgs_dirs = cc.pkgs_dirs[:1] actions = plan.install_actions(prefix, index, specs) plan.display_actions(actions, index) plan.execute_actions(actions, index, verbose=debug) os.environ['PATH'] = old_path # ensure prefix exists, even if empty, i.e. when specs are empty if not isdir(prefix): os.makedirs(prefix) if on_win: shell = "cmd.exe" else: shell = "bash" symlink_conda(prefix, sys.prefix, shell)
def execute_plan(plan, index=None, verbose=False): if verbose: from conda.console import setup_verbose_handlers setup_verbose_handlers() # set default prefix prefix = config.root_dir i = None cmds = cmds_from_plan(plan) for cmd, arg in cmds: if i is not None and cmd in progress_cmds: i += 1 getLogger('progress.update').info((install.name_dist(arg), i)) if cmd == PREFIX: prefix = arg elif cmd == PRINT: getLogger('print').info(arg) elif cmd == FETCH: fetch(index, arg) elif cmd == PROGRESS: i = 0 maxval = int(arg) getLogger('progress.start').info(maxval) elif cmd == EXTRACT: install.extract(config.pkgs_dirs[0], arg) elif cmd == RM_EXTRACTED: install.rm_extracted(config.pkgs_dirs[0], arg) elif cmd == RM_FETCHED: install.rm_fetched(config.pkgs_dirs[0], arg) elif cmd == LINK: link(prefix, arg, index=index) elif cmd == UNLINK: install.unlink(prefix, arg) elif cmd == SYMLINK_CONDA: install.symlink_conda(prefix, arg) else: raise Exception("Did not expect command: %r" % cmd) if i is not None and cmd in progress_cmds and maxval == i: i = None getLogger('progress.stop').info(None) install.messages(prefix)
def execute_plan(plan, index=None, verbose=False): if verbose: from conda.console import setup_verbose_handlers setup_verbose_handlers() # set default prefix prefix = config.root_dir i = None cmds = cmds_from_plan(plan) for cmd, arg in cmds: if i is not None and cmd in progress_cmds: i += 1 getLogger('progress.update').info((install.name_dist(arg), i)) if cmd == PREFIX: prefix = arg elif cmd == PRINT: getLogger('print').info(arg) elif cmd == FETCH: fetch(index, arg) elif cmd == PROGRESS: i = 0 maxval = int(arg) getLogger('progress.start').info(maxval) elif cmd == EXTRACT: install.extract(config.pkgs_dirs[0], arg) elif cmd == RM_EXTRACTED: install.rm_extracted(config.pkgs_dirs[0], arg) elif cmd == RM_FETCHED: install.rm_fetched(config.pkgs_dirs[0], arg) elif cmd == LINK: link(prefix, arg) elif cmd == UNLINK: install.unlink(prefix, arg) elif cmd == SYMLINK_CONDA: install.symlink_conda(prefix, arg) else: raise Exception("Did not expect command: %r" % cmd) if i is not None and cmd in progress_cmds and maxval == i: i = None getLogger('progress.stop').info(None) install.messages(prefix)
def SYMLINK_CONDA_CMD(state, arg): install.symlink_conda(state['prefix'], arg)
def SYMLINK_CONDA_CMD(state, arg): install.symlink_conda(state['prefix'], arg, find_parent_shell())
def SYMLINK_CONDA_CMD(state, root_dir): install.symlink_conda(state['prefix'], root_dir)
def create_env(prefix, specs, clear_cache=True, debug=False): ''' Create a conda envrionment for the given prefix and specs. ''' if debug: logging.getLogger("conda").setLevel(logging.DEBUG) logging.getLogger("binstar").setLevel(logging.DEBUG) logging.getLogger("install").setLevel(logging.DEBUG) logging.getLogger("conda.install").setLevel(logging.DEBUG) logging.getLogger("fetch").setLevel(logging.DEBUG) logging.getLogger("print").setLevel(logging.DEBUG) logging.getLogger("progress").setLevel(logging.DEBUG) logging.getLogger("dotupdate").setLevel(logging.DEBUG) logging.getLogger("stdoutlog").setLevel(logging.DEBUG) logging.getLogger("requests").setLevel(logging.DEBUG) else: # This squelches a ton of conda output that is not hugely relevant logging.getLogger("conda").setLevel(logging.WARN) logging.getLogger("binstar").setLevel(logging.WARN) logging.getLogger("install").setLevel(logging.ERROR) logging.getLogger("conda.install").setLevel(logging.ERROR) logging.getLogger("fetch").setLevel(logging.WARN) logging.getLogger("print").setLevel(logging.WARN) logging.getLogger("progress").setLevel(logging.WARN) logging.getLogger("dotupdate").setLevel(logging.WARN) logging.getLogger("stdoutlog").setLevel(logging.WARN) logging.getLogger("requests").setLevel(logging.WARN) specs = list(specs) for feature, value in feature_list: if value: specs.append('%s@' % feature) for d in config.bldpkgs_dirs: if not isdir(d): os.makedirs(d) update_index(d) if specs: # Don't waste time if there is nothing to do # FIXME: stupid hack to put test prefix on PATH so that runtime libs can be found old_path = os.environ['PATH'] os.environ['PATH'] = prepend_bin_path(os.environ.copy(), prefix, True)['PATH'] index = get_build_index(clear_cache=True) warn_on_old_conda_build(index) cc.pkgs_dirs = cc.pkgs_dirs[:1] actions = plan.install_actions(prefix, index, specs) plan.display_actions(actions, index) try: plan.execute_actions(actions, index, verbose=debug) except SystemExit as exc: if "too short in" in exc.message and config.prefix_length > 80: log.warn("Build prefix failed with prefix length {0}.".format( config.prefix_length)) log.warn("Error was: ") log.warn(exc.message) log.warn( "One or more of your package dependencies needs to be rebuilt with a " "longer prefix length.") log.warn( "Falling back to legacy prefix length of 80 characters.") log.warn( "Your package will not install into prefixes longer than 80 characters." ) config.prefix_length = 80 create_env(prefix, specs, clear_cache=clear_cache, debug=debug) os.environ['PATH'] = old_path # ensure prefix exists, even if empty, i.e. when specs are empty if not isdir(prefix): os.makedirs(prefix) if on_win: shell = "cmd.exe" else: shell = "bash" symlink_conda(prefix, sys.prefix, shell)
def create_env(prefix, specs, clear_cache=True, debug=False): ''' Create a conda envrionment for the given prefix and specs. ''' if debug: logging.getLogger("conda").setLevel(logging.DEBUG) logging.getLogger("binstar").setLevel(logging.DEBUG) logging.getLogger("install").setLevel(logging.DEBUG) logging.getLogger("conda.install").setLevel(logging.DEBUG) logging.getLogger("fetch").setLevel(logging.DEBUG) logging.getLogger("print").setLevel(logging.DEBUG) logging.getLogger("progress").setLevel(logging.DEBUG) logging.getLogger("dotupdate").setLevel(logging.DEBUG) logging.getLogger("stdoutlog").setLevel(logging.DEBUG) logging.getLogger("requests").setLevel(logging.DEBUG) else: # This squelches a ton of conda output that is not hugely relevant logging.getLogger("conda").setLevel(logging.WARN) logging.getLogger("binstar").setLevel(logging.WARN) logging.getLogger("install").setLevel(logging.ERROR) logging.getLogger("conda.install").setLevel(logging.ERROR) logging.getLogger("fetch").setLevel(logging.WARN) logging.getLogger("print").setLevel(logging.WARN) logging.getLogger("progress").setLevel(logging.WARN) logging.getLogger("dotupdate").setLevel(logging.WARN) logging.getLogger("stdoutlog").setLevel(logging.WARN) logging.getLogger("requests").setLevel(logging.WARN) specs = list(specs) for feature, value in feature_list: if value: specs.append('%s@' % feature) for d in config.bldpkgs_dirs: if not isdir(d): os.makedirs(d) update_index(d) if specs: # Don't waste time if there is nothing to do # FIXME: stupid hack to put test prefix on PATH so that runtime libs can be found old_path = os.environ['PATH'] os.environ['PATH'] = prepend_bin_path(os.environ.copy(), prefix, True)['PATH'] index = get_build_index(clear_cache=True) warn_on_old_conda_build(index) cc.pkgs_dirs = cc.pkgs_dirs[:1] actions = plan.install_actions(prefix, index, specs) plan.display_actions(actions, index) try: plan.execute_actions(actions, index, verbose=debug) except SystemExit as exc: if "too short in" in exc.message and config.prefix_length > 80: log.warn("Build prefix failed with prefix length {0}." .format(config.prefix_length)) log.warn("Error was: ") log.warn(exc.message) log.warn("One or more of your package dependencies needs to be rebuilt with a " "longer prefix length.") log.warn("Falling back to legacy prefix length of 80 characters.") log.warn("Your package will not install into prefixes longer than 80 characters.") config.prefix_length = 80 create_env(prefix, specs, clear_cache=clear_cache, debug=debug) os.environ['PATH'] = old_path # ensure prefix exists, even if empty, i.e. when specs are empty if not isdir(prefix): os.makedirs(prefix) if on_win: shell = "cmd.exe" else: shell = "bash" symlink_conda(prefix, sys.prefix, shell)