Clone of the official spack repository with modifications for HLRS HAWK
Find a file
Harmen Stoppels 4bad9f9b13
Consolidate DAG traversal in traverse.py, support DFS/BFS (#33406)
This PR introduces breadth-first traversal, and moves depth-first traversal
logic out of Spec's member functions, into `traverse.py`.

It introduces a high-level API with three main methods:

```python
spack.traverse.traverse_edges(specs, kwargs...)
spack.traverse.traverse_nodes(specs, kwags...)
spack.traverse.traverse_tree(specs, kwargs...)
```

with the usual `root`, `order`, `cover`, `direction`, `deptype`, `depth`, `key`,
`visited` kwargs for the first two.

What's new is that `order="breadth"` is added for breadth-first traversal.

The lower level API is not exported, but is certainly useful for advanced use
cases. The lower level API includes visitor classes for direction reversal and
edge pruning, which can be used to create more advanced traversal methods,
especially useful when the `deptype` is not constant but depends on the node
or depth. 

---

There's a couple nice use-cases for breadth-first traversal:

- Sometimes roots have to be handled differently (e.g. follow build edges of
  roots but not of deps). BFS ensures that root nodes are always discovered at
  depth 0, instead of at any depth > 1 as a dep of another root.
- When printing a tree, it would be nice to reduce indent levels so it fits in the 
  terminal, and ensure that e.g. `zlib` is not printed at indent level 10 as a 
  dependency of a build dep of a build dep -- rather if it's a direct dep of my
  package, I wanna see it at depth 1. This basically requires one breadth-first
  traversal to construct a tree, which can then be printed with depth-first traversal.
- In environments in general, it's sometimes inconvenient to have a double
  loop: first over the roots then over each root's deps, and maintain your own
  `visited` set outside. With BFS, you can simply init the queue with the
  environment root specs and it Just Works. [Example here](3ec7304699/lib/spack/spack/environment/environment.py (L1815-L1816))
2022-11-01 23:04:47 -07:00
.github Let pytest-cov create the xml directly (#33619) 2022-11-01 19:04:45 +01:00
bin Make GHA tests parallel by using xdist (#32361) 2022-09-07 20:12:57 +02:00
etc/spack/defaults Windows: fix library loading and enable Clingo bootstrapping (#33400) 2022-10-31 09:36:52 -07:00
lib/spack Consolidate DAG traversal in traverse.py, support DFS/BFS (#33406) 2022-11-01 23:04:47 -07:00
share/spack Let pytest-cov create the xml directly (#33619) 2022-11-01 19:04:45 +01:00
var/spack Consolidate DAG traversal in traverse.py, support DFS/BFS (#33406) 2022-11-01 23:04:47 -07:00
.codecov.yml codecov: allow coverage offsets for more base commit flexibility (#25293) 2021-08-06 01:33:12 -07:00
.dockerignore Docker: ignore var/spack/cache (source caches) when creating container (#23329) 2021-05-17 11:28:58 +02:00
.flake8 Make GHA tests parallel by using xdist (#32361) 2022-09-07 20:12:57 +02:00
.git-blame-ignore-revs black: fix .git-blame-ignore-revs commit 2022-07-31 15:06:38 -07:00
.gitattributes
.gitignore Windows Support: Testing Suite integration 2022-03-17 09:01:01 -07:00
.mailmap Update mailmap (#22739) 2021-04-06 10:32:35 +02:00
.readthedocs.yml More strict ReadTheDocs tests (#26580) 2021-10-08 09:27:17 +02:00
CHANGELOG.md Update release procedure, keep CHANGELOG up-to-date (#31969) 2022-08-09 12:10:49 +00:00
CITATION.cff Add citation information to GitHub (#27518) 2021-11-30 01:37:50 -07:00
COPYRIGHT unparser: implement operator precedence algorithm for unparser 2022-01-12 06:14:18 -08:00
LICENSE-APACHE
LICENSE-MIT Update copyright year to 2022 2022-01-14 22:50:21 -08:00
NOTICE
pyproject.toml ci: restore coverage computation (#32585) 2022-09-10 07:25:44 -06:00
pytest.ini Filter UserWarning out of test output (#26001) 2021-09-16 14:56:00 -06:00
README.md Github Discussions can be used for Q&A (#33364) 2022-10-17 08:38:25 -07:00
SECURITY.md Fix SECURITY.md file by adding v0.17.x to supported versions (#28661) 2022-01-31 10:04:06 -08:00

Spack Spack

Unit Tests Bootstrapping codecov Containers Read the Docs Code style: black Slack

Spack is a multi-platform package manager that builds and installs multiple versions and configurations of software. It works on Linux, macOS, and many supercomputers. Spack is non-destructive: installing a new version of a package does not break existing installations, so many configurations of the same package can coexist.

Spack offers a simple "spec" syntax that allows users to specify versions and configuration options. Package files are written in pure Python, and specs allow package authors to write a single script for many different builds of the same package. With Spack, you can build your software all the ways you want to.

See the Feature Overview for examples and highlights.

To install spack and your first package, make sure you have Python. Then:

$ git clone -c feature.manyFiles=true https://github.com/spack/spack.git
$ cd spack/bin
$ ./spack install zlib

Documentation

Full documentation is available, or run spack help or spack help --all.

For a cheat sheet on Spack syntax, run spack help --spec.

Tutorial

We maintain a hands-on tutorial. It covers basic to advanced usage, packaging, developer features, and large HPC deployments. You can do all of the exercises on your own laptop using a Docker container.

Feel free to use these materials to teach users at your organization about Spack.

Community

Spack is an open source project. Questions, discussion, and contributions are welcome. Contributions can be anything from new packages to bugfixes, documentation, or even new core features.

Resources:

Contributing

Contributing to Spack is relatively easy. Just send us a pull request. When you send your request, make develop the destination branch on the Spack repository.

Your PR must pass Spack's unit tests and documentation tests, and must be PEP 8 compliant. We enforce these guidelines with our CI process. To run these tests locally, and for helpful tips on git, see our Contribution Guide.

Spack's develop branch has the latest contributions. Pull requests should target develop, and users who want the latest package versions, features, etc. can use develop.

Releases

For multi-user site deployments or other use cases that need very stable software installations, we recommend using Spack's stable releases.

Each Spack release series also has a corresponding branch, e.g. releases/v0.14 has 0.14.x versions of Spack, and releases/v0.13 has 0.13.x versions. We backport important bug fixes to these branches but we do not advance the package versions or make other changes that would change the way Spack concretizes dependencies within a release branch. So, you can base your Spack deployment on a release branch and git pull to get fixes, without the package churn that comes with develop.

The latest release is always available with the releases/latest tag.

See the docs on releases for more details.

Code of Conduct

Please note that Spack has a Code of Conduct. By participating in the Spack community, you agree to abide by its rules.

Authors

Many thanks go to Spack's contributors.

Spack was created by Todd Gamblin, tgamblin@llnl.gov.

Citing Spack

If you are referencing Spack in a publication, please cite the following paper:

On GitHub, you can copy this citation in APA or BibTeX format via the "Cite this repository" button. Or, see the comments in CITATION.cff for the raw BibTeX.

License

Spack is distributed under the terms of both the MIT license and the Apache License (Version 2.0). Users may choose either license, at their option.

All new contributions must be made under both the MIT and Apache-2.0 licenses.

See LICENSE-MIT, LICENSE-APACHE, COPYRIGHT, and NOTICE for details.

SPDX-License-Identifier: (Apache-2.0 OR MIT)

LLNL-CODE-811652