Commit Graph

7802 Commits

Author SHA1 Message Date
Gregory Becker
66bb19084c
add test file for conditional dependencies
Signed-off-by: Gregory Becker <becker33@llnl.gov>
2025-05-18 11:12:09 -07:00
Gregory Becker
9cdb25497d
style
Signed-off-by: Gregory Becker <becker33@llnl.gov>
2025-05-16 16:58:20 -07:00
Gregory Becker
26c5f5265d
tests for conditional deps in requirements
Signed-off-by: Gregory Becker <becker33@llnl.gov>
2025-05-16 16:56:43 -07:00
Gregory Becker
a16d10edc9
conditional deps: tests for Spec.satisfies and Spec.constrain
Signed-off-by: Gregory Becker <becker33@llnl.gov>
2025-05-16 12:31:22 -07:00
Gregory Becker
231d537a2e
mypy fix
Signed-off-by: Gregory Becker <becker33@llnl.gov>
2025-05-15 14:53:35 -07:00
Gregory Becker
452a84d9eb
conditional deps: fix parsing tests
Signed-off-by: Gregory Becker <becker33@llnl.gov>
2025-05-15 14:00:55 -07:00
Gregory Becker
b03d5b7885
parseable_tokens: fix mypy annotations
Signed-off-by: Gregory Becker <becker33@llnl.gov>
2025-05-15 10:35:13 -07:00
Gregory Becker
e0aa378f9e
fixup rebase missing closing paren
Signed-off-by: Gregory Becker <becker33@llnl.gov>
2025-05-14 19:47:54 -07:00
Gregory Becker
2c2282dcb4
rebase fixup
Signed-off-by: Gregory Becker <becker33@llnl.gov>
2025-05-14 17:44:29 -07:00
Gregory Becker
f27eb55f29
add test for toolchains
Signed-off-by: Gregory Becker <becker33@llnl.gov>
2025-05-14 17:03:41 -07:00
Gregory Becker
019957a225
Spec.satisfies: Remove optimization that fails for spec with no dependency satisfying failed conditional dep
Signed-off-by: Gregory Becker <becker33@llnl.gov>
2025-05-14 17:03:41 -07:00
Gregory Becker
7472a1db8a
Spec.constrain: separate constraints from edges with different conditions
Signed-off-by: Gregory Becker <becker33@llnl.gov>
2025-05-14 17:03:40 -07:00
Gregory Becker
fb6ffc45d7
Spec.edge_attributes: deduplicate dependency conditions from multiple parents
Signed-off-by: Gregory Becker <becker33@llnl.gov>
2025-05-14 17:03:40 -07:00
Gregory Becker
ebf4c8b445
Spec: filter conditional edges in Spec.dependencies/edges_to_dependencies
Signed-off-by: Gregory Becker <becker33@llnl.gov>
2025-05-14 17:03:40 -07:00
Gregory Becker
79610ce80e
candidate.long_spec in error when concrete spec does not satisfy abstract
Signed-off-by: Gregory Becker <becker33@llnl.gov>
2025-05-14 17:03:40 -07:00
Gregory Becker
462379b92f
conditional deps: add parsing test
Signed-off-by: Gregory Becker <becker33@llnl.gov>
2025-05-14 17:03:37 -07:00
Gregory Becker
893d56ac2c
constrain: handle conditional deps
Signed-off-by: Gregory Becker <becker33@llnl.gov>
2025-05-14 17:03:03 -07:00
Gregory Becker
b4f938adf4
toolchains/conditional deps: support prefers/requires
Signed-off-by: Gregory Becker <becker33@llnl.gov>
2025-05-14 17:03:02 -07:00
Gregory Becker
6623209ba7
Spack toolchains
Add parser and config support for toolchains. A toolchain is a configured
string alias applied at parse time. When parsing the '%' sigil the parser
will match the token after the sigil to any toolchain name, and if there is
a match it will replace the sigil and following token with the tokens for
the associated string.

For example, the following config allows for the user to enforce usage of
clang for c/cxx and gcc for fortran with a single option `%my_toolchain`

toolchains:
  my_toolchain: ^[when=%c virtuals=c ]clang ^[when=%cxx virtuals=cxx ]clang ^[when=%fortran virtuals=fortran ]gcc

Note that the space before the ']' symbol is required for proper parsing. This
is considered a bug and will be fixed when possible.

