本文整理汇总了Python中spack.spec.Spec类的典型用法代码示例。如果您正苦于以下问题:Python Spec类的具体用法?Python Spec怎么用?Python Spec使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Spec类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: read_spec
def read_spec(self, path):
"""Read the contents of a file and parse them as a spec"""
with closing(open(path)) as spec_file:
# Specs from files are assumed normal and concrete
spec = Spec(spec_file.read().replace('\n', ''))
if all(spack.db.exists(s.name) for s in spec.traverse()):
copy = spec.copy()
# TODO: It takes a lot of time to normalize every spec on read.
# TODO: Storing graph info with spec files would fix this.
copy.normalize()
if copy.concrete:
return copy # These are specs spack still understands.
# If we get here, either the spec is no longer in spack, or
# something about its dependencies has changed. So we need to
# just assume the read spec is correct. We'll lose graph
# information if we do this, but this is just for best effort
# for commands like uninstall and find. Currently Spack
# doesn't do anything that needs the graph info after install.
# TODO: store specs with full connectivity information, so
# that we don't have to normalize or reconstruct based on
# changing dependencies in the Spack tree.
spec._normal = True
spec._concrete = True
return spec
开发者ID:AaronTHolt,项目名称:spack,代码行数:28,代码来源:directory_layout.py
示例2: test_yaml_subdag
def test_yaml_subdag(config, builtin_mock):
spec = Spec('mpileaks^mpich+debug')
spec.concretize()
yaml_spec = Spec.from_yaml(spec.to_yaml())
for dep in ('callpath', 'mpich', 'dyninst', 'libdwarf', 'libelf'):
assert spec[dep].eq_dag(yaml_spec[dep])
开发者ID:justintoo,项目名称:spack,代码行数:7,代码来源:spec_yaml.py
示例3: remove
def remove(self, query_spec, force=False):
"""Remove specs from an environment that match a query_spec"""
query_spec = Spec(query_spec)
# try abstract specs first
matches = []
if not query_spec.concrete:
matches = [s for s in self.user_specs if s.satisfies(query_spec)]
if not matches:
# concrete specs match against concrete specs in the env
specs_hashes = zip(
self.concretized_user_specs, self.concretized_order)
matches = [
s for s, h in specs_hashes if query_spec.dag_hash() == h]
if not matches:
raise SpackEnvironmentError("Not found: {0}".format(query_spec))
for spec in matches:
if spec in self.user_specs:
self.user_specs.remove(spec)
if force and spec in self.concretized_user_specs:
i = self.concretized_user_specs.index(spec)
del self.concretized_user_specs[i]
dag_hash = self.concretized_order[i]
del self.concretized_order[i]
del self.specs_by_hash[dag_hash]
开发者ID:LLNL,项目名称:spack,代码行数:30,代码来源:environment.py
示例4: test_test_deptype
def test_test_deptype():
"""Ensure that test-only dependencies are only included for specified
packages in the following spec DAG::
w
/|
x y
|
z
w->y deptypes are (link, build), w->x and y->z deptypes are (test)
"""
default = ('build', 'link')
test_only = ('test',)
x = MockPackage('x', [], [])
z = MockPackage('z', [], [])
y = MockPackage('y', [z], [test_only])
w = MockPackage('w', [x, y], [test_only, default])
mock_repo = MockPackageMultiRepo([w, x, y, z])
with spack.repo.swap(mock_repo):
spec = Spec('w')
spec.concretize(tests=(w.name,))
assert ('x' in spec)
assert ('z' not in spec)
开发者ID:LLNL,项目名称:spack,代码行数:28,代码来源:spec_dag.py
示例5: test_equal
def test_equal(self):
# Different spec structures to test for equality
flat = Spec.from_literal(
{'mpileaks ^callpath ^libelf ^libdwarf': None}
)
flat_init = Spec.from_literal({
'mpileaks': {
'callpath': None,
'libdwarf': None,
'libelf': None
}
})
flip_flat = Spec.from_literal({
'mpileaks': {
'libelf': None,
'libdwarf': None,
'callpath': None
}
})
dag = Spec.from_literal({
'mpileaks': {
'callpath': {
'libdwarf': {
'libelf': None
}
}
}
})
flip_dag = Spec.from_literal({
'mpileaks': {
'callpath': {
'libelf': {
'libdwarf': None
}
}
}
})
# All these are equal to each other with regular ==
specs = (flat, flat_init, flip_flat, dag, flip_dag)
for lhs, rhs in zip(specs, specs):
assert lhs == rhs
assert str(lhs) == str(rhs)
# Same DAGs constructed different ways are equal
assert flat.eq_dag(flat_init)
# order at same level does not matter -- (dep on same parent)
assert flat.eq_dag(flip_flat)
# DAGs should be unequal if nesting is different
assert not flat.eq_dag(dag)
assert not flat.eq_dag(flip_dag)
assert not flip_flat.eq_dag(dag)
assert not flip_flat.eq_dag(flip_dag)
assert not dag.eq_dag(flip_dag)
开发者ID:LLNL,项目名称:spack,代码行数:60,代码来源:spec_dag.py
示例6: test_using_ordered_dict
def test_using_ordered_dict(builtin_mock):
""" Checks that dicts are ordered
Necessary to make sure that dag_hash is stable across python
versions and processes.
"""
def descend_and_check(iterable, level=0):
if isinstance(iterable, Mapping):
assert isinstance(iterable, syaml_dict)
return descend_and_check(iterable.values(), level=level + 1)
max_level = level
for value in iterable:
if isinstance(value, Iterable) and not isinstance(value, str):
nlevel = descend_and_check(value, level=level + 1)
if nlevel > max_level:
max_level = nlevel
return max_level
specs = ['mpileaks ^zmpi', 'dttop', 'dtuse']
for spec in specs:
dag = Spec(spec)
dag.normalize()
from pprint import pprint
pprint(dag.to_node_dict())
break
level = descend_and_check(dag.to_node_dict())
# level just makes sure we are doing something here
assert level >= 5
开发者ID:justintoo,项目名称:spack,代码行数:30,代码来源:spec_yaml.py
示例7: test_dynamic_dot_graph_mpileaks
def test_dynamic_dot_graph_mpileaks(mock_packages):
"""Test dynamically graphing the mpileaks package."""
s = Spec('mpileaks').normalized()
stream = StringIO()
graph_dot([s], static=False, out=stream)
dot = stream.getvalue()
mpileaks_hash, mpileaks_lbl = s.dag_hash(), s.format('$_$/')
mpi_hash, mpi_lbl = s['mpi'].dag_hash(), s['mpi'].format('$_$/')
callpath_hash, callpath_lbl = (
s['callpath'].dag_hash(), s['callpath'].format('$_$/'))
dyninst_hash, dyninst_lbl = (
s['dyninst'].dag_hash(), s['dyninst'].format('$_$/'))
libdwarf_hash, libdwarf_lbl = (
s['libdwarf'].dag_hash(), s['libdwarf'].format('$_$/'))
libelf_hash, libelf_lbl = (
s['libelf'].dag_hash(), s['libelf'].format('$_$/'))
assert ' "%s" [label="%s"]\n' % (mpileaks_hash, mpileaks_lbl) in dot
assert ' "%s" [label="%s"]\n' % (callpath_hash, callpath_lbl) in dot
assert ' "%s" [label="%s"]\n' % (mpi_hash, mpi_lbl) in dot
assert ' "%s" [label="%s"]\n' % (dyninst_hash, dyninst_lbl) in dot
assert ' "%s" [label="%s"]\n' % (libdwarf_hash, libdwarf_lbl) in dot
assert ' "%s" [label="%s"]\n' % (libelf_hash, libelf_lbl) in dot
assert ' "%s" -> "%s"\n' % (dyninst_hash, libdwarf_hash) in dot
assert ' "%s" -> "%s"\n' % (callpath_hash, dyninst_hash) in dot
assert ' "%s" -> "%s"\n' % (mpileaks_hash, mpi_hash) in dot
assert ' "%s" -> "%s"\n' % (libdwarf_hash, libelf_hash) in dot
assert ' "%s" -> "%s"\n' % (callpath_hash, mpi_hash) in dot
assert ' "%s" -> "%s"\n' % (mpileaks_hash, callpath_hash) in dot
assert ' "%s" -> "%s"\n' % (dyninst_hash, libelf_hash) in dot
开发者ID:LLNL,项目名称:spack,代码行数:34,代码来源:graph.py
示例8: test_with_or_without
def test_with_or_without(self):
s = Spec('a')
s.concretize()
pkg = spack.repo.get(s)
# Called without parameters
options = pkg.with_or_without('foo')
assert '--with-bar' in options
assert '--without-baz' in options
assert '--no-fee' in options
def activate(value):
return 'something'
options = pkg.with_or_without('foo', activation_value=activate)
assert '--with-bar=something' in options
assert '--without-baz' in options
assert '--no-fee' in options
options = pkg.enable_or_disable('foo')
assert '--enable-bar' in options
assert '--disable-baz' in options
assert '--disable-fee' in options
options = pkg.with_or_without('bvv')
assert '--with-bvv' in options
开发者ID:LLNL,项目名称:spack,代码行数:26,代码来源:build_systems.py
示例9: test_install_overwrite
def test_install_overwrite(
mock_packages, mock_archive, mock_fetch, config, install_mockery
):
# It's not possible to overwrite something that is not yet installed
with pytest.raises(AssertionError):
install('--overwrite', 'libdwarf')
# --overwrite requires a single spec
with pytest.raises(AssertionError):
install('--overwrite', 'libdwarf', 'libelf')
# Try to install a spec and then to reinstall it.
spec = Spec('libdwarf')
spec.concretize()
install('libdwarf')
assert os.path.exists(spec.prefix)
expected_md5 = fs.hash_directory(spec.prefix)
# Modify the first installation to be sure the content is not the same
# as the one after we reinstalled
with open(os.path.join(spec.prefix, 'only_in_old'), 'w') as f:
f.write('This content is here to differentiate installations.')
bad_md5 = fs.hash_directory(spec.prefix)
assert bad_md5 != expected_md5
install('--overwrite', '-y', 'libdwarf')
assert os.path.exists(spec.prefix)
assert fs.hash_directory(spec.prefix) == expected_md5
assert fs.hash_directory(spec.prefix) != bad_md5
开发者ID:LLNL,项目名称:spack,代码行数:33,代码来源:install.py
示例10: test_patched_dependency
def test_patched_dependency(
mock_packages, config, install_mockery, mock_fetch):
"""Test whether patched dependencies work."""
spec = Spec('patch-a-dependency')
spec.concretize()
assert 'patches' in list(spec['libelf'].variants.keys())
# make sure the patch makes it into the dependency spec
assert (('c45c1564f70def3fc1a6e22139f62cb21cd190cc3a7dbe6f4120fa59ce33dcb8',) ==
spec['libelf'].variants['patches'].value)
# make sure the patch in the dependent's directory is applied to the
# dependency
libelf = spec['libelf']
pkg = libelf.package
pkg.do_patch()
with pkg.stage:
with working_dir(pkg.stage.source_path):
# output a Makefile with 'echo Patched!' as the default target
configure = Executable('./configure')
configure()
# Make sure the Makefile contains the patched text
with open('Makefile') as mf:
assert 'Patched!' in mf.read()
开发者ID:LLNL,项目名称:spack,代码行数:25,代码来源:patch.py
示例11: test_conditional_patched_deps_with_conditions
def test_conditional_patched_deps_with_conditions(mock_packages, config):
"""Test whether conditional patched dependencies with conditions work."""
spec = Spec('patch-several-dependencies @1.0 ^[email protected]')
spec.concretize()
# basic patch on libelf
assert 'patches' in list(spec['libelf'].variants.keys())
# foo
assert ('b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c'
in spec['libelf'].variants['patches'].value)
# conditional patch on libdwarf
assert 'patches' in list(spec['libdwarf'].variants.keys())
# bar
assert ('7d865e959b2466918c9863afca942d0fb89d7c9ac0c99bafc3749504ded97730'
in spec['libdwarf'].variants['patches'].value)
# baz is conditional on libdwarf version (no guarantee on order w/conds)
assert ('bf07a7fbb825fc0aae7bf4a1177b2b31fcf8a3feeaf7092761e18c859ee52a9c'
in spec['libdwarf'].variants['patches'].value)
# URL patches
assert 'patches' in list(spec['fake'].variants.keys())
# urlpatch.patch, urlpatch.patch.gz
assert (('1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd',
'abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234') ==
spec['fake'].variants['patches'].value)
开发者ID:LLNL,项目名称:spack,代码行数:26,代码来源:patch.py
示例12: test_getitem_query
def test_getitem_query(self):
s = Spec('mpileaks')
s.concretize()
# Check a query to a non-virtual package
a = s['callpath']
query = a.last_query
assert query.name == 'callpath'
assert len(query.extra_parameters) == 0
assert not query.isvirtual
# Check a query to a virtual package
a = s['mpi']
query = a.last_query
assert query.name == 'mpi'
assert len(query.extra_parameters) == 0
assert query.isvirtual
# Check a query to a virtual package with
# extra parameters after query
a = s['mpi:cxx,fortran']
query = a.last_query
assert query.name == 'mpi'
assert len(query.extra_parameters) == 2
assert 'cxx' in query.extra_parameters
assert 'fortran' in query.extra_parameters
assert query.isvirtual
开发者ID:justintoo,项目名称:spack,代码行数:30,代码来源:spec_dag.py
示例13: test_external_and_virtual
def test_external_and_virtual(self):
spec = Spec('externaltest')
spec.concretize()
self.assertEqual(spec['externaltool'].external, '/path/to/external_tool')
self.assertEqual(spec['stuff'].external, '/path/to/external_virtual_gcc')
self.assertTrue(spec['externaltool'].compiler.satisfies('gcc'))
self.assertTrue(spec['stuff'].compiler.satisfies('gcc'))
开发者ID:Exteris,项目名称:spack,代码行数:7,代码来源:concretize.py
示例14: test_spec_contains_deps
def test_spec_contains_deps(self):
s = Spec('callpath')
s.normalize()
assert 'dyninst' in s
assert 'libdwarf' in s
assert 'libelf' in s
assert 'mpi' in s
开发者ID:LLNL,项目名称:spack,代码行数:7,代码来源:spec_semantics.py
示例15: test_regression_issue_7705
def test_regression_issue_7705(self):
# spec.package.provides(name) doesn't account for conditional
# constraints in the concretized spec
s = Spec('simple-inheritance~openblas')
s.concretize()
assert not s.package.provides('lapack')
开发者ID:LLNL,项目名称:spack,代码行数:7,代码来源:concretize.py
示例16: check_concretize
def check_concretize(abstract_spec):
abstract = Spec(abstract_spec)
concrete = abstract.concretized()
assert not abstract.concrete
assert concrete.concrete
check_spec(abstract, concrete)
return concrete
开发者ID:LLNL,项目名称:spack,代码行数:7,代码来源:concretize.py
示例17: get_matching_versions
def get_matching_versions(specs, **kwargs):
"""Get a spec for EACH known version matching any spec in the list."""
matching = []
for spec in specs:
pkg = spec.package
# Skip any package that has no known versions.
if not pkg.versions:
tty.msg("No safe (checksummed) versions for package %s" % pkg.name)
continue
num_versions = kwargs.get('num_versions', 0)
matching_spec = []
for i, v in enumerate(reversed(sorted(pkg.versions))):
# Generate no more than num_versions versions for each spec.
if num_versions and i >= num_versions:
break
# Generate only versions that satisfy the spec.
if v.satisfies(spec.versions):
s = Spec(pkg.name)
s.versions = VersionList([v])
s.variants = spec.variants.copy()
# This is needed to avoid hanging references during the
# concretization phase
s.variants.spec = s
matching_spec.append(s)
if not matching_spec:
tty.warn("No known version matches spec: %s" % spec)
matching.extend(matching_spec)
return matching
开发者ID:alfredo-gimenez,项目名称:spack,代码行数:33,代码来源:mirror.py
示例18: test_find_spec_sibling
def test_find_spec_sibling(self):
s = Spec.from_literal({
'a': {
'b +foo': {
'c': None,
'd': None
},
'e +foo': None
}
})
assert 'e' == find_spec(s['b'], lambda s: '+foo' in s).name
assert 'b' == find_spec(s['e'], lambda s: '+foo' in s).name
s = Spec.from_literal({
'a': {
'b +foo': {
'c': None,
'd': None
},
'e': {
'f +foo': None
}
}
})
assert 'f' == find_spec(s['b'], lambda s: '+foo' in s).name
开发者ID:LLNL,项目名称:spack,代码行数:28,代码来源:concretize.py
示例19: test_conflicts_in_spec
def test_conflicts_in_spec(self, conflict_spec):
# Check that an exception is raised an caught by the appropriate
# exception types.
for exc_type in (ConflictsInSpecError, RuntimeError, SpecError):
s = Spec(conflict_spec)
with pytest.raises(exc_type):
s.concretize()
开发者ID:LLNL,项目名称:spack,代码行数:7,代码来源:concretize.py
示例20: test_external_package
def test_external_package(self):
spec = Spec('externaltool')
spec.concretize()
self.assertEqual(spec['externaltool'].external, '/path/to/external_tool')
self.assertFalse('externalprereq' in spec)
self.assertTrue(spec['externaltool'].compiler.satisfies('gcc'))
开发者ID:Exteris,项目名称:spack,代码行数:7,代码来源:concretize.py
注:本文中的spack.spec.Spec类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论