本文整理汇总了Python中spack.spec.Spec.dag_hash方法的典型用法代码示例。如果您正苦于以下问题:Python Spec.dag_hash方法的具体用法?Python Spec.dag_hash怎么用?Python Spec.dag_hash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spack.spec.Spec
的用法示例。
在下文中一共展示了Spec.dag_hash方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_regression_issue_7941
# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import dag_hash [as 别名]
def test_regression_issue_7941(self):
# The string representation of a spec containing
# an explicit multi-valued variant and a dependency
# might be parsed differently than the originating spec
s = Spec('a foobar=bar ^b')
t = Spec(str(s))
s.concretize()
t.concretize()
assert s.dag_hash() == t.dag_hash()
示例2: test_dynamic_dot_graph_mpileaks
# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import dag_hash [as 别名]
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
示例3: remove
# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import dag_hash [as 别名]
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]
示例4: test_installed_dependency_request_conflicts
# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import dag_hash [as 别名]
def test_installed_dependency_request_conflicts(
install_mockery, mock_fetch, mutable_mock_packages):
dependency = Spec('dependency-install')
dependency.concretize()
dependency.package.do_install()
dependency_hash = dependency.dag_hash()
dependent = Spec(
'conflicting-dependent ^/' + dependency_hash)
with pytest.raises(spack.spec.UnsatisfiableSpecError):
dependent.concretize()
示例5: test_satisfies_same_spec_with_different_hash
# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import dag_hash [as 别名]
def test_satisfies_same_spec_with_different_hash(self):
"""Ensure that concrete specs are matched *exactly* by hash."""
s1 = Spec('mpileaks').concretized()
s2 = s1.copy()
assert s1.satisfies(s2)
assert s2.satisfies(s1)
# Simulate specs that were installed before and after a change to
# Spack's hashing algorithm. This just reverses s2's hash.
s2._hash = s1.dag_hash()[-1::-1]
assert not s1.satisfies(s2)
assert not s2.satisfies(s1)
示例6: test_dont_add_patches_to_installed_package
# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import dag_hash [as 别名]
def test_dont_add_patches_to_installed_package(install_mockery, mock_fetch):
import sys
dependency = Spec('dependency-install')
dependency.concretize()
dependency.package.do_install()
dependency.package.patches['dependency-install'] = [
sys.modules['spack.patch'].Patch.create(
None, 'file://fake.patch', sha256='unused-hash')]
dependency_hash = dependency.dag_hash()
dependent = Spec('dependent-install ^/' + dependency_hash)
dependent.concretize()
assert dependent['dependency-install'] == dependency
示例7: test_ordered_read_not_required_for_consistent_dag_hash
# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import dag_hash [as 别名]
def test_ordered_read_not_required_for_consistent_dag_hash(
config, builtin_mock
):
"""Make sure ordered serialization isn't required to preserve hashes.
For consistent hashes, we require that YAML and json documents
have their keys serialized in a deterministic order. However, we
don't want to require them to be serialized in order. This
ensures that is not required.
"""
specs = ['mpileaks ^zmpi', 'dttop', 'dtuse']
for spec in specs:
spec = Spec(spec)
spec.concretize()
#
# Dict & corresponding YAML & JSON from the original spec.
#
spec_dict = spec.to_dict()
spec_yaml = spec.to_yaml()
spec_json = spec.to_json()
#
# Make a spec with reversed OrderedDicts for every
# OrderedDict in the original.
#
reversed_spec_dict = reverse_all_dicts(spec.to_dict())
#
# Dump to YAML and JSON
#
yaml_string = syaml.dump(spec_dict, default_flow_style=False)
reversed_yaml_string = syaml.dump(reversed_spec_dict,
default_flow_style=False)
json_string = sjson.dump(spec_dict)
reversed_json_string = sjson.dump(reversed_spec_dict)
#
# Do many consistency checks
#
# spec yaml is ordered like the spec dict
assert yaml_string == spec_yaml
assert json_string == spec_json
# reversed string is different from the original, so it
# *would* generate a different hash
assert yaml_string != reversed_yaml_string
assert json_string != reversed_json_string
# build specs from the "wrongly" ordered data
round_trip_yaml_spec = Spec.from_yaml(yaml_string)
round_trip_json_spec = Spec.from_json(json_string)
round_trip_reversed_yaml_spec = Spec.from_yaml(
reversed_yaml_string
)
round_trip_reversed_json_spec = Spec.from_yaml(
reversed_json_string
)
# TODO: remove this when build deps are in provenance.
spec = spec.copy(deps=('link', 'run'))
# specs are equal to the original
assert spec == round_trip_yaml_spec
assert spec == round_trip_json_spec
assert spec == round_trip_reversed_yaml_spec
assert spec == round_trip_reversed_json_spec
assert round_trip_yaml_spec == round_trip_reversed_yaml_spec
assert round_trip_json_spec == round_trip_reversed_json_spec
# dag_hashes are equal
assert spec.dag_hash() == round_trip_yaml_spec.dag_hash()
assert spec.dag_hash() == round_trip_json_spec.dag_hash()
assert spec.dag_hash() == round_trip_reversed_yaml_spec.dag_hash()
assert spec.dag_hash() == round_trip_reversed_json_spec.dag_hash()
示例8: test_buildcache
# 需要导入模块: from spack.spec import Spec [as 别名]
# 或者: from spack.spec.Spec import dag_hash [as 别名]
def test_buildcache(mock_archive, tmpdir):
# tweak patchelf to only do a download
spec = Spec("patchelf")
spec.concretize()
pkg = spack.repo.get(spec)
fake_fetchify(pkg.fetcher, pkg)
mkdirp(os.path.join(pkg.prefix, "bin"))
patchelfscr = os.path.join(pkg.prefix, "bin", "patchelf")
f = open(patchelfscr, 'w')
body = """#!/bin/bash
echo $PATH"""
f.write(body)
f.close()
st = os.stat(patchelfscr)
os.chmod(patchelfscr, st.st_mode | stat.S_IEXEC)
# Install the test package
spec = Spec('trivial-install-test-package')
spec.concretize()
assert spec.concrete
pkg = spec.package
fake_fetchify(mock_archive.url, pkg)
pkg.do_install()
pkghash = '/' + spec.dag_hash(7)
# Put some non-relocatable file in there
filename = os.path.join(spec.prefix, "dummy.txt")
with open(filename, "w") as script:
script.write(spec.prefix)
# Create the build cache and
# put it directly into the mirror
mirror_path = os.path.join(str(tmpdir), 'test-mirror')
spack.mirror.create(
mirror_path, specs=[], no_checksum=True
)
# register mirror with spack config
mirrors = {'spack-mirror-test': 'file://' + mirror_path}
spack.config.set('mirrors', mirrors)
stage = spack.stage.Stage(
mirrors['spack-mirror-test'], name="build_cache", keep=True)
stage.create()
# setup argument parser
parser = argparse.ArgumentParser()
buildcache.setup_parser(parser)
# Create a private key to sign package with if gpg2 available
if has_gnupg2():
spack.util.gpg.Gpg.create(name='test key 1', expires='0',
email='[email protected]',
comment='Spack test key')
# Create build cache with signing
args = parser.parse_args(['create', '-d', mirror_path, str(spec)])
buildcache.buildcache(parser, args)
# Uninstall the package
pkg.do_uninstall(force=True)
# test overwrite install
args = parser.parse_args(['install', '-f', str(pkghash)])
buildcache.buildcache(parser, args)
# create build cache with relative path and signing
args = parser.parse_args(
['create', '-d', mirror_path, '-f', '-r', str(spec)])
buildcache.buildcache(parser, args)
# Uninstall the package
pkg.do_uninstall(force=True)
# install build cache with verification
args = parser.parse_args(['install', str(spec)])
buildcache.install_tarball(spec, args)
# test overwrite install
args = parser.parse_args(['install', '-f', str(pkghash)])
buildcache.buildcache(parser, args)
else:
# create build cache without signing
args = parser.parse_args(
['create', '-d', mirror_path, '-u', str(spec)])
buildcache.buildcache(parser, args)
# Uninstall the package
pkg.do_uninstall(force=True)
# install build cache without verification
args = parser.parse_args(['install', '-u', str(spec)])
buildcache.install_tarball(spec, args)
# test overwrite install without verification
args = parser.parse_args(['install', '-f', '-u', str(pkghash)])
buildcache.buildcache(parser, args)
# create build cache with relative path
args = parser.parse_args(
#.........这里部分代码省略.........