summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2018-10-26 17:02:21 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2018-11-09 00:31:24 -0800
commitc27b78ee369bf26ed27b35c6f19a9f546218f8ec (patch)
tree420fd3304c293f4e4ca5e41bc142b4927b913ae0
parent36623a27fd794cb16d31e4e987383895a075b7c2 (diff)
downloadspack-c27b78ee369bf26ed27b35c6f19a9f546218f8ec.tar.gz
spack-c27b78ee369bf26ed27b35c6f19a9f546218f8ec.tar.bz2
spack-c27b78ee369bf26ed27b35c6f19a9f546218f8ec.tar.xz
spack-c27b78ee369bf26ed27b35c6f19a9f546218f8ec.zip
env: remove upgrade() and relocate() for now
- these won't be in the first release of environments - they'll be added back in later
-rw-r--r--lib/spack/spack/cmd/env.py46
-rw-r--r--lib/spack/spack/environment.py66
-rw-r--r--lib/spack/spack/test/cmd/env.py29
3 files changed, 1 insertions, 140 deletions
diff --git a/lib/spack/spack/cmd/env.py b/lib/spack/spack/cmd/env.py
index c2a3e52cb5..5c0ca1e4db 100644
--- a/lib/spack/spack/cmd/env.py
+++ b/lib/spack/spack/cmd/env.py
@@ -6,8 +6,6 @@
import os
import sys
import argparse
-import shutil
-import tempfile
import llnl.util.tty as tty
import llnl.util.filesystem as fs
@@ -37,11 +35,9 @@ subcommands = [
['list', 'ls'],
'add',
['remove', 'rm'],
- 'upgrade',
'concretize',
['status', 'st'],
'loads',
- 'relocate',
'stage',
'install',
'uninstall',
@@ -412,20 +408,6 @@ def env_uninstall(args):
#
-# env relocate
-#
-def env_relocate_setup_parser(subparser):
- """reconcretize environment with new OS and/or compiler"""
- subparser.add_argument('--compiler', help="Compiler spec to use")
-
-
-def env_relocate(args):
- env = get_env(args, 'relocate')
- env.reset_os_and_compiler(compiler=args.compiler)
- env.write()
-
-
-#
# env status
#
def env_status_setup_parser(subparser):
@@ -503,34 +485,6 @@ def env_loads(args):
print(' source %s' % loads_file)
-#
-# env upgrade
-#
-def env_upgrade_setup_parser(subparser):
- """upgrade a dependency package in an environment to the latest version"""
- subparser.add_argument('dep_name', help='Dependency package to upgrade')
- subparser.add_argument('--dry-run', action='store_true', dest='dry_run',
- help="Just show the updates that would take place")
-
-
-def env_upgrade(args):
- env = get_env(args, 'upgrade')
-
- if os.path.exists(env.repos_path):
- repo_stage = tempfile.mkdtemp()
- new_repos_path = os.path.join_path(repo_stage, 'repos')
- shutil.copytree(env.repos_path, new_repos_path)
-
- repo = spack.environment.make_repo_path(new_repos_path)
- if args.dep_name in repo:
- shutil.rmtree(repo.dirname_for_package_name(args.dep_name))
- spack.repo.path.put_first(repo)
-
- new_dep = env.upgrade_dependency(args.dep_name, args.dry_run)
- if not args.dry_run and new_dep:
- env.write(new_dep)
-
-
#: Dictionary mapping subcommand names and aliases to functions
subcommand_functions = {}
diff --git a/lib/spack/spack/environment.py b/lib/spack/spack/environment.py
index 8d2d3dabb1..67c799f7bd 100644
--- a/lib/spack/spack/environment.py
+++ b/lib/spack/spack/environment.py
@@ -21,8 +21,7 @@ import spack.schema.env
import spack.spec
import spack.util.spack_json as sjson
import spack.config
-from spack.spec import Spec, CompilerSpec, FlagMap
-from spack.version import VersionList
+from spack.spec import Spec
#: environment variable used to indicate the active environment
@@ -224,31 +223,6 @@ def list_environments():
return names
-def _reset_os_and_compiler(spec, compiler=None):
- spec = spec.copy()
- for x in spec.traverse():
- x.compiler = None
- x.architecture = None
- x.compiler_flags = FlagMap(x)
- x._concrete = False
- x._hash = None
- if compiler:
- spec.compiler = CompilerSpec(compiler)
- spec.concretize()
- return spec
-
-
-def _upgrade_dependency_version(spec, dep_name):
- spec = spec.copy()
- for x in spec.traverse():
- x._concrete = False
- x._normal = False
- x._hash = None
- spec[dep_name].versions = VersionList(':')
- spec.concretize()
- return spec
-
-
def validate(data, filename=None):
global _validator
if _validator is None:
@@ -635,44 +609,6 @@ class Environment(object):
write_user_spec(s, 'r')
stream.write(c.tree(**kwargs))
- def upgrade_dependency(self, dep_name, dry_run=False):
- # TODO: if you have
- # w -> x -> y
- # and
- # v -> x -> y
- # then it would be desirable to ensure that w and v refer to the
- # same x after upgrading y. This is not currently guaranteed.
- new_order = list()
- new_deps = list()
- for i, spec_hash in enumerate(self.concretized_order):
- spec = self.specs_by_hash[spec_hash]
- if dep_name in spec:
- if dry_run:
- tty.msg("Would upgrade {0} for {1}"
- .format(spec[dep_name].format(), spec.format()))
- else:
- new_spec = _upgrade_dependency_version(spec, dep_name)
- new_order.append(new_spec.dag_hash())
- self.specs_by_hash[new_spec.dag_hash()] = new_spec
- new_deps.append(new_spec[dep_name])
- else:
- new_order.append(spec_hash)
-
- if not dry_run:
- self.concretized_order = new_order
- return new_deps[0] if new_deps else None
-
- def reset_os_and_compiler(self, compiler=None):
- new_order = list()
- new_specs_by_hash = {}
- for spec_hash in self.concretized_order:
- spec = self.specs_by_hash[spec_hash]
- new_spec = _reset_os_and_compiler(spec, compiler)
- new_order.append(new_spec.dag_hash())
- new_specs_by_hash[new_spec.dag_hash()] = new_spec
- self.concretized_order = new_order
- self.specs_by_hash = new_specs_by_hash
-
def _get_environment_specs(self, recurse_dependencies=True):
"""Returns the specs of all the packages in an environment.
If these specs appear under different user_specs, only one copy
diff --git a/lib/spack/spack/test/cmd/env.py b/lib/spack/spack/test/cmd/env.py
index 4f55d72451..b271a07e47 100644
--- a/lib/spack/spack/test/cmd/env.py
+++ b/lib/spack/spack/test/cmd/env.py
@@ -13,7 +13,6 @@ import llnl.util.filesystem as fs
import spack.modules
import spack.environment as ev
from spack.cmd.env import _env_concretize, _env_create
-from spack.version import Version
from spack.spec import Spec
from spack.main import SpackCommand
@@ -139,21 +138,6 @@ def test_remove_command():
assert 'mpileaks' not in env('status', 'test')
-def test_reset_compiler():
- e = ev.create('test')
- e.add('mpileaks')
- e.concretize()
-
- first_spec = e.specs_by_hash[e.concretized_order[0]]
- available = set(['gcc', 'clang'])
- available.remove(first_spec.compiler.name)
- new_compiler = next(iter(available))
- e.reset_os_and_compiler(compiler=new_compiler)
-
- new_spec = e.specs_by_hash[e.concretized_order[0]]
- assert new_spec.compiler != first_spec.compiler
-
-
def test_environment_status():
e = ev.create('test')
e.add('mpileaks')
@@ -168,19 +152,6 @@ def test_environment_status():
assert mpileaks_spec.format() in list_content
-def test_upgrade_dependency():
- e = ev.create('test')
- e.add('mpileaks ^callpath@0.9')
- e.concretize()
-
- e.upgrade_dependency('callpath')
- env_specs = e._get_environment_specs()
- callpath_dependents = list(x for x in env_specs if 'callpath' in x)
- assert callpath_dependents
- for spec in callpath_dependents:
- assert spec['callpath'].version == Version('1.0')
-
-
def test_to_lockfile_dict():
e = ev.create('test')
e.add('mpileaks')