def env_remove(args): """Remove a *named* environment. This removes an environment managed by Spack. Directory environments and `spack.yaml` files embedded in repositories should be removed manually. """ read_envs = [] for env_name in args.rm_env: env = ev.read(env_name) read_envs.append(env) if not args.yes_to_all: answer = tty.get_yes_or_no( 'Really remove %s %s?' % ( string.plural(len(args.rm_env), 'environment', show_n=False), string.comma_and(args.rm_env)), default=False) if not answer: tty.die("Will not remove any environments") for env in read_envs: if env.active: tty.die("Environment %s can't be removed while activated." % env.name) env.destroy() tty.msg("Successfully removed environment '%s'" % env.name)
def env_remove(args): """Remove a *named* environment. This removes an environment managed by Spack. Directory environments and `spack.yaml` files embedded in repositories should be removed manually. """ read_envs = [] for env_name in args.rm_env: env = ev.read(env_name) read_envs.append(env) if not args.yes_to_all: answer = tty.get_yes_or_no( 'Really remove %s %s?' % ( string.plural(len(args.rm_env), 'environment', show_n=False), string.comma_and(args.rm_env)), default=False) if not answer: tty.die("Will not remove any environments") for env in read_envs: if env.active: tty.die("Environment %s can't be removed while activated.") env.destroy() tty.msg("Successfully removed environment '%s'" % env.name)
def _check_version_attributes(fetcher, pkg, version): """Ensure that the fetcher for a version is not ambiguous. This assumes that we have already determined the fetcher for the specific version using ``for_package_version()`` """ all_optionals = set(a for s in all_strategies for a in s.optional_attrs) args = pkg.versions[version] extra = set(args) - set(fetcher.optional_attrs) - set([fetcher.url_attr]) extra.intersection_update(all_optionals) if extra: legal_attrs = [fetcher.url_attr] + list(fetcher.optional_attrs) raise FetcherConflict( "%s version '%s' has extra arguments: %s" % (pkg.name, version, comma_and(quote(extra))), "Valid arguments for a %s fetcher are: \n %s" % (fetcher.url_attr, comma_and(quote(legal_attrs))))
def check_pkg_attributes(pkg): """Find ambiguous top-level fetch attributes in a package. Currently this only ensures that two or more VCS fetch strategies are not specified at once. """ # a single package cannot have URL attributes for multiple VCS fetch # strategies *unless* they are the same attribute. conflicts = set( [s.url_attr for s in all_strategies if hasattr(pkg, s.url_attr)]) # URL isn't a VCS fetch method. We can use it with a VCS method. conflicts -= set(['url']) if len(conflicts) > 1: raise FetcherConflict( 'Package %s cannot specify %s together. Pick at most one.' % (pkg.name, comma_and(quote(conflicts))))
def check_pkg_attributes(pkg): """Find ambiguous top-level fetch attributes in a package. Currently this only ensures that two or more VCS fetch strategies are not specified at once. """ # a single package cannot have URL attributes for multiple VCS fetch # strategies *unless* they are the same attribute. conflicts = set([s.url_attr for s in all_strategies if hasattr(pkg, s.url_attr)]) # URL isn't a VCS fetch method. We can use it with a VCS method. conflicts -= set(['url']) if len(conflicts) > 1: raise FetcherConflict( 'Package %s cannot specify %s together. Pick at most one.' % (pkg.name, comma_and(quote(conflicts))))