Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/spack/spack/build_systems/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def update_external_dependencies(self, extendee_spec=None):

python.external_path = self.spec.external_path
python._mark_concrete()
self.spec.add_dependency_edge(python, deptypes=("build", "link", "run"))
self.spec.add_dependency_edge(python, deptypes=("build", "link", "run"), virtuals=())

def get_external_python_for_prefix(self):
"""
Expand Down
3 changes: 2 additions & 1 deletion lib/spack/spack/cray_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ def entries_to_specs(entries):
continue
parent_spec = spec_dict[entry["hash"]]
dep_spec = spec_dict[dep_hash]
parent_spec._add_dependency(dep_spec, deptypes=deptypes)
# TODO: Check this with Peter
parent_spec._add_dependency(dep_spec, deptypes=deptypes, virtuals=())

return spec_dict

Expand Down
17 changes: 12 additions & 5 deletions lib/spack/spack/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
# DB version. This is stuck in the DB file to track changes in format.
# Increment by one when the database format changes.
# Versions before 5 were not integers.
_db_version = Version("6")
_db_version = Version("7")

# For any version combinations here, skip reindex when upgrading.
# Reindexing can take considerable time and is not always necessary.
Expand All @@ -72,6 +72,7 @@
# version is saved to disk the first time the DB is written.
(Version("0.9.3"), Version("5")),
(Version("5"), Version("6")),
(Version("6"), Version("7")),
]

# Default timeout for spack database locks in seconds or None (no timeout).
Expand Down Expand Up @@ -105,7 +106,11 @@


def reader(version):
reader_cls = {Version("5"): spack.spec.SpecfileV1, Version("6"): spack.spec.SpecfileV3}
reader_cls = {
Version("5"): spack.spec.SpecfileV1,
Version("6"): spack.spec.SpecfileV3,
Version("7"): spack.spec.SpecfileV4,
}
return reader_cls[version]


Expand Down Expand Up @@ -744,7 +749,9 @@ def _assign_dependencies(self, spec_reader, hash_key, installs, data):
spec_node_dict = spec_node_dict[spec.name]
if "dependencies" in spec_node_dict:
yaml_deps = spec_node_dict["dependencies"]
for dname, dhash, dtypes, _ in spec_reader.read_specfile_dep_specs(yaml_deps):
for dname, dhash, dtypes, _, virtuals in spec_reader.read_specfile_dep_specs(
yaml_deps
):
# It is important that we always check upstream installations
# in the same order, and that we always check the local
# installation first: if a downstream Spack installs a package
Expand All @@ -767,7 +774,7 @@ def _assign_dependencies(self, spec_reader, hash_key, installs, data):
tty.warn(msg)
continue

spec._add_dependency(child, deptypes=dtypes)
spec._add_dependency(child, deptypes=dtypes, virtuals=virtuals)

def _read_from_file(self, filename):
"""Fill database from file, do not maintain old data.
Expand Down Expand Up @@ -1170,7 +1177,7 @@ def _add(
for dep in spec.edges_to_dependencies(deptype=_tracked_deps):
dkey = dep.spec.dag_hash()
upstream, record = self.query_by_spec_hash(dkey)
new_spec._add_dependency(record.spec, deptypes=dep.deptypes)
new_spec._add_dependency(record.spec, deptypes=dep.deptypes, virtuals=dep.virtuals)
if not upstream:
record.ref_count += 1

Expand Down
9 changes: 5 additions & 4 deletions lib/spack/spack/environment/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,15 @@ def default_manifest_yaml():
valid_environment_name_re = r"^\w[\w-]*$"

#: version of the lockfile format. Must increase monotonically.
lockfile_format_version = 4
lockfile_format_version = 5


READER_CLS = {
1: spack.spec.SpecfileV1,
2: spack.spec.SpecfileV1,
3: spack.spec.SpecfileV2,
4: spack.spec.SpecfileV3,
5: spack.spec.SpecfileV4,
}


Expand Down Expand Up @@ -1479,7 +1480,7 @@ def _concretize_separately(self, tests=False):
if test_dependency in current_spec[node.name]:
continue
current_spec[node.name].add_dependency_edge(
test_dependency.copy(), deptypes="test"
test_dependency.copy(), deptypes="test", virtuals=()
)

results = [
Expand Down Expand Up @@ -2052,9 +2053,9 @@ def _read_lockfile_dict(self, d):
# and add them to the spec
for lockfile_key, node_dict in json_specs_by_hash.items():
name, data = reader.name_and_data(node_dict)
for _, dep_hash, deptypes, _ in reader.dependencies_from_node_dict(data):
for _, dep_hash, deptypes, _, virtuals in reader.dependencies_from_node_dict(data):
specs_by_hash[lockfile_key]._add_dependency(
specs_by_hash[dep_hash], deptypes=deptypes
specs_by_hash[dep_hash], deptypes=deptypes, virtuals=virtuals
)

# Traverse the root specs one at a time in the order they appear.
Expand Down
1 change: 1 addition & 0 deletions lib/spack/spack/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ def _static_edges(specs, deptype):
spack.spec.Spec(parent_name),
spack.spec.Spec(dependency_name),
deptypes=deptype,
virtuals=(),
)


Expand Down
4 changes: 3 additions & 1 deletion lib/spack/spack/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,9 @@ def _packages_needed_to_bootstrap_compiler(compiler, architecture, pkgs):
dep.concretize()
# mark compiler as depended-on by the packages that use it
for pkg in pkgs:
dep._dependents.add(spack.spec.DependencySpec(pkg.spec, dep, deptypes=("build",)))
dep._dependents.add(
spack.spec.DependencySpec(pkg.spec, dep, deptypes=("build",), virtuals=())
)
packages = [(s.package, False) for s in dep.traverse(order="post", root=False)]

packages.append((dep.package, True))
Expand Down
2 changes: 1 addition & 1 deletion lib/spack/spack/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def next_spec(self, initial_spec: Optional[spack.spec.Spec] = None) -> spack.spe
if root_spec.concrete:
raise spack.spec.RedundantSpecError(root_spec, "^" + str(dependency))

root_spec._add_dependency(dependency, deptypes=())
root_spec._add_dependency(dependency, deptypes=(), virtuals=())

else:
break
Expand Down
4 changes: 2 additions & 2 deletions lib/spack/spack/provider_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,8 @@ def from_json(stream, repository):
index.providers = _transform(
providers,
lambda vpkg, plist: (
spack.spec.SpecfileV3.from_node_dict(vpkg),
set(spack.spec.SpecfileV3.from_node_dict(p) for p in plist),
spack.spec.SpecfileV4.from_node_dict(vpkg),
set(spack.spec.SpecfileV4.from_node_dict(p) for p in plist),
),
)
return index
Expand Down
11 changes: 9 additions & 2 deletions lib/spack/spack/solver/asp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2330,10 +2330,15 @@ def depends_on(self, pkg, dep, type):
assert len(dependencies) < 2, msg

if not dependencies:
self._specs[pkg].add_dependency_edge(self._specs[dep], deptypes=(type,))
self._specs[pkg].add_dependency_edge(self._specs[dep], deptypes=(type,), virtuals=())
else:
# TODO: This assumes that each solve unifies dependencies
dependencies[0].add_type(type)
dependencies[0].update_deptypes(deptypes=(type,))

def virtual_on_edge(self, pkg, provider, virtual):
dependencies = self._specs[pkg].edges_to_dependencies(name=provider)
assert len(dependencies) == 1
dependencies[0].update_virtuals((virtual,))

def reorder_flags(self):
"""Order compiler flags on specs in predefined order.
Expand Down Expand Up @@ -2406,6 +2411,8 @@ def sort_fn(function_tuple):
return (-2, 0)
elif name == "external_spec_selected":
return (0, 0) # note out of order so this goes last
elif name == "virtual_on_edge":
return (1, 0)
else:
return (-1, 0)

Expand Down
5 changes: 5 additions & 0 deletions lib/spack/spack/solver/concretize.lp
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,11 @@ attr("depends_on", Package, Provider, Type)
provider(Provider, Virtual),
not external(Package).

attr("virtual_on_edge", Package, Provider, Virtual)
:- dependency_holds(Package, Virtual, Type),
provider(Provider, Virtual),
not external(Package).

% dependencies on virtuals also imply that the virtual is a virtual node
attr("virtual_node", Virtual)
:- dependency_holds(Package, Virtual, Type),
Expand Down
Loading