Signed-off-by: Gregory Becker <becker33@llnl.gov>
2025-05-14 17:02:59 -07:00
Gregory Becker
6eaaaa4ae7
satisfies for conditional dependencies
Signed-off-by: Gregory Becker <becker33@llnl.gov>
2025-05-14 16:55:01 -07:00
Gregory Becker
89e0cf886d
concretization for conditional dependencies
Signed-off-by: Gregory Becker <becker33@llnl.gov>
2025-05-14 16:55:01 -07:00
Gregory Becker
e24bd2ef3c
fixup 2355eb5c3e
Signed-off-by: Gregory Becker <becker33@llnl.gov>
2025-05-14 16:55:01 -07:00
Gregory Becker
2c43131aca
bugfix for error message when input spec does not satisfy concretizer output
Signed-off-by: Gregory Becker <becker33@llnl.gov>
2025-05-14 16:55:00 -07:00
Gregory Becker
d792121cde
conditional deps: bugfix for type mismatch in _add_dependency
Signed-off-by: Gregory Becker <becker33@llnl.gov>
2025-05-14 16:55:00 -07:00
Gregory Becker
ce3fcf011f
SpecParsingError: only print context if available
Signed-off-by: Gregory Becker <becker33@llnl.gov>
2025-05-14 16:55:00 -07:00
Gregory Becker
e66ae3959d
Spec.long_spec: update for conditional deps
Signed-off-by: Gregory Becker <becker33@llnl.gov>
2025-05-14 16:55:00 -07:00
Gregory Becker
02513eae7e
wip
Signed-off-by: Gregory Becker <becker33@llnl.gov>
2025-05-14 16:54:51 -07:00
Massimiliano Culpo
f8538a1b1c
Parse % as ^ in specs (#49808)
This PR modifies the parser, so that `%` is parsed as a `DEPENDENCY`, and all
node properties that follow are associated to the name after the `%`. e.g.,
in `foo %gcc +binutils` the `+binutils` refers to `gcc` and not to `foo`.

`%` is still parsed as a build-type dependency, at the moment.

Environments, config files and `package.py` files from before Spack v1.0 may have
spec strings with package variants, targets, etc. *after* a build dependency, and these
will need to be updated. You can use the `spack style --spec-strings` command to do this.

To see what strings will be parsed differently under Spack v1.0, run:

```
spack style --spec-strings FILES
```

where `FILES` is a list of filenames that may contain old specs. To update these spec
strings so that they parse correctly under both Spack 1.0 and Spack 0.x, you can run:

```
spack style --fix --spec-strings FILES
```

In the example above, `foo %gcc +binutils` would be rewritten as `foo +binutils %gcc`,
which parses the same in any Spack version.

In addition, this PR fixes several issues with `%` dependencies:

- [x] Ensure we can still constrain compilers on reuse
- [x] Ensure we can reuse a compiler by hash
- [x] Add tests

---------

Signed-off-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
2025-05-14 16:17:34 -06:00
Harmen Stoppels
1e9be97a25
Update sys.path references (#50466) 2025-05-14 10:25:00 +00:00
Tamara Dahlgren
719fd6fb43
test_load_json_specfiles: skip virtual reconstruction (#50361) 2025-05-14 02:32:47 -06:00
Harmen Stoppels
abcc641373
Fix spack.repo.is_package_module (#50464) 2025-05-14 10:22:28 +02:00
G-Ragghianti
abcef565a8
spack env activate: respect --without-view when --temp (#50438) 2025-05-14 09:58:38 +02:00
Harmen Stoppels
00d65b75a1
remove std_cmake_args, std_pip_args, std_meson_args (#50462)
The "magic" globals `std_cmake_args`, `std_pip_args` and `std_meson_args` were deprecated in Spack 0.23 and removed in this commit, because they are no longer static and don't make sense to be defined for packages that do not depend on cmake, pip or meson.

Additionally, removing them ensures that `build_environment.py` no longer depends on builders, which will soon be moved out of `spack` into the `spack_repo` package.

The audit that scans whether these globals are used is not removed.
2025-05-14 09:51:42 +02:00
Tamara Dahlgren
ae9cffe55f
test/bootstrap.py: test_bootstrap_search_for_compilers_with* use mock packages path (#50441) 2025-05-13 14:31:13 +02:00
Harmen Stoppels
c5eb82fcb0
pkg.spec.package is pkg after deserialization (#50449) 2025-05-13 12:08:13 +02:00
Massimiliano Culpo
a938167a22
Add a prefix when we import vendored modules (#50443)
Signed-off-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
Co-authored-by: Harmen Stoppels <harmenstoppels@gmail.com>
2025-05-13 07:20:40 +02:00
Massimiliano Culpo
acd47147a5
solver: support concrete multivalued variants (#50325)
The solves now supports key:=val syntax for multivalued variants in specs originating from input, externals, requirements, directives and when conditions

Signed-off-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
2025-05-09 23:08:21 +02:00
Harmen Stoppels
3ed6736b2c
compiler.py: be more defensive (#50403) 2025-05-09 16:58:52 +00:00
Massimiliano Culpo
842954f6a4
solver: treat external nodes as concrete for optimization purposes (#50165)
This PR is a step towards treating externals as concrete specs. Specifically, it moves the optimization weights of external nodes into the group of "reused" specs, and doesn't count externals as specs to be built. 

It still keeps the one to many mapping between an external spec in `packages.yaml` and the corresponding specs in the DB. To make it such that an hashed external is preferred to a non-hashed one, the version weights of externals are demoted at lowest priority.

**Change in behavior**:
- Having the possibility, Spack will now prefer to mix compilers in a DAG, and use the latest version possible for each node, rather than using a single compiler and employ old versions of some nodes because of conflicts
- In general, using externals by default is now triggered by putting their weights in the "reused" group. This means that any penalty they might induce will never have the same priority as something that needs to be built. This behavior reflects reality, but changes some default choices from the previous state.

Modifications:
- External nodes weights are now moved to the group of "reused" specs
- Runtimes are treated as concrete as well (to avoid that e.g.`gcc` is not selected because it "builds" the runtime package)
- Shuffle version weights, so that externals are least preferred (counterbalanced by the fact that they are in the "reused" groups)
- Split provider weights on edges from version badness on edges

Signed-off-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
2025-05-09 17:41:16 +02:00
Tamara Dahlgren
a505fb1f37
unit tests: switch TestSpecList to use mock packages (#50353) 2025-05-09 07:45:49 +02:00
Scott Wittenburg
03cb30cb96
binary_distribution: Do not look in sub-mirrors when indexing (#50389)
When indexing top level specs, eg, in s3://spack-binaries/develop,
do not sync manifests from all the stacks.  Instead, add the path
to the spec manifests to the url to sync, so that only items in
s3://spack-binaries/develop/v3/manifests/spec are copied to the
local system.
2025-05-08 17:25:35 -06:00
Scott Wittenburg
f6da037129
binary_distribution: Handle fetch error during rebuild-index (#50387)
Allow rebuild-index to continue if fetching some specs fails
for any reason, and issue a warning indicating which manifest
is associated with the failed fetch.
2025-05-08 13:54:43 -06:00
jgraciahlrs
1a379215da
Allow usage of config variables and env variables with include_concrete (#45871)
* Allow usage of spack config vars in concrete env path
* Update docs on usage of spack config vars in concrete env path
2025-05-08 14:23:02 -05:00
Harmen Stoppels
b0b316c646
builtin: add a few missing __init__.py (#50374) 2025-05-08 18:45:09 +02:00
Harmen Stoppels
a95fa26857
docs/comments: fix typo with wildcard import (#50379) 2025-05-08 18:37:45 +02:00
Harmen Stoppels
98c08ce5c6
repo.py: enable search paths when spack.repo.PATH is assigned (#50370)
Fixes a bug where `custom_repo.get_pkg_class("foo")` failed executing `import spack_repo.builtin` even if the builtin repo was configured globally.

Instead of assignment of `spack.repo.PATH`, the `spack.repo.enable_repo` function now assigns and enables the repo, meaning that also Python module search paths are modified.
2025-05-08 13:42:20 +02:00
Tamara Dahlgren
59339be48f
test/cmd/find.py: switch to use mock_packages (#50358) 2025-05-08 08:33:56 +02:00
Harmen Stoppels
21d8c09c5e
builtin: fix various type/correctness issues (#50340) 2025-05-07 15:45:15 +02:00
Tamara Dahlgren
0b4477c0df
test/cmd/unit_test: have test_list_with* ignore missing repo warning (#50332) 2025-05-07 09:06:34 +02:00
Tamara Dahlgren
eff4c14a09
test/providers: switch to mock packages (#50333) 2025-05-07 09:04:06 +02:00