Commit graph

6203 commits

Author SHA1 Message Date
Massimiliano Culpo
b0e54bc0ac
Fix regression on compiler constraint (#36342)
fixes #36339

We were missing a rule that enforced a match between
the `node_compiler` and the compiler used to satisfy
a requirement.

Fix compiler with custom, made up version too
2023-03-23 20:43:13 +01:00
Harmen Stoppels
4dc9d9f60e
Revert "Bugfix: package requirements with git commits (#35057)" (#36341)
This reverts commit 3d597e29be.
2023-03-23 12:10:46 +01:00
Peter Scheibel
3d597e29be
Bugfix: package requirements with git commits (#35057)
* Specs that define 'new' versions in the require: section need to generate
  associated facts to indicate that those versions are valid.

* add test to verify success with unknown versions.
2023-03-23 01:58:20 -07:00
Xavier Delaruelle
47d710dc4d
modules tcl: switch default all:autoload from none to direct (#36269)
Since environment-modules has support for autoloading since 4.2,
and Spack-builds of it enable it by default, use the same autoload
default for tcl as lmod.
2023-03-23 07:49:17 +01:00
Leopold Talirz
311d3be18e
docs: mention cuda multi-arch capability (#36321) 2023-03-22 16:52:53 -04:00
Peter Scheibel
c3e41153ac
Package requirements: allow single specs in requirement lists (#36258)
If you have a "require:" section in your packages config, and you
use it to specify a list of requirements, the list elements can
now include strings (before this, each element in the list had to
be a `one_of` or `any_of` specification, which is awkward if you
wanted to apply just one spec with no alternatives).
2023-03-20 12:30:33 -07:00
Harmen Stoppels
88d78025a6
spack install: simplify behavior when inside environments (#35206)
Example one:

```
spack install --add x y z
```

is equivalent to

```
spack add x y z
spack concretize
spack install --only-concrete
```

where `--only-concrete` installs without modifying spack.yaml/spack.lock

Example two:

```
spack install
```

concretizes current spack.yaml if outdated and installs all specs.

Example three:

```
spack install x y z
```

concretizes current spack.yaml if outdated and installs *only* concrete
specs in the environment that match abstract specs `x`, `y`, or `z`.
2023-03-20 13:51:30 +01:00
Adam J. Stewart
5dc8ed2694
Remove unused ignore parameter of extends() directive (#35588)
The `ignore` parameter was only used for `spack activate/deactivate`, and it isn't used
by Spack Environments which have their own handling of file conflicts. We should remove it.

Everything that handles `ignore=` was removed in #29317 and included in 0.19, when we
removed `spack activate` and `spack deactivate` in favor of environments.  So all of these
usages removed here were already being ignored by Spack.
2023-03-20 07:22:59 -04:00
Harmen Stoppels
b8e5fc061d
ci.py: remove redundant wrapper around get (#36188) 2023-03-20 10:56:19 +01:00
Xavier Delaruelle
41d7fe0a50
modules tcl: fix autoload mechanism in template (#36237)
Adapt tcl modulefile template to call "module load" on autoload
dependency without testing if this dependency is already loaded or not.

The is-loaded test is not necessary, as module commands know how to cope
with an already loaded module. With environment-modules 4.2+ (released
in 2018) it is also important to have this "module load" command even if
dependency is already loaded in order to record that the modulefile
declares such dependency. This is important if you want to keep a
consistent environment when a dependent module is unloaded.

The "Autoloading" verbose message is also removed as recent module
commands will report such information to the user (depending on the
verbosity configured for the module command).

Such change has been test successfully with Modules 3.2 (EL7), 4.5 (EL8)
and 5.2 (latest) and also with Lmod 7 and 8 (as it is mentionned in
Spack docs that Lmod can be used along with tcl modules). Dependencies
are correctly loaded or unloaded, whether they are loaded/unloaded or
not.

This change fixes Tcl quoting issue introduced in #32853.

Fixes #19155.
2023-03-20 09:23:40 +01:00
Xavier Delaruelle
df97827a7b
Fix case spelling for Lmod and Tcl (#36215) 2023-03-19 01:42:50 +00:00
Massimiliano Culpo
d84c6ad29e
cmake build system: make "generator" a variant (#35552) 2023-03-18 16:39:04 +01:00
Massimiliano Culpo
2f07c64f2d
Fix wrong computation of concrete specs due to a bug in intersects (#36194)
fixes #36190
2023-03-18 12:50:52 +01:00
Massimiliano Culpo
0478e5f684
Improve wording of audit message (#36180) 2023-03-17 17:43:35 -04:00
John W. Parent
8195f27a66
Windows: properly handle symlink failures (#36003)
In the Windows filesystem logic for creating a symlink, we intend to
fall back to a copy when the symlink cannot be created (for some
configuration settings on Windows it is not possible for the user
to create a symlink). It turns out we were overly-broad in which
exceptions lead to this fallback, and the subsequent copy would
also fail: at least one case where this occurred is when we
attempted to create a symlink that already existed.

The updated logic expressly avoids falling back to a copy when the
file/symlink already exists.
2023-03-17 10:19:32 -07:00
Massimiliano Culpo
97193a25ce
Mitigation for GitVersion bug when no =reference is given (#36159)
* ASP-based solver: use satisfies instead of intersects

They are semantically equivalent for concrete versions,
but the GitVersion.intersects implementation is buggy

* Mitigation for git version bug

fixes #36134

This commit works around the issue in #36134, by using
GitVersion.satisfies instead of GitVersion.intersects

There are still underlying issues when trying to infer the
"reference version" when no explicit one is given, but:

1. They are not reproducible with our synthetic repo
2. They occur only when the `git.<xxx>` form of Git version
   is used

Here we just work around the user facing issue and ensure
the tests are correct with our synthetic repository.
2023-03-17 11:36:29 +01:00
Massimiliano Culpo
8517a74f37
ASP-based solver: tweak heuristic, modify compiler encoding (#35989)
This PR does 2 unrelated things:
1. It changes the encoding of the compilers
2. It tweaks the heuristic for the solves in a0d88179074f81d13a3fad629a43d86334e7f982

Both were initially motivated by trying to get a performance gain but, while 2 showed significant speed-ups[^1], 1 instead didn't. I kept it anyhow, since I think the code related to compilers is more consolidated with the new encoding and we might get some performance improvement out of it if we can base our errors on the `node_compiler(Package, CompilerID)` atoms instead of `attrs`.

[^1]: In general the changes in the heuristic brought a ~10% speed-up on the tests I did. I'll post detailed results below.

Add a warning about compilers.yaml that is triggered if there are multiple compilers with the same spec, os and
target (since they can't be selected by users with the spec syntax only).
2023-03-17 00:39:41 -07:00
Harmen Stoppels
ba00da61e4
reduce spec.json.sig file size (#36157)
Since GPG clear-sign cannot deal with lines longer than 19995 characters
and doesn't even error but simply truncates those linese (don't ask me
why...), we have to be careful not to hit that line limit when reducing
the filesize.

So, instead this PR sets the indent level to 0 and drops the whitespace
after `: `, which still reduces file size by 50% or so.
2023-03-16 19:46:13 +01:00
Harmen Stoppels
50cc1d12f9
Revert "minify spec.json in buildcache (#36138)" (#36156)
This reverts commit 1a8eefe09b.
2023-03-16 10:30:52 +01:00
Harmen Stoppels
1a8eefe09b
minify spec.json in buildcache (#36138)
saves about 50% of data, which is significant
for hundreds of thousands of spec.json files
in our buildcaches.
2023-03-15 16:54:03 -04:00
Shahzeb Siddiqui
b5f3b5bf78
Remove leftover command from documentation (#36116)
The command refers to dotkit files, which are not supported since a long time.
2023-03-14 20:48:28 -04:00
John W. Parent
cd42fc5cc8
Libogg and libtheora: build on windows (#35099)
Adds builders appropriate for building these packages on Windows.
It is intended that builds on other platforms are unaffected (e.g.
they build with Autotools as before on Linux).
2023-03-14 16:46:49 -07:00
Harmen Stoppels
96b205ce6c
environment.matching_spec: linear time traversal (#35534)
... and use colors in disambiguate message for clarity.

This commit avoids the loop:

```
for root in roots:
  for dep in deps(root):
    ...
```

instead it ensures each node is visited once and only once.

Also adds a small optimization when searching for concrete specs, since
we can assume uniqueness of dag hash, so it's fine to early exit.
2023-03-14 11:18:10 -07:00
Harmen Stoppels
40019dacd9
Use bfs in get_spec_filter_list (#36093) 2023-03-14 14:34:56 +01:00
Harmen Stoppels
1691b7caac
Fix typo affecting Gitlab CI (#36103)
Introduced in #35944
2023-03-14 14:18:05 +01:00
Harmen Stoppels
f7da7db9b2
use stage dir for buildcache create (#36091) 2023-03-14 09:35:47 +01:00
Michael Kuhn
5bae742826
concretizer: add mode to reuse dependencies only (#30990)
This adds a new mode for `concretizer:reuse` called `dependencies`,
which only reuses dependencies. Currently, `spack install foo` will
reuse older versions of `foo`, which might be surprising to users.
2023-03-14 09:22:20 +01:00
Greg Becker
66bf9bc7a6
cce compiler: bugfix for version regex to avoid conflation with apple-clang (#35974)
Currently apple-clang is detected as cce, and it should not be.
---------

Co-authored-by: becker33 <becker33@users.noreply.github.com>
2023-03-12 08:17:09 +00:00
Harmen Stoppels
844701b974
get --dev and drop set -x (#36010) 2023-03-10 22:59:57 -08:00
kwryankrattiger
181bb54372
Hotfix: Fix CI unit test after CI refactor (#36004)
* Hotfix: Fix CI unit test after CI refactor
2023-03-10 13:31:40 -08:00
kwryankrattiger
f3595da600
CI boilerplate reduction (#34272)
* CI configuration boilerplate reduction and refactor

Configuration:
- New notation for list concatenation (prepend/append)
- New notation for string concatenation (prepend/append)
- Break out configuration files for: ci.yaml, cdash.yaml, view.yaml
- Spack CI section refactored to improve self-consistency and
composability
  - Scripts are now lists of lists and/or lists of strings
  - Job attributes are now listed under precedence ordered list that are
  composed/merged using Spack config merge rules.
  - "service-jobs" are identified explicitly rather than as a batch

CI:
- Consolidate common, platform, and architecture configurations for all CI stacks into composable configuration files
- Make padding consistent across all stacks (256)
- Merge all package -> runner mappings to be consistent across all
stacks

Unit Test:
- Refactor CI module unit-tests for refactor configuration

Docs:
- Add docs for new notations in configuration.rst
- Rewrite docs on CI pipelines to be consistent with refactored CI
workflow

* Script verbose environ, dev bootstrap

* Port #35409
2023-03-10 12:25:35 -07:00
Greg Becker
a51f4b77d9
reorder_flags: properly handle flags from concrete reused specs (#35951) 2023-03-09 16:46:47 -08:00
Peter Scheibel
1b8561f752
add logging to help users debug where external file searches are taking a long time (#35900) 2023-03-08 09:46:13 -08:00
Scott Wittenburg
4a9ffdcfa2
gitlab ci: Provide a knob to control untouched spec pruning (#35274)
When untouched spec pruning is enabled, specs possibly affected
by a change cannot be pruned from a pipeline.

Previously spack looked at all specs matching changed package
names, and traversed dependents of each, all the way to the
environment root, to compute the set of environment specs
possibly affected by a change (and thus, not candidates for
pruning).

With this PR, when untouched spec pruning is enabled, a new
environment variable can control how far towards the root spack
traverses to compute the set of specs possibly affected by a
change.  SPACK_UNTOUCHED_PRUNING_DEPENDENT_DEPTH can be set
to any numeric value before the "spack ci generate" command
is called to control this traversal depth parameter.  Setting
it to "0" traverses only touched specs, setting it to "1"
traverses only touched specs and their direct dependents, and
so on.  Omitting the variable results in the previous behavior
of traversing all the way to the root.  Setting it to a negative
value means no traversal is done, and always yields an empty
set of possibly affected specs (which would result in the max
pruning possible).
2023-03-08 09:38:07 -07:00
Harmen Stoppels
22d4e79037
buildcache create: reproducible tarballs (#35623)
Currently `spack buildcache create` creates compressed tarballs that
differ between each invocation, thanks to:

1. The gzip header containing mtime set to time.time()
2. The generated buildinfo file which has a different mtime every time.

To avoid this, you have to explicitly construct GZipFile yourself, since
the Python API doesn't expose the mtime arg, and we have to manually
create the tarinfo object for the buildinfo metadata file.

Normalize mode: regular files & hardlinks executable by user, dirs, symlinks: set 0o755 permissions in tarfile; other files use 0o644
2023-03-08 15:51:55 +00:00
Massimiliano Culpo
d54611af2c
Split satisfies(..., strict=True/False) into two functions (#35681)
This commit formalizes `satisfies(lhs, rhs, strict=True/False)`
and splits it into two functions: `satisfies(lhs, rhs)` and
`intersects(lhs, rhs)`.

- `satisfies(lhs, rhs)` means: all concrete specs matching the
   left hand side also match the right hand side
- `intersects(lhs, rhs)` means: there exist concrete specs
   matching both lhs and rhs.

`intersects` now has the property that it's commutative,
which previously was not guaranteed.

For abstract specs, `intersects(lhs, rhs)` implies that
`constrain(lhs, rhs)` works.

What's *not* done in this PR is ensuring that
`intersects(concrete, abstract)` returns false when the
abstract spec has additional properties not present in the
concrete spec, but `constrain(concrete, abstract)` will
raise an error.

To accomplish this, some semantics have changed, as well
as bugfixes to ArchSpec:
- GitVersion is now interpreted as a more constrained
  version
- Compiler flags are interpreted as strings since their
  order is important
- Abstract specs respect variant type (bool / multivalued)
2023-03-08 13:00:53 +01:00
Tamara Dahlgren
b06648eb64
docs: added platform conflicts example, fix quotes (#35771) 2023-03-08 10:10:01 +01:00
Harmen Stoppels
c37d6f97dc
compiler wrapper: parse Wl and Xlinker properly (#35912)
Two fixes:

1. `-Wl,a,b,c,d` is a comma separated list of linker arguments, we
   incorrectly assume key/value pairs, which runs into issues with for
   example `-Wl,--enable-new-dtags,-rpath,/x`
2. `-Xlinker,xxx` is not a think, so it shouldn't be parsed.
2023-03-08 09:03:31 +01:00
Greg Becker
2ff337a2a5
compiler flags: fix multiple compilers with different flags (#35721)
Currently, if two compilers with the same spec differ on the flags, the concretizer will:

1. mix both sets of flags for the spec in the ASP program
2. error noting that the set of flags from the compiler (both of them) doesn't match the set from the lower priority compiler

This PR fixes both -- only flags from the highest priority compiler with a given spec are considered.
2023-03-06 10:29:48 -08:00
Todd Gamblin
42a02411b4
windows: use sys.platform == "win32" instead of is_windows (#35640)
`mypy` only understands `sys.platform == "win32"`, not indirect assignments of that
value to things like `is_windows`. If we don't use the accepted platform checks, `mypy`
registers many Windows-only symbols as not present on Linux, when it should skip the
checks for platform-specific code.
2023-03-05 07:58:05 -08:00
Massimiliano Culpo
046416479a
Polish spack.util.environment (#35812)
Update `spack.util.environment` to remove legacy idioms.
* Remove kwargs from method signature and use a class for traces
* Uppercase a few global variables
* spack.util.environment: add type-hints
* Improve docstrings
* Fixed most style issues reported by pylint
2023-03-03 16:17:27 -05:00
Brian Van Essen
eb29889f6e
Detection of Cray's slingshot detection has relied on the presence of (#35779)
a shared library /lib64/libcxi.so, which seems to also appear on other
non-slingshot systems.  This patch also checks to make sure that there
is a Cray programming enviornment in /opt/cray/pe in addition to the
shared library.
2023-03-01 23:19:20 -08:00
Adam J. Stewart
583d89e95a
Simplify spack help --spec output (#35626) 2023-03-01 16:26:59 +01:00
Adam J. Stewart
146464e063
Docs: fix link to PythonPackage docs (#35725) 2023-03-01 11:14:05 +01:00
Massimiliano Culpo
07e251c887
Remove handling of deprecated target names (graviton) (#35537)
* Update target names for Gitlab pipelines

* Remove handling of deprecated names for graviton
2023-03-01 11:03:12 +01:00
Alberto Invernizzi
4e13b5374f
fix dump problem (#35673)
if dump file existed it was not truncating the file, resulting in
a file with unaltered filesize, with the new content at the beginning,
"padded" with the tail of the old content, since the new content was
not enough to overwrite it.
2023-02-24 21:32:33 -08:00
Todd Gamblin
6b27aebeb4
colify.py: get rid of **kwargs (#35641)
`colify` is an old module in Spack that still uses `**kwargs` liberally. 

We should be more explicit. Doing this eliminates the need for many 
checks (can't pass the wrong arg if it isn't allowed) and makes the 
function documentation more clear.
2023-02-23 11:18:54 -08:00
Harmen Stoppels
3d41b71664
buildcache push: ensure bool arguments for include_* (#35632)
Fixes a bug introduced in 44ed0de8c0
where the push method of binary_distribution now takes named args
include_root and include_depedencies, to avoid the **kwarg hole.

But the call site wasn't update and we passed a dict of keys/values instead
of arguments, which resulted in a call like this:

```
push(include_root={"include_root": True, "include_dependencies": False})
```

This commit fixes that, and adds a test to see if we push the correct packages.
2023-02-23 01:44:47 +01:00
Harmen Stoppels
3be9af8c13
copy_files_to_artifacts: error -> warning (#35613)
This error shows up a lot, typically it's harmless because an error
happened before the source build even started, in which case we don't
have build logs to copy. So, warn instead of error, cause it distracts
from the actual CI error.
2023-02-22 11:53:42 +00:00
Harmen Stoppels
6e477d547d
add cdash arg to source build only (#35565) 2023-02-22 11:08:32 +01:00
Harmen Stoppels
9d6630e245
spack build-env: error when deps are not installed (#35533)
Currently we attempt to setup the build environment even when
dependencies are not installed, which typically results in error while
searching for libraries or executables in a dependency's prefix.

With this change, we get a more user friendly error:

```
$ spack build-env perl
==> Error: Not all dependencies of perl are installed, cannot setup build environment:
 -   qpj6dw5  perl@5.36.0%apple-clang@14.0.0+cpanm+open+shared+threads build_system=generic arch=darwin-ventura-m1
 -   jq2plbe      ^berkeley-db@18.1.40%apple-clang@14.0.0+cxx~docs+stl build_system=autotools patches=26090f4,b231fcc arch=darwin-ventura-m1
...
$ echo $?
1
```
2023-02-22 10:35:44 +01:00
psakievich
b8d15e816b
Allow users to specify root env dir (#32836)
* Allow users to specify root env dir

Environments managed by spack have some advantages over anonymous Environments
but they are tucked away inside spack's directory tree. This PR gives
users the ability to specify where the environments should live.

See #32823

This is also taken as an opportunity to ensure that all references are to "managed environments",
rather than "named environments". Prior to this PR some references to the latter persisted.

Co-authored-by: Tom Scogland <scogland1@llnl.gov>
Co-authored-by: Tamara Dahlgren <35777542+tldahlgren@users.noreply.github.com>
Co-authored-by: Gregory Becker <becker33@llnl.gov>
2023-02-22 00:37:14 +00:00
Harmen Stoppels
bc24a8f290
Spec.satisfies should be commutative when strict=False (#35598)
The call:
```
x.satisfies(y[, strict=False])
```
is commutative, and tests non-empty intersection, whereas:
```
x.satsifies(y, strict=True)
```
is not commutative, and tests set-inclusion.

There are 2 fast paths. When strict=False both self and other need to 
be concrete, when strict=True we can optimize when other is concrete.
2023-02-21 14:30:47 +01:00
simon-Leary42
33bf1fd033
nonexistent module concise error message (#35502) 2023-02-21 04:50:56 -08:00
Adam J. Stewart
ce9f8143cc
Fix view support for optional Python extensions (#35489)
Co-authored-by: Harmen Stoppels <harmenstoppels@gmail.com>
2023-02-20 11:58:28 -08:00
Harmen Stoppels
c1ff7bbf04
environment views: better, earlier error on clash (#35541)
Spack generally ignores file-file projection clashes in environment
views, but would eventually error when linking the `.spack` directory
for two specs of the same package.

This leads to obscure errors where users have no clue what the issue is
and how to fix it. On top of that, the error comes very late, since it
happens when the .spack dir contents are linked (which happens after
everything else)

This PR improves that by doing a quick check ahead of time if clashes
are going to be anticipated (by simply checking for clashes in the
projection of each spec's .spack metadir). If there are clashes, a
human-readable error is thrown which shows two of the conflicting specs,
and tells users to user unify:true, view:false, or set up custom
projections.
2023-02-20 19:14:27 +01:00
Ben Wibking
e8238fe330
Patchel shutil.copystat to avoid PermissionError on Lustre (#27247) 2023-02-20 17:28:03 +01:00
Harmen Stoppels
5e337d907b
spack ci: remove 120s db timeout since 60s is the default now (#35566) 2023-02-20 14:41:26 +01:00
Harmen Stoppels
208c9585b8
Revert "lib/spack/spack/store.py: Fix #28170 for padding relocation (#33122)" (#35077)
This reverts commit c721aab006.
2023-02-20 13:56:11 +01:00
elenimath
c769582709
Pass tests argument to solver method when concretizing together (#35290)
to make the workaround for #29447 work with `concretizer:unify:true` option
2023-02-20 10:21:24 +01:00
Adam J. Stewart
7c01d3ba35
Fix broken links in docs (#35582) 2023-02-20 09:21:18 +01:00
Harmen Stoppels
86320eb569
Improve error handling in buildcache downloads (#35568)
The checksum exception was not detailed enough and not reraised when using cache only, resulting in useless error messages.

Now it dumps the file path, expected
hash, computed hash, and the downloaded file summary.
2023-02-18 19:22:48 +01:00
Harmen Stoppels
fb644de086
clang/apple-clang correct c/c++ standard flags (#35062) 2023-02-17 23:18:01 +01:00
Adam J. Stewart
603569e321
Style: black 23, skip magic trailing comma (#35351)
* Style: black 23, skip magic trailing commas

* isort should use same line length as black

* Fix unused import

* Update version of black used in CI

* Update new packages

* Update new packages
2023-02-16 23:06:12 -06:00
Harmen Stoppels
68b711c1ad
view: fix issue with non-contributing specs (#34661)
Specs that did not contribute any files to an env view caused a problem
where zip(specs, files grouped by prefix) got "out of sync", causing the
wrong merge map to be passed to a package's `add_files_to_view`, which
specifically caused an issue where *sometimes* bin/python ended up as a
symlink instead of a copy.

One such example is kokkos + kokkos-nvcc-wrapper, as the latter package
only provides the file bin/nvcc_wrapper, which is also added to view by
kokkos, causing kokkos-nvcc-wrapper to contribute 0 files.

The test feels a bit contrived, but it captures the problem... pkg a is
added first and has 0 files to contribute, pkg b adds a single file, and
we check if pkg b receives a merge map (and a does not).
2023-02-16 10:36:22 -08:00
Harmen Stoppels
96ac4c7f98
simplify cdash filename (#35509) 2023-02-16 18:25:39 +01:00
Harmen Stoppels
44ed0de8c0
spack buildcache create: push all deps / cleanup (#34860) 2023-02-16 14:08:49 +00:00
Harmen Stoppels
09eb86e077
spack uninstall: follow run/link edges on --dependents (#34058)
`spack gc` removes build deps of explicitly installed specs, but somehow
if you take one of the specs that `spack gc` would remove, and feed it
to `spack uninstall /<hash>` by hash, it complains about all the
dependents that still rely on it.

This resolves the inconsistency by only following run/link type deps in
spack uninstall.

That way you can finally do `spack uninstall cmake` without having to
remove all packages built with cmake.
2023-02-16 14:26:30 +01:00
Massimiliano Culpo
50691ccdd9
Avoid verifying variants in default package requirements (#35037)
Default package requirements might contain
variants that are not defined in each package,
so we shouldn't verify them when emitting facts
for the ASP solver.

Account for group when enforcing requirements

packages:all : don't emit facts for requirement conditions
that can't apply to current spec
2023-02-16 11:57:26 +01:00
Harmen Stoppels
ce693ff304
buildcache create: avoid prefix copy (#35173) 2023-02-16 11:52:10 +01:00
Adam J. Stewart
dd434ec413
Use the maintainers directive in all base classes (#35324)
* Use the `maintainers` directive in all base classes
* Update unit tests
2023-02-15 01:33:29 -08:00
luker
9b3c4e0696
Update cce.py (#35469)
* Update cce.py

adding c++17 flag for cce

* Update cce.py
2023-02-14 07:37:34 +00:00
John W. Parent
e1341d70ce
MSBuilder/MSVC: correct toolchain ver (#35424)
#35098 added the correct extraction of toolset version for the MSVC
compiler. This updates the associated method in MSBuilder to retrieve
the (now correct) property.
2023-02-10 10:53:16 -08:00
Zack Galbreath
82041ac5a3
Restore our ability to submit build/test results to CDash from GitLab CI (#35328)
* Restore our ability to submit build/test results to CDash from GitLab CI

* Don't use CDash upload URL as report filename
2023-02-10 12:01:05 -06:00
Adam J. Stewart
7e78efcc44
spack help --spec: fix indentation (#35383) 2023-02-08 08:46:56 -08:00
Massimiliano Culpo
27c2ff6c64
Ensure we print the correct branch number for tutorials (#35371) 2023-02-08 09:46:21 +01:00
Scott Wittenburg
9bde77199c
bindist: use append as a method, not assignable attr (#35379) 2023-02-08 09:42:28 +01:00
Dan Lipsa
1648968514
Windows: Fix spack.bat handling of env commands (#35143)
This PR enables the successful execution of the spack binary cache
tutorial on Windows. It assumes gnupg and file are available (they
can be installed with choco).

* Fix handling of args with quotes in spack.bat
* `file` utility can be installed on Windows (e.g. with choco): update
  error message accordingly
2023-02-07 11:04:14 -08:00
Matthias Wolf
a7f39da5db
Fix path handling in prefix inspections (#35318)
At least with ZSH, prefix inspections containing `./bin` result in a
`$PREFIX/./bin` and result in strange `$PATH` handling.

I.e., `module load git` will prepend `/path/to/git/./bin`, `which git`
will find the right executable, but `git --version` will print the
system one. Normalize the relative path to avoid this behavior.

See also spack/spack#31867.
2023-02-06 19:12:30 -08:00
Tamara Dahlgren
383a343412
GenericBuilder: facilitate post-install phase test callbacks (#35314) 2023-02-06 12:51:01 -08:00
Massimiliano Culpo
017a15988c
Don't use CDash upload URL as report filename (#35338)
fixes #35337
2023-02-05 12:58:45 +01:00
John W. Parent
1826a41cdd
MSVC compiler: add platform toolset version (#35098) 2023-02-03 17:53:24 -08:00
John W. Parent
c49e2e5620
NMake builder: fix incorrect variable reference (#34937) 2023-02-02 16:34:35 -08:00
Massimiliano Culpo
ddecf07045
Use the maintainers directive in all packages (#35201) 2023-02-01 21:07:25 -08:00
Massimiliano Culpo
46466302a9
Pin black to 22.12.0 to avoid spurious style changes (#35282)
We need to sync changes on major versions with
spackbot, to avoid the bot saying everything is
allright and have CI failing nonetheless.
2023-02-01 15:45:12 +01:00
Massimiliano Culpo
cc2ae9f270
Add a maintainers directive (#35083)
fixes #34879

This commit adds a new maintainer directive,
which by default extend the list of maintainers
for a given package.

The directive is backward compatible with the current
practice of having a "maintainers" list declared at
the class level.
2023-01-27 07:51:24 +01:00
Harmen Stoppels
6847d73504
Cleanup of binary text relocation (#34188)
Move the relocation of binary text in its own class

Drop threaded text replacement, since the current bottleneck 
is decompression. It would be better to parallellize over packages,
instead of over files per package.

A small improvement with separate classes for text replacement is that we
now compile the regex in the constructor; previously it was compiled per
binary to be relocated.
2023-01-26 12:18:53 +01:00
Massimiliano Culpo
84917cfa79
Extract functions to read spec files from different format (#35094)
This commit makes explicit the format version of the spec file
we are reading from.

Before there were different functions capable of reading some
part of the spec file at multiple format versions. The decision
was implicit, since checks were based on the structure of the
JSON without ever checking a format version number.

The refactor makes also explicit which spec file format is used
by which database and lockfile format, since the information is
stored in global mappings.

To ensure we don't change the hash of old specs, JSON representations
of specs have been added as data. A unit tests checks that we read
the correct hash in, and that the hash stays the same when we
re-serialize the spec using the most recent format version.

Co-authored-by: Harmen Stoppels <me@harmenstoppels.nl>
2023-01-26 10:40:46 +01:00
Harmen Stoppels
918bb63c3a
test/config.py: fix import issues (#35076) 2023-01-26 09:53:44 +01:00
Harmen Stoppels
5f8c09fd33
Print file summary on checksum validation failure (#35161)
Currently we print "sha256 checksum failed for [file]. Expected X but
got Y".

This PR extends that message with file size and contents info:

"... but got Y. File size = 123456 bytes. Contents = b'abc...def'"

That way we can immediately see if the file was downloaded only
partially, or if we downloaded a text page instead of a binary, etc.

Co-authored-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
2023-01-25 15:02:41 +00:00
Cory Bloor
d17aaf8729
hip: add cuda variant (#33872) 2023-01-24 22:30:58 +01:00
Massimiliano Culpo
115b6b2a51
Avoid creating help.sh and test.sh in cwd (#35123)
When running unit-test the test/ci.py module is leaving
garbage (help.sh, test.sh files) in the current working
directory.

This commit changes the current working directory to a
temporary path before those files are created.
2023-01-24 03:42:15 -08:00
kwryankrattiger
cd2d6a6397
ParaView/VTK: Patch xdmf2 for HDF5 1.13 (#33930)
* ParaView/VTK: Patch xdmf2 for HDF5 1.13

* Meson: update meson build system for 0.64

* ParaView: Change HDF5 1.13 patch to 1.13.1/2 patchs

* Mesa: Remove legacy mesa option from meson_args

* Use append to assemble meson args
2023-01-23 19:22:21 -08:00
Richarda Butler
a4b8753456
Update: spack help --spec (#35115)
* Update variant & compiler propagation
* Add the info for non boolean variants
* Add example for multi variants
2023-01-24 00:42:08 +00:00
Harmen Stoppels
13739e0783
environments: don't replace relative view path with absolute path on concretize/install (#34958)
* environments: don't rewrite relative view path, expand path on cli ahead of time

Currently if you have a spack.yaml that specifies a view by relative
path, Spack expands it to an absolute path on `spack -e . install` and
persists that to disk.

This is rather annoying when you have a `spack.yaml` file inside a git
repo, cause you want to use relative paths to make it relocatable, but
you constantly have to undo the changes made to spack.yaml by Spack.

So, as an alternative:

1. Always stick to paths as they are provided in spack.yaml, never
   replace them with a canonicalized version
2. Turn relative paths on the command line into absolute paths before
   storing to spack.yaml. This way you can do `spack env create --dir
   ./env --with-view ./view` and both `./env` and `./view` are resolved
   to the current working dir, as expected (not `./env/view`). This
   corresponds to the old behavior of `spack env create`.

* create --with-view always takes a value
2023-01-23 10:03:54 -08:00
Alex Richert
ce8727cece
Add --exclude option to 'spack external find' (#35013)
* Add --exclude option to 'spack external find' to ignore user-specified external packages
* Update bash completion arg order for external find

Co-authored-by: Todd Gamblin <tgamblin@llnl.gov>
2023-01-21 15:43:20 -08:00
markus-ferrell
c3e3c392a6
Windows/testing: enable tests for "spack find" (#33588) 2023-01-20 17:54:06 -08:00
John W. Parent
a424f7f173
Identify Windows support with tags (#35027)
All packages with explicit Windows support can be found with
`spack list --tags=windows`.

This also removes the documentation which explicitly lists
supported packages on Windows (which is currently out of date and
is now unnecessary with the added tags).

Note that if a package does not appear in this list, it *may*
still build on Windows, but it likely means that no explicit
attempt has been made to support it.
2023-01-20 13:32:28 -08:00
Massimiliano Culpo
8f8394a829
Add type hints to DependencySpec (#35021)
* DependencySpec: add type hints

* DependencySpec: make deptypes a keyword only argument
2023-01-20 09:53:57 +01:00
Harmen Stoppels
80db7a8a52
buildcache create: make "file exists" less verbose (#35019)
Currently we print 3 lines of "file exist" warning per tarball, this is
a bit excessive. Instead, it can be a simple single-line tty.warn
message.
2023-01-19 15:35:24 +00:00
Stephen Sachs
45ea7c19e5
[py-numpy, py-scipy] Enable MKL & ARMpl (#34979) 2023-01-19 08:01:31 -07:00
Harmen Stoppels
a357a39963
depfile: --make-target-prefix -> --make-prefix (#35009)
Since SPACK_PACKAGE_IDS is now also "namespaced" with <prefix>, it makes
more sense to call the flag `--make-prefix` and alias the old flag
`--make-target-prefix` to it.
2023-01-19 14:58:34 +01:00
Greg Becker
08101639cd
Bugfix: External Python Extensions (#34202)
Normally when using external packages in concretization, Spack ignores
all dependencies of the external. #33777 updated this logic to attach
a Python Spec to external Python extensions (most py-* packages), but
as implemented there were a couple issues:

* this did not account for concretization groups and could generate
  multiple different python specs for a single DAG
* in some cases this created a fake Python spec with insufficient
  details to be usable (concretization/installation of the
  extension would fail)

This PR addresses both of these issues: 

* For environment specs that are concretized together, external python
  extensions in those specs will all be assigned the same Python spec
* If Spack needs to "invent" a Python spec, then it will have all the
  needed details (e.g. compiler/architecture)
2023-01-18 15:17:28 -08:00
Harmen Stoppels
fce95e2efb
license year bump (#34921)
* license bump year
* fix black issues of modified files
* mypy
* fix 2021 -> 2023
2023-01-18 14:30:17 -08:00
Harmen Stoppels
f050b1cf78
depfile: variable with all identifiers (#34678)
With the new variable [prefix/]SPACK_PACKAGE_IDS you can conveniently execute
things after each successful install.

For example push just-built packages to a buildcache

```
SPACK ?= spack
export SPACK_COLOR = always
MAKEFLAGS += -Orecurse
MY_BUILDCACHE := $(CURDIR)/cache

.PHONY: all clean

all: push

ifeq (,$(filter clean,$(MAKECMDGOALS)))
include env.mk
endif

# the relevant part: push has *all* example/push/<pkg identifier> as prereqs
push: $(addprefix example/push/,$(example/SPACK_PACKAGE_IDS))
	$(SPACK) -e . buildcache update-index --directory $(MY_BUILDCACHE)
	$(info Pushed everything, yay!)

# and each example/push/<pkg identifier> has the install target as prereq,
# and the body can use target local $(HASH) and $(SPEC) variables to do
# things, such as pushing to a build cache
example/push/%: example/install/%
	@mkdir -p $(dir $@)
	$(SPACK) -e . buildcache create --allow-root --only=package --unsigned --directory $(MY_BUILDCACHE) /$(HASH) # push $(SPEC)
	@touch $@

spack.lock: spack.yaml
	$(SPACK) -e . concretize -f

env.mk: spack.lock
	$(SPACK) -e . env depfile -o $@ --make-target-prefix example

clean:
	rm -rf spack.lock env.mk example/
``
2023-01-18 19:19:46 +01:00
Harmen Stoppels
3bc943ae51
Remove verbose warning message from _try_install_from_binary_cache (#34994)
In the past we checked remote binary mirrors for existence of a spec
before attempting to download it. That changed to only checking local
copies of index.jsons (if available) to prioritize certain mirrors where
we expect to find a tarball. That was faster for CI since fetching
index.json and loading it just to order mirrors takes more time than
just attempting to fetch tarballs -- and also if we have a direct hit
there's no point to look at other mirrors.

Long story short: the info message only makes sense in the old version
of Spack, so it's better to remove it.
2023-01-18 08:25:48 -06:00
Dom Heinzeller
548aa21b18
Bug fix for duplicate rpath errors on macOS when creating build caches (#34375) 2023-01-18 13:32:16 +01:00
Harmen Stoppels
fef0f47d65
spack mirror create takes local paths only (#34992)
spack mirror create cannot work with urls, so it shouldn't promote local
paths to file urls.
2023-01-18 11:45:58 +01:00
Massimiliano Culpo
b148a43f08
CDashReporter: remove unused argument (#34869)
* CDashReporter: remove unused argument
* Removed extract_ctest_test_data
2023-01-17 11:09:38 -08:00
Massimiliano Culpo
74901a3d0d
Forward lookup of "test_log_file" and "test_failures" (#34882)
* Forward lookup of "test_log_file" and "test_failures"
  refers #34531
  closes #34487
  fixes #34440
* Add unit test
* py-libensemble: fix tests
* Support stand-alone tests with cached files as install-time tests

Co-authored-by: Tamara Dahlgren <dahlgren1@llnl.gov>
2023-01-17 10:59:48 -08:00
roottreej
7659912dc4
Reduce verbosity in mirrors.yaml (#34210)
Ensure `spack mirror add <name> <url/path>` without further arguments translates to `<name>: <url>` key value pairs in mirrors.yaml. If --s3-* flags are provided, only store the provided ones. 

Co-authored-by: Harmen Stoppels <me@harmenstoppels.nl>
2023-01-17 13:19:13 +00:00
Harmen Stoppels
3489cc0a9b
Refer to mirrors by name, path, or url (#34891)
With this change we get the invariant that `mirror.fetch_url` and
`mirror.push_url` return valid URLs, even when the backing config
file is actually using (relative) paths with potentially `$spack` and
`$env` like variables.

Secondly it avoids expanding mirror path / URLs too early,
so if I say `spack mirror add name ./path`, it stays `./path` in my
config. When it's retrieved through MirrorCollection() we
exand it to say `file://<env dir>/path` if `./path` was set in an
environment scope.

Thirdly, the interface is simplified for the relevant buildcache
commands, so it's more like `git push`:

```
spack buildcache create [mirror] [specs...]
```

`mirror` is either a mirror name, a path, or a URL.

Resolving the relevant mirror goes as follows:
    
- If it contains either / or \ it is used as an anonymous mirror with
   path or url.
- Otherwise, it's interpreted as a named mirror, which must exist.

This helps to guard against typos, e.g. typing `my-mirror` when there
is no such named mirror now errors with:

```
$ spack -e . buildcache create my-mirror
==> Error: no mirror named "my-mirror". Did you mean ./my-mirror?
```

instead of creating a directory in the current working directory. I
think this is reasonable, as the alternative (requiring that a local dir
exists) feels a bit pendantic in the general case -- spack is happy to
create the build cache dir when needed, saving a `mkdir`.

The old (now deprecated) format will still be available in Spack 0.20,
but is scheduled to be removed in 0.21:

```
spack buildcache create (--directory | --mirror-url | --mirror-name) [specs...]
```

This PR also touches `tmp_scope` in tests, because it didn't really
work for me, since spack fixes the possible --scope values once and
for all across tests, so tests failed when run out of order.
2023-01-16 10:14:41 -08:00
Gilles Gouaillardet
17a67b9a56
fix libtool filter for Fujitsu compilers (#34916)
Since legit regular expressions are matched, do not pass string=True
to the filter

Refs #34897
2023-01-16 15:56:13 +01:00
Jack Morrison
add8022490
Fix incorrect configuration file name in docs (#34925) 2023-01-16 14:52:08 +01:00
Adam J. Stewart
5f4b736006
Drop Python 3.6 again (#34442) 2023-01-16 10:09:40 +01:00
Todd Gamblin
d4e714bb2e
spack list: add --count option (#34950)
Sometimes I just want to know how many packages of a certain type there are.

- [x] add `--count` option to `spack list` that output the number of packages that
      *would* be listed.

```console
> spack list --count
6864
> spack list --count py-
2040
> spack list --count r-
1162
```
2023-01-14 16:08:40 -08:00
John W. Parent
ff38ff25cb
Support windows paths in a spec (#34405)
Refactor Spack's spec syntax parsing to handle Windows style paths
Amend unit tests to reflect this updated behavior.
2023-01-14 07:52:37 +01:00
Todd Gamblin
88a604e7f4
config: make path replacements lazy (#34758)
Currently, all of the replacements in `spack.util.path.replacements()` get evaluated for
each replacement. This makes it easy to get bootstrap issues, because config is used
very early on in Spack.

Right now, if I run `test_autotools_gnuconfig_replacement_no_gnuconfig` on my M1 mac, I
get the circular reference error below. This fixes the issue by making all of the path
replacements lazy lambdas.

As a bonus, this cleans up the way we do substitution for `$env` -- it's consistent with
other substitutions now.

- [x] make all path `replacements()` lazy
- [x] clean up handling of `$env`

```console
> spack unit-test -k test_autotools_gnuconfig_replacement_no_gnuconfig

...

==> [2022-12-31-15:44:21.771459] Error: AttributeError:

The 'autotools-config-replacement' package cannot find an attribute while trying to build from sources. This might be due to a change in Spack's package format to support multiple build-systems for a single package. You can fix this by updating the build recipe, and you can also report the issue as a bug. More information at https://spack.readthedocs.io/en/latest/packaging_guide.html#installation-procedure

/Users/gamblin2/src/spack/lib/spack/spack/package_base.py:1332, in prefix:
       1330    @property
       1331    def prefix(self):
  >>   1332        """Get the prefix into which this package should be installed."""
       1333        return self.spec.prefix

Traceback (most recent call last):
  File "/Users/gamblin2/src/spack/lib/spack/spack/build_environment.py", line 1030, in _setup_pkg_and_run
    kwargs["env_modifications"] = setup_package(
                                  ^^^^^^^^^^^^^^
  File "/Users/gamblin2/src/spack/lib/spack/spack/build_environment.py", line 757, in setup_package
    set_module_variables_for_package(pkg)
  File "/Users/gamblin2/src/spack/lib/spack/spack/build_environment.py", line 596, in set_module_variables_for_package
    m.std_cmake_args = spack.build_systems.cmake.CMakeBuilder.std_args(pkg)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gamblin2/src/spack/lib/spack/spack/build_systems/cmake.py", line 241, in std_args
    define("CMAKE_INSTALL_PREFIX", pkg.prefix),
                                   ^^^^^^^^^^
  File "/Users/gamblin2/src/spack/lib/spack/spack/package_base.py", line 1333, in prefix
    return self.spec.prefix
           ^^^^^^^^^^^^^^^^
  File "/Users/gamblin2/src/spack/lib/spack/spack/spec.py", line 1710, in prefix
    self.prefix = spack.store.layout.path_for_spec(self)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gamblin2/src/spack/lib/spack/spack/directory_layout.py", line 336, in path_for_spec
    path = self.relative_path_for_spec(spec)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gamblin2/src/spack/lib/spack/spack/directory_layout.py", line 106, in relative_path_for_spec
    projection = spack.projections.get_projection(self.projections, spec)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gamblin2/src/spack/lib/spack/spack/projections.py", line 13, in get_projection
    if spec.satisfies(spec_like, strict=True):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gamblin2/src/spack/lib/spack/spack/spec.py", line 3642, in satisfies
    if not self.virtual and other.virtual:
           ^^^^^^^^^^^^
  File "/Users/gamblin2/src/spack/lib/spack/spack/spec.py", line 1622, in virtual
    return spack.repo.path.is_virtual(self.name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 890, in is_virtual
    return have_name and pkg_name in self.provider_index
                                     ^^^^^^^^^^^^^^^^^^^
  File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 770, in provider_index
    self._provider_index.merge(repo.provider_index)
                               ^^^^^^^^^^^^^^^^^^^
  File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 1096, in provider_index
    return self.index["providers"]
           ~~~~~~~~~~^^^^^^^^^^^^^
  File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 592, in __getitem__
    self._build_all_indexes()
  File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 607, in _build_all_indexes
    self.indexes[name] = self._build_index(name, indexer)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 616, in _build_index
    index_mtime = self.cache.mtime(cache_filename)
                  ^^^^^^^^^^^^^^^^
  File "/Users/gamblin2/src/spack/lib/spack/llnl/util/lang.py", line 826, in __getattr__
    return getattr(self.instance, name)
                   ^^^^^^^^^^^^^
  File "/Users/gamblin2/src/spack/lib/spack/llnl/util/lang.py", line 825, in __getattr__
    raise AttributeError()
AttributeError
```
2023-01-13 10:27:07 -08:00
Tamara Dahlgren
c0b458e38a
Documentation: Add installation policy to packaging guide (#34878) 2023-01-12 11:01:35 -08:00
Massimiliano Culpo
ccb9969b64
Fix issue when generating compiler hierarchy (#34873)
- [x] Fix bug affecting generation of Lmod modules
2023-01-11 10:09:02 -08:00
John W. Parent
7365d138fb
Build systems: add MSBuild and update NMake (#34659)
Add/update build systems used to build packages on Windows.
2023-01-10 17:03:15 -08:00
Massimiliano Culpo
9d00e7d15d
Remove **kwargs from function signatures in llnl.util.filesystem (#34804)
Since we dropped support for Python 2.7, we can embrace using keyword only arguments 
for many functions in Spack that use **kwargs in the function signature. Here this is done 
for the llnl.util.filesystem module.

There were a couple of bugs lurking in the code related to typo-like errors when retrieving
from kwargs. Those have been fixed as well.
2023-01-10 14:23:42 +01:00
Jonathon Anderson
807b87068a
style: Run mypy last (#34687) 2023-01-10 04:37:41 -08:00
Jonathon Anderson
6879c35d1c
FileCache: Delete the new cache file on exception (#34623)
The code in FileCache for write_transaction attempts to delete the temporary file when an exception occurs under the context by calling shutil.rmtree. However, rmtree only operates on directories while the rest of FileCache uses normal files. This causes an empty file to be written to the cache key when unneeded.

Use os.remove instead which operates on normal files.

Co-authored-by: Harmen Stoppels <harmenstoppels@gmail.com>
2023-01-10 13:36:12 +01:00
Wileam Y. Phan
0f7f600d1f
Add CUDA 12.0 (#34664) 2023-01-10 11:51:23 +01:00
John Parent
9f0bb4301f Support ASCI control
Windows CMD prompt does not automatically support ASCI color control
characters on the console from Python. Enable this behavior by
accessing the current console and allowing the interpreation of ASCI
control characters from Python via the win32 API.
2023-01-09 09:14:17 -08:00
Harmen Stoppels
47011f594f
Revert "Allow spec.json files to be clearsigned, use transparent compression for *.json (#34490)" (#34856)
This reverts commit 8a1b817978.
2023-01-09 10:52:07 +01:00
Harmen Stoppels
8a1b817978
Allow spec.json files to be clearsigned, use transparent compression for *.json (#34490)
This commit allows (remote) spec.json files to be clearsigned and gzipped.

The idea is to reduce the number of requests and number of bytes transferred
2023-01-07 12:22:40 +01:00
QuellynSnead
ea970c8ab8
Fix PrgEnv detection (#34845)
* Fix PrgEnv detection for Cray compiler link paths
2023-01-06 18:11:43 +00:00
Massimiliano Culpo
eace2ebb08
spack.dependency: add type hints (#34807) 2023-01-05 17:48:29 +01:00
Massimiliano Culpo
6a44a146af Fix building docs 2023-01-04 09:43:04 -08:00
Massimiliano Culpo
033cb86fd6 Add vendored packages back 2023-01-04 09:43:04 -08:00
Massimiliano Culpo
5175189412 Delete outdated externals 2023-01-04 09:43:04 -08:00
Massimiliano Culpo
86378502f9 Use "vendoring" to manage 3rd party dependencies 2023-01-04 09:43:04 -08:00
Massimiliano Culpo
310b6b9466
Remove dead code that was needed for the old parser (#34792)
The old to token definitions and spec_id_re regular
expression are not used anymore
2023-01-04 05:47:21 -08:00
Harmen Stoppels
2e8d165120
environment view use new traversal (#34662) 2023-01-02 19:04:55 +01:00
Massimiliano Culpo
b549548f69
Simplify creation of test and install reports (#34712)
The code in Spack to generate install and test reports currently suffers from unneeded complexity. For
instance, we have classes in Spack core packages, like `spack.reporters.CDash`, that need an
`argparse.Namespace` to be initialized and have "hard-coded" string literals on which they branch to
change their behavior:

```python
if do_fn.__name__ == "do_test" and skip_externals:
    package["result"] = "skipped"
else:
    package["result"] = "success"
package["stdout"] = fetch_log(pkg, do_fn, self.dir)
package["installed_from_binary_cache"] = pkg.installed_from_binary_cache
if do_fn.__name__ == "_install_task" and installed_already:
    return
```
This PR attempt to polish the major issues encountered in both `spack.report` and `spack.reporters`.

Details:
- [x] `spack.reporters` is now a package that contains both the base class `Reporter` and all 
      the derived classes (`JUnit` and `CDash`)
- [x] Classes derived from `spack.reporters.Reporter` don't take an `argparse.Namespace` anymore
       as argument to `__init__`. The rationale is that code for commands should be built upon Spack
       core classes, not vice-versa.
- [x] An `argparse.Action` has been coded to create the correct `Reporter` object based on command
       line arguments
- [x] The context managers to generate reports from either `spack install` or from `spack test` have
       been greatly simplified, and have been made less "dynamic" in nature. In particular, the `collect_info`
       class has been deleted in favor of two more specific context managers. This allows for a simpler
       structure of the code, and less knowledge required to client code (in particular on which method to patch)
- [x] The `InfoCollector` class has been turned into a simple hierarchy, so to avoid conditional statements
       within methods that assume a knowledge of the context in which the method is called.
2022-12-30 10:15:38 -08:00
Todd Gamblin
06312ddf18
bugfix: setgid tests fail when primary group is unknown (#34729)
On systems with remote groups, the primary user group may be remote and may not exist on
the local system (i.e., it might just be a number). On the CLI, it looks like this:

```console
> touch foo
> l foo
-rw-r--r-- 1 gamblin2 57095 0 Dec 29 22:24 foo
> chmod 2000 foo
chmod: changing permissions of 'foo': Operation not permitted
```

Here, the local machine doesn't know about per-user groups, so they appear as gids in
`ls` output. `57095` is also `gamblin2`'s uid, but the local machine doesn't know that
`gamblin2` is in the `57095` group.

Unfortunately, it seems that Python's `os.chmod()` just fails silently, setting
permissions to `0o0000` instead of `0o2000`. We can avoid this by ensuring that the file
has a group the user is known to be a member of.

- [x] Add `ensure_known_group()` in the permissions tests.
- [x] Call `ensure_known_group()` on tempfile in `test_chmod_real_entries_ignores_suid_sgid`.
2022-12-30 10:24:35 +01:00
Todd Gamblin
3a0db729c7
docs: avoid errors by using type hints instead of doc types (#34707)
There are a number of places in our docstrings where we write "list of X" as the type, even though napoleon doesn't actually support this. It ends up causing warnings when generating docs.

Now that we require Python 3, we don't have to rely on type hints in docs -- we can just use Python type hints and omit the types of args and return values from docstrings.

We should probably do this for all types in docstrings eventually, but this PR focuses on the ones that generate warnings during doc builds.

Some `mypy` annoyances we should consider in the future:
1. Adding some of these type annotations gets you:
    ```
    note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
    ```
   because they are in unannotated functions (like constructors where we don't really need any annotations).
   You can silence these with `disable_error_code = "annotation-unchecked"` in `pyproject.toml`
2. Right now we support running `mypy` in Python `3.6`.  That means we have to support `mypy` `.971`, which does not support `disable_error_code = "annotation-unchecked"`, so I just filter `[annotation-unchecked]` lines out in `spack style`.
3. I would rather just turn on `check_untyped_defs` and get more `mypy` coverage everywhere, but that will require about 1,000 fixes.  We should probably do that eventually.
4. We could also consider only running `mypy` on newer python versions.  This is not easy to do while supporting `3.6`, because you have to use `if TYPE_CHECKING` for a lot of things to ensure that 3.6 still parses correctly.  If we only supported `3.7` and above we could use [`from __future__ import annotations`](https://mypy.readthedocs.io/en/stable/runtime_troubles.html#future-annotations-import-pep-563), but we have to support 3.6 for now. Sigh.

- [x] Convert a number of docstring types to Python type hints
- [x] Get rid of "list of" wherever it appears
2022-12-29 16:45:09 -08:00
Todd Gamblin
5f8c706128
Consolidate how Spack uses git (#34700)
Local `git` tests will fail with `fatal: transport 'file' not allowed` when using git 2.38.1 or higher, due to a fix for `CVE-2022-39253`.

This was fixed in CI in #33429, but that doesn't help the issue for anyone's local environment. Instead of fixing this with git config in CI, we should ensure that the tests run anywhere.

- [x] Introduce `spack.util.git`.
- [x] Use `spack.util.git.get_git()` to get a git executable, instead of `which("git")` everywhere.
- [x] Make all `git` tests use a `git` fixture that goes through `spack.util.git.get_git()`.
- [x] Add `-c protocol.file.allow=always` to all `git` invocations under `pytest`.
- [x] Revert changes from #33429, which are no longer needed.
2022-12-28 00:44:11 -08:00
Massimiliano Culpo
3d961b9a1f
spack graph: rework to use Jinja templates and builders (#34637)
`spack graph` has been reworked to use:

- Jinja templates
- builder objects to construct the template context when DOT graphs are requested. 

This allowed to add a new colored output for DOT graphs that highlights both
the dependency types and the nodes that are needed at runtime for a given spec.
2022-12-27 15:25:53 +01:00
Todd Gamblin
d100ac8923 types: fix type annotations and remove novm annootations for llnl module
Apparently I forgot to do this in #34305.
2022-12-26 22:28:44 +01:00
Harmen Stoppels
e8fa8c5f01 timer: pick a single unit based on max duration. 2022-12-26 22:28:44 +01:00
Todd Gamblin
be6bb413df spack solve: use consistent units for time
`spack solve` is supposed to show you times you can compare. setup, ground, solve, etc.
all in a list. You're also supposed to be able to compare easily across runs. With
`pretty_seconds()` (introduced in #33900), it's easy to miss the units, e.g., spot the
bottleneck here:

```console
> spack solve --timers tcl
    setup        22.125ms
    load         16.083ms
    ground        8.298ms
    solve       848.055us
    total        58.615ms
```

It's easier to see what matters if these are all in the same units, e.g.:

```
> spack solve --timers tcl
    setup         0.0147s
    load          0.0130s
    ground        0.0078s
    solve         0.0008s
    total         0.0463s
```

And the units won't fluctuate from run to run as you make changes.

-[x] make `spack solve` timings consistent like before
2022-12-26 22:28:44 +01:00
Adam J. Stewart
7975e0afbc
QMakeBuilder: fix bug introduced during multi-bs refactor (#34683) 2022-12-23 13:57:44 -06:00
Harmen Stoppels
161fbfadf4
Fix combine_phase_logs text encoding issues (#34657)
Avoid text decoding and encoding when combining log files, instead
combine in binary mode.

Also do a buffered copy which is sometimes faster for large log files.
2022-12-22 15:32:48 +01:00
Alec Scott
3279ee7068
Add --fresh to docs to actually upgrade spack environments (#34433) 2022-12-22 11:19:24 +00:00
Todd Gamblin
8f3f838763
docs: show module documentation before submodules (#34258)
Currently, the Spack docs show documentation for submodules *before* documentation for
submodules on package doc pages. This means that if you put docs in `__init__.py` in
some package, the docs in there will be shown *after* the docs for all submodules of the
package instead of at the top as an intro to the package. See, e.g.,
[the lockfile docs](https://spack.readthedocs.io/en/latest/spack.environment.html#module-spack.environment),
which should be at the
[top of that page](https://spack.readthedocs.io/en/latest/spack.environment.html).

- [x] add the `--module-first` option to sphinx so that it generates module docs at top of page.
2022-12-22 11:50:48 +01:00
Todd Gamblin
09864d00c5
docs: remove monitors and analyzers (#34358)
These experimental features were removed in #31130, but the docs were not.

- [x] remove the `spack monitor` and `spack analyze` docs
2022-12-22 11:47:13 +01:00
Harmen Stoppels
e9ea9e2316
index.json.hash, no fatal error if key cannot be fetched (#34643) 2022-12-22 09:48:05 +01:00
Harmen Stoppels
492a603d5e
json: remove python 2 only code (#34615) 2022-12-21 14:18:12 -07:00
Cory Bloor
e60e74694f
rocm: make amdgpu_target sticky (#34591)
The sticky property will prevent clingo from changing the amdgpu_target
to work around conflicts. This is the same behaviour as was adopted for
cuda_arch in 055c9d125d.
2022-12-21 20:21:20 +01:00
Harmen Stoppels
4a22c1c699
urlopen: handle timeout in opener (#34639) 2022-12-21 19:40:26 +01:00
Harmen Stoppels
4473d5d811
etags for index.json invalidation, test coverage (#34641)
Implement an alternative strategy to do index.json invalidation.

The current approach of pairs of index.json / index.json.hash is
problematic because it leads to races.

The standard solution for cache invalidation is etags, which are
supported by both http and s3 protocols, which allows one to do
conditional fetches.

This PR implements that for the http/https schemes. It should also work
for s3 schemes, but that requires other prs to be merged.

Also it improves unit tests for index.json fetches.
2022-12-21 18:41:59 +01:00
Massimiliano Culpo
b2c806f6fc
archspec: add support for zen4 (#34609)
Also add:
- Upper bound for Xeon Phi compiler support
- Better detection for a64fx
2022-12-20 11:22:50 +01:00
Harmen Stoppels
1020b65297
fix != -> == typo (#34568) 2022-12-17 20:15:15 +01:00
John W. Parent
642c5b876b
Compiler detection: avoid false recognition of MSVC (#34574)
Interim fix for #34559

Spack's MSVC compiler definition uses ifx as the Fortran compiler.
Prior to #33385, the Spack MSVC compiler definition required the
executable to be called "ifx.exe"; #33385 replaced this with just
"ifx", which inadvertently led to ifx falsely indicating the
presence of MSVC on non-Windows systems (which leads to future
errors when attempting to query/use those compiler objects).

This commit applies a short-term fix by updating MSVC Fortran
version detection to always indicate a failure on non-Windows.
2022-12-16 19:22:04 +00:00
Massimiliano Culpo
22922bf74c
Propagate exceptions from Spack python console (#34547)
fixes #34489

Customize sys.excepthook to raise SystemExit when
any unhandled exception reaches the hook.
2022-12-15 18:08:53 +01:00
Sean Koyama
8a02463d7d
IntelOneApiPackage: add envmods variant to toggle environment modifications by oneapi packages (#34253)
Co-authored-by: Sean Koyama <skoyama@anl.gov>
Co-authored-by: Robert Cohn <robert.s.cohn@intel.com>
2022-12-15 17:52:09 +01:00
Harmen Stoppels
c6465bd9bd
Add a proper deprecation warning for update-index -d (#34520) 2022-12-15 17:45:32 +01:00
Harmen Stoppels
9025caed6e
Remove warning in download_tarball (#34549) 2022-12-15 14:03:30 +00:00
Massimiliano Culpo
7056a4bffd
Forward lookup of the "run_tests" attribute (#34531)
fixes #34518

Fix an issue due to the MRO chain of the package wrapper
during build. Before this PR we were always returning
False when the builder object was created before the
run_tests method was monkey patched.
2022-12-15 09:35:33 +01:00
Harmen Stoppels
ea029442e6
Revert "Revert "Use urllib handler for s3:// and gs://, improve url_exists through HEAD requests (#34324)"" (#34498)
This reverts commit 8035eeb36d.

And also removes logic around an additional HEAD request to prevent
a more expensive GET request on wrong content-type. Since large files
are typically an attachment and only downloaded when reading the
stream, it's not an optimization that helps much, and in fact the logic
was broken since the GET request was done unconditionally.
2022-12-14 23:47:11 +01:00
Harmen Stoppels
9032179b34
Use update-index --mirror-url <url> instead of -d <url> (#34519) 2022-12-14 10:03:18 +01:00
Harmen Stoppels
e055dc0e64
Use file paths/urls correctly (#34452)
The main issue that's fixed is that Spack passes paths (as strings) to
functions that require urls. That wasn't an issue on unix, since there
you can simply concatenate `file://` and `path` and all is good, but on
Windows that gives invalid file urls. Also on Unix, Spack would not deal with uri encoding like x%20y for file paths. 

It also removes Spack's custom url.parse function, which had its own incorrect interpretation of file urls, taking file://x/y to mean the relative path x/y instead of hostname=x and path=/y. Also it automatically interpolated variables, which is surprising for a function that parses URLs.

Instead of all sorts of ad-hoc `if windows: fix_broken_file_url` this PR
adds two helper functions around Python's own path2url and reverse.

Also fixes a bug where some `spack buildcache` commands
used `-d` as a flag to mean `--mirror-url` requiring a URL, and others
`--directory`, requiring a path. It is now the latter consistently.
2022-12-13 23:44:13 +01:00
Harmen Stoppels
333da47dc7
Don't fetch to order mirrors (#34359)
When installing binary tarballs, Spack has to download from its
binary mirrors.

Sometimes Spack has cache available for these mirrors.

That cache helps to order mirrors to increase the likelihood of
getting a direct hit.

However, currently, when Spack can't find a spec in any local cache
of mirrors, it's very dumb:

- A while ago it used to query each mirror to see if it had a spec,
  and use that information to order the mirror again, only to go
  about and do exactly a part of what it just did: fetch the spec
  from that mirror confused
- Recently, it was changed to download a full index.json, which
  can be multiple dozens of MBs of data and may take a minute to
  process thanks to the blazing fast performance you get with
  Python.

In a typical use case of concretizing with reuse, the full index.json
is already available, and it likely that the local cache gives a perfect
mirror ordering on install. (There's typically no need to update any
caches).

However, in the use case of Gitlab CI, the build jobs don't have cache,
and it would be smart to just do direct fetches instead of all the
redundant work of (1) and/or (2).

Also, direct fetches from mirrors will soon be fast enough to
prefer these direct fetches over the excruciating slowness of
index.json files.
2022-12-13 17:07:11 +01:00
Aidan Heerdegen
b95a75779b
Fix markdown links in rst files (#34488) 2022-12-13 14:11:38 +00:00
Harmen Stoppels
0ff6a1bd1c
spack/package.py: improve editor support for some +/- static props (#34319) 2022-12-13 13:55:32 +01:00
Massimiliano Culpo
f9cfc2f57e
scons: fix signature for install_args (#34481) 2022-12-13 12:21:44 +01:00
Todd Gamblin
62da76cb5d
directives: depends_on should not admit anonymous specs (#34368)
Writing a long dependency like:

```python
     depends_on(
         "llvm"
         "targets=amdgpu,bpf,nvptx,webassembly"
         "version_suffix=jl +link_llvm_dylib ~internal_unwind"
     )
```

when it should be formatted like this:

```python
     depends_on(
         "llvm"
         " targets=amdgpu,bpf,nvptx,webassembly"
         " version_suffix=jl +link_llvm_dylib ~internal_unwind"
     )
```

can cause really subtle errors. Specifically, you'll get something like this in
the package sanity tests:

```
    AttributeError: 'NoneType' object has no attribute 'rpartition'
```

because Spack happily constructs a class that has a dependency with name `None`.

We can catch this earlier by banning anonymous dependency specs directly in
`depends_on()`.  This causes the package itself to fail to parse, and emits
a much better error message:

```
==> Error: Invalid dependency specification in package 'julia':
    llvmtargets=amdgpu,bpf,nvptx,webassemblyversion_suffix=jl +link_llvm_dylib ~internal_unwind
```
2022-12-12 11:24:28 +01:00
Robert Cohn
39f13853ba
intel-oneapi-* conflicts for non linux, x86 (#34441) 2022-12-12 09:23:14 +01:00
Todd Gamblin
aa3b6e598f pkg grep: use capfd instead of executable for tests 2022-12-10 16:43:44 -08:00
Todd Gamblin
8035eeb36d Revert "Use urllib handler for s3:// and gs://, improve url_exists through HEAD requests (#34324)"
This reverts commit db8f115013.
2022-12-10 16:43:44 -08:00
Harmen Stoppels
db8f115013
Use urllib handler for s3:// and gs://, improve url_exists through HEAD requests (#34324)
* `url_exists` improvements (take 2)

Make `url_exists` do HEAD request for http/https/s3 protocols

Rework the opener: construct it once and only once, dynamically dispatch
to the right one based on config.
2022-12-10 00:20:29 +01:00
Todd Gamblin
d991ec90e3
new command: spack pkg grep to search package files (#34388)
It's very common for us to tell users to grep through the existing Spack packages to
find examples of what they want, and it's also very common for package developers to do
it. Now, searching packages is even easier.

`spack pkg grep` runs grep on all `package.py` files in repos known to Spack. It has no
special options other than the search string; all options passed to it are forwarded
along to `grep`.

```console
> spack pkg grep --help
usage: spack pkg grep [--help] ...

positional arguments:
  grep_args  arguments for grep

options:
  --help     show this help message and exit
```

```console
> spack pkg grep CMakePackage | head -3
/Users/gamblin2/src/spack/var/spack/repos/builtin/packages/3dtk/package.py:class _3dtk(CMakePackage):
/Users/gamblin2/src/spack/var/spack/repos/builtin/packages/abseil-cpp/package.py:class AbseilCpp(CMakePackage):
/Users/gamblin2/src/spack/var/spack/repos/builtin/packages/accfft/package.py:class Accfft(CMakePackage, CudaPackage):
```

```console
> spack pkg grep -Eho '(\S*)\(PythonPackage\)' | head -3
AwsParallelcluster(PythonPackage)
Awscli(PythonPackage)
Bueno(PythonPackage)
```

## Return Value

This retains the return value semantics of `grep`:
* 0  for found,
* 1  for not found
* >1 for error

## Choosing a `grep`

You can set the ``SPACK_GREP`` environment variable to choose the ``grep``
executable this command should use.
2022-12-09 10:07:54 -08:00
John W. Parent
0e69710f41
Windows: reenable unit tests (#33385)
Unit tests on Windows are supposed to pass for any PR to pass CI.
However, the return code for the unit test command was not being
checked, which meant this check was always passing (effectively
disabled). This PR

* Properly checks the result of the unit tests and fails if the
  unit tests fail
* Fixes (or disables on Windows) a number of tests which have
  "drifted" out of support on Windows since this check was
  effectively disabled
2022-12-09 13:27:46 +00:00
Harmen Stoppels
ec62150ed7
binary distribution: warn about issues (#34152) 2022-12-09 13:25:32 +01:00
Harmen Stoppels
7e054cb7fc
s3: cache client instance (#34372) 2022-12-09 08:50:32 +01:00
Peter Scheibel
c6e35da2c7
Cray manifest: automatically convert 'cray' platform to 'linux' (#34177)
* Automatically convert 'cray' platform to 'linux'
2022-12-08 11:28:06 -08:00
John W. Parent
aed77efb9a
Windows: Prevent SameFileError when rpathing (#34332) 2022-12-07 16:58:44 -08:00
Massimiliano Culpo
ab6499ce1e
parser: refactor with coarser token granularity (#34151)
## Motivation

Our parser grew to be quite complex, with a 2-state lexer and logic in the parser
that has up to 5 levels of nested conditionals. In the future, to turn compilers into
proper dependencies, we'll have to increase the complexity further as we foresee
the need to add:
1. Edge attributes
2. Spec nesting

to the spec syntax (see https://github.com/spack/seps/pull/5 for an initial discussion of
those changes).  The main attempt here is thus to _simplify the existing code_ before
we start extending it later. We try to do that by adopting a different token granularity,
and by using more complex regexes for tokenization. This allow us to a have a "flatter"
encoding for the parser. i.e., it has fewer nested conditionals and a near-trivial lexer.

There are places, namely in `VERSION`, where we have to use negative lookahead judiciously
to avoid ambiguity.  Specifically, this parse is ambiguous without `(?!\s*=)` in `VERSION_RANGE`
and an extra final `\b` in `VERSION`:

```
@ 1.2.3     :        develop  # This is a version range 1.2.3:develop
@ 1.2.3     :        develop=foo  # This is a version range 1.2.3: followed by a key-value pair
```

## Differences with the previous parser

~There are currently 2 known differences with the previous parser, which have been added on purpose:~

- ~No spaces allowed after a sigil (e.g. `foo @ 1.2.3` is invalid while `foo @1.2.3` is valid)~
- ~`/<hash> @1.2.3` can be parsed as a concrete spec followed by an anonymous spec (before was invalid)~

~We can recover the previous behavior on both ones but, especially for the second one, it seems the current behavior in the PR is more consistent.~

The parser is currently 100% backward compatible.

## Error handling

Being based on more complex regexes, we can possibly improve error
handling by adding regexes for common issues and hint users on that.
I'll leave that for a following PR, but there's a stub for this approach in the PR.

## Performance

To be sure we don't add any performance penalty with this new encoding, I measured:
```console
$ spack python -m timeit -s "import spack.spec" -c "spack.spec.Spec(<spec>)"
```
for different specs on my machine:

* **Spack:** 0.20.0.dev0 (c9db4e50ba045f5697816187accaf2451cb1aae7)
* **Python:** 3.8.10
* **Platform:** linux-ubuntu20.04-icelake
* **Concretizer:** clingo

results are:

| Spec          | develop       | this PR |
| ------------- | ------------- | ------- |
| `trilinos`  |  28.9 usec | 13.1 usec |
| `trilinos @1.2.10:1.4.20,2.0.1`  | 131 usec  | 120 usec |
| `trilinos %gcc`  | 44.9 usec  | 20.9 usec |
| `trilinos +foo`  | 44.1 usec  | 21.3 usec |
| `trilinos foo=bar`  | 59.5 usec  | 25.6 usec |
| `trilinos foo=bar ^ mpich foo=baz`  | 120 usec  | 82.1 usec |

so this new parser seems to be consistently faster than the previous one.

## Modifications

In this PR we just substituted the Spec parser, which means:
- [x] Deleted in `spec.py` the `SpecParser` and `SpecLexer` classes. deleted `spack/parse.py`
- [x] Added a new parser in `spack/parser.py`
- [x] Hooked the new parser in all the places the previous one was used
- [x] Adapted unit tests in `test/spec_syntax.py`


## Possible future improvements

Random thoughts while working on the PR:
- Currently we transform hashes and files into specs during parsing. I think
we might want to introduce an additional step and parse special objects like
a `FileSpec` etc. in-between parsing and concretization.
2022-12-07 14:56:53 -08:00
Greg Becker
194f9a9ca9
compiler flags: fix mixed flags from cli and yaml (#34218) 2022-12-06 16:32:08 -08:00
Harmen Stoppels
dfab5b5ceb
Stop checking for {s3://path}/index.html (#34325) 2022-12-06 09:19:04 -07:00
Harmen Stoppels
e3bf7358d7
Avoid stat call in llnl.util.symlink on non-windows (#34321) 2022-12-06 15:17:15 +00:00
Harmen Stoppels
b58ec9e2b9
Remove legacy yaml from buildcache fetch (#34347) 2022-12-06 16:12:20 +01:00
Massimiliano Culpo
4c05fe569c
Bootstrap most of Spack dependencies using environments (#34029)
This commit reworks the bootstrapping procedure to use Spack environments 
as much as possible.

The `spack.bootstrap` module has also been reorganized into a Python package. 
A distinction is made among "core" Spack dependencies (clingo, GnuPG, patchelf)
and other dependencies. For a number of reasons, explained in the `spack.bootstrap.core`
module docstring, "core" dependencies are bootstrapped with the current ad-hoc
method. 

All the other dependencies are instead bootstrapped using a Spack environment
that lives in a directory specific to the interpreter and the architecture being used.
2022-12-06 11:54:02 +01:00
Todd Gamblin
54008a2342
vermin: remove all novm comments from code (#34308)
All the vermin annotations we were using were for optional features introduced in early
Python 3 versions. We no longer need any of them, as we only support Python 3.6+. If we
start optionally using features from newer Pythons than 3.6, we will need more vermin
annotations.

Co-authored-by: Harmen Stoppels <harmenstoppels@gmail.com>

Co-authored-by: Harmen Stoppels <harmenstoppels@gmail.com>
2022-12-05 08:59:27 -07:00
Todd Gamblin
94dc86e163
web: remove checks for SSL verification support (#34307)
We no longer support Python <3.6, so we don't need to check whether Python supports SSL
verification in `spack.util.web`.

- [x] Remove a bunch of logic we needed to appease Python 2
2022-12-05 08:46:27 +01:00
Todd Gamblin
82b7fe649f
typing: move from comment annotations to Python 3.6 annotations (#34305)
We've stopped supporting Python 2, and contributors are noticing that our CI no longer
allows Python 2.7 comment type hints. They end up having to adapt them, but this adds
extra unrelated work to PRs.

- [x] Move to 3.6 type hints across the entire code base
2022-12-04 21:41:12 -08:00
Greg Becker
99044bedd7
patch command: add concretizer args (#34282)
* patch command: add concretizer args
* tab completion
2022-12-02 14:02:20 -08:00
Tamara Dahlgren
bcefe6a73e
Docs: Minor change 'several'->'over a dozen' (#34274) 2022-12-02 10:27:37 -08:00
Todd Gamblin
87562042df
concretizer: use only attr() for Spec attributes (#31202)
All Spec attributes are now represented as `attr(attribute_name, ... args ...)`, e.g.
`attr(node, "hdf5")` instead of `node("hdf5")`, as we *have* to maintain the `attr()`
form anyway, and it simplifies the encoding to just maintain one form of the Spec
information.

Background
----------

In #20644, we unified the way conditionals are done in the concretizer, but this
introduced a nasty aspect to the encoding: we have to maintain everything we want in
general conditions in two forms: `predicate(...)` and `attr("predicate", ...)`. For
example, here's the start of the table of spec attributes we had to maintain:

```prolog
node(Package)                      :- attr("node", Package).
virtual_node(Virtual)              :- attr("virtual_node", Virtual).
hash(Package, Hash)                :- attr("hash", Package, Hash).
version(Package, Version)          :- attr("version", Package, Version).
...
```

```prolog
attr("node", Package)              :- node(Package).
attr("virtual_node", Virtual)      :- virtual_node(Virtual).
attr("hash", Package, Hash)        :- hash(Package, Hash).
attr("version", Package, Version)  :- version(Package, Version).
...
```

This adds cognitive load to understanding how the concretizer works, as you have to
understand the equivalence between the two forms of spec attributes. It also makes the
general condition logic in #20644 hard to explain, and it's easy to forget to add a new
equivalence to this list when adding new spec attributes (at least two people have been
bitten by this).

Solution
--------

- [x] remove the equivalence list from `concretize.lp`
- [x] simplify `spec_clauses()`, `condition()`, and other functions in `asp.py` that need
      to deal with `Spec` attributes.
- [x] Convert all old-form spec attributes in `concretize.lp` to the `attr()` form
- [x] Simplify `display.lp`, where we also had to maintain a list of spec attributes. Now
      we only need to show `attr/2`, `attr/3`, and `attr/4`.
- [x] Simplify model extraction logic in `asp.py`.

Performance
-----------

This seems to result in a smaller grounded problem (as there are no longer duplicated
`attr("foo", ...)` / `foo(...)` predicates in the program), but it also adds a slight
performance overhead vs. develop. Ultimately, simplifying the encoding will be a win,
particularly for improving error messages.

Notes
-----

This will simplify future node refactors in `concretize.lp` (e.g., not identifying nodes
by package name, which we need for separate build dependencies).

I'm still not entirely used to reading `attr()` notation, but I thnk it's ultimately
clearer than what we did before. We need more uniform naming, and it's now clear what is
part of a solution. We should probably continue making the encoding of `concretize.lp`
simpler and more self-explanatory. It may make sense to rename `attr` to something like
`node_attr` and to simplify the names of node attributes. It also might make sense to do
something similar for other types of predicates in `concretize.lp`.
2022-12-02 18:56:18 +01:00
Tamara Dahlgren
18efd817b1
Bugfix: Fetch should not force use of curl to check url existence (#34225)
* Bugfix: Fetch should not force use of curl to check url existence

* Switch type hints from comments to actual hints
2022-12-02 04:50:23 -07:00
Greg Becker
b139cab687
conditional variant values: allow boolean (#33939) 2022-12-01 08:25:57 +01:00
Massimiliano Culpo
43d93f7773
Deduplicate code to propagate module changes across MRO (#34157) 2022-11-30 11:10:42 +01:00
Harmen Stoppels
f8dec3e87f
Single pass text replacement (#34180) 2022-11-30 10:21:51 +01:00
Todd Gamblin
c64c9649be
debug: move "nonexistent config path" message to much higher verbosity level (#34201)
We currently report that searched config paths don't exist at debug level 1, which
clutters the output quite a bit:

```console
> spack -d solve --fresh --show asp hdf5 > hdf5.lp
==> [2022-11-29-14:18:21.035133] Skipping nonexistent config path /Users/gamblin2/src/spack/etc/spack/darwin/concretizer.yaml
==> [2022-11-29-14:18:21.035151] Skipping nonexistent config path /Users/gamblin2/.spack/concretizer.yaml
==> [2022-11-29-14:18:21.035169] Skipping nonexistent config path /Users/gamblin2/.spack/darwin/concretizer.yaml
==> [2022-11-29-14:18:21.035238] Reading config from file /Users/gamblin2/src/spack/etc/spack/defaults/repos.yaml
==> [2022-11-29-14:18:21.035996] Skipping nonexistent config path /Users/gamblin2/src/spack/etc/spack/defaults/darwin/repos.yaml
==> [2022-11-29-14:18:21.036021] Skipping nonexistent config path /etc/spack/repos.yaml
==> [2022-11-29-14:18:21.036039] Skipping nonexistent config path /etc/spack/darwin/repos.yaml
==> [2022-11-29-14:18:21.036057] Skipping nonexistent config path /Users/gamblin2/src/spack/etc/spack/repos.yaml
==> [2022-11-29-14:18:21.036072] Skipping nonexistent config path /Users/gamblin2/src/spack/etc/spack/darwin/repos.yaml
==> [2022-11-29-14:18:21.036088] Skipping nonexistent config path /Users/gamblin2/.spack/repos.yaml
==> [2022-11-29-14:18:21.036105] Skipping nonexistent config path /Users/gamblin2/.spack/darwin/repos.yaml
==> [2022-11-29-14:18:21.071828] Reading config from file /Users/gamblin2/src/spack/etc/spack/defaults/config.yaml
==> [2022-11-29-14:18:21.081628] Skipping nonexistent config path /Users/gamblin2/src/spack/etc/spack/defaults/darwin/config.yaml
==> [2022-11-29-14:18:21.081669] Skipping nonexistent config path /etc/spack/config.yaml
==> [2022-11-29-14:18:21.081692] Skipping nonexistent config path /etc/spack/darwin/config.yaml
==> [2022-11-29-14:18:21.081712] Skipping nonexistent config path /Users/gamblin2/src/spack/etc/spack/config.yaml
==> [2022-11-29-14:18:21.081731] Skipping nonexistent config path /Users/gamblin2/src/spack/etc/spack/darwin/config.yaml
==> [2022-11-29-14:18:21.081748] Skipping nonexistent config path /Users/gamblin2/.spack/config.yaml
==> [2022-11-29-14:18:21.081764] Skipping nonexistent config path /Users/gamblin2/.spack/darwin/config.yaml
==> [2022-11-29-14:18:21.134909] Reading config from file /Users/gamblin2/src/spack/etc/spack/defaults/packages.yaml
==> [2022-11-29-14:18:21.148695] Reading config from file /Users/gamblin2/src/spack/etc/spack/defaults/darwin/packages.yaml
==> [2022-11-29-14:18:21.152555] Skipping nonexistent config path /etc/spack/packages.yaml
==> [2022-11-29-14:18:21.152582] Skipping nonexistent config path /etc/spack/darwin/packages.yaml
==> [2022-11-29-14:18:21.152601] Skipping nonexistent config path /Users/gamblin2/src/spack/etc/spack/packages.yaml
==> [2022-11-29-14:18:21.152620] Skipping nonexistent config path /Users/gamblin2/src/spack/etc/spack/darwin/packages.yaml
==> [2022-11-29-14:18:21.152637] Skipping nonexistent config path /Users/gamblin2/.spack/packages.yaml
==> [2022-11-29-14:18:21.152654] Skipping nonexistent config path /Users/gamblin2/.spack/darwin/packages.yaml
==> [2022-11-29-14:18:21.853915] Skipping nonexistent config path /Users/gamblin2/src/spack/etc/spack/defaults/compilers.yaml
==> [2022-11-29-14:18:21.853962] Skipping nonexistent config path /Users/gamblin2/src/spack/etc/spack/defaults/darwin/compilers.yaml
==> [2022-11-29-14:18:21.853987] Skipping nonexistent config path /etc/spack/compilers.yaml
==> [2022-11-29-14:18:21.854007] Skipping nonexistent config path /etc/spack/darwin/compilers.yaml
==> [2022-11-29-14:18:21.854025] Skipping nonexistent config path /Users/gamblin2/src/spack/etc/spack/compilers.yaml
==> [2022-11-29-14:18:21.854043] Skipping nonexistent config path /Users/gamblin2/src/spack/etc/spack/darwin/compilers.yaml
==> [2022-11-29-14:18:21.854060] Skipping nonexistent config path /Users/gamblin2/.spack/compilers.yaml
==> [2022-11-29-14:18:21.854093] Reading config from file /Users/gamblin2/.spack/darwin/compilers.yaml
```

It is very rare that I want to know this much information about config search, so I've
moved this to level 3. Now at level 1, we can see much more clearly what configs were
actually found:

```console
> spack -d solve --fresh --show asp hdf5 > hdf5.lp
==> [2022-11-29-14:19:04.035457] Imported solve from built-in commands
==> [2022-11-29-14:19:04.035818] Imported solve from built-in commands
==> [2022-11-29-14:19:04.037626] Reading config from file /Users/gamblin2/src/spack/etc/spack/defaults/concretizer.yaml
==> [2022-11-29-14:19:04.040033] Reading config from file /Users/gamblin2/src/spack/etc/spack/defaults/repos.yaml
==> [2022-11-29-14:19:04.080852] Reading config from file /Users/gamblin2/src/spack/etc/spack/defaults/config.yaml
==> [2022-11-29-14:19:04.133241] Reading config from file /Users/gamblin2/src/spack/etc/spack/defaults/packages.yaml
==> [2022-11-29-14:19:04.147175] Reading config from file /Users/gamblin2/src/spack/etc/spack/defaults/darwin/packages.yaml
==> [2022-11-29-14:19:05.157896] Reading config from file /Users/gamblin2/.spack/darwin/compilers.yaml
```

You can still get the old messages with `spack -ddd` (to activate debug level 3).
2022-11-29 16:17:13 -08:00
Greg Becker
451e3ff50b
warn about removal of deprecated format strings (#34101)
* warn about removal of deprecated format strings

Co-authored-by: becker33 <becker33@users.noreply.github.com>
2022-11-28 10:03:49 -08:00
Massimiliano Culpo
fdfda72371
Use a module-like object to propagate changes in the MRO, when setting build env (#34059)
This fixes an issue introduced in #32340, which changed the semantics of the "module"
object passed to the "setup_dependent_package" callback.
2022-11-28 14:18:26 +01:00
Harmen Stoppels
efa1dba9e4
Revert "Revert "gitlab: Add shared PR mirror to places pipelines look for binaries. (#33746)" (#34087)" (#34153)
This reverts commit 63e4406514.
2022-11-28 06:06:03 -07:00