Commit graph

6351 commits

Author SHA1 Message Date
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
Adam J. Stewart
a1b4e1bccd
Add type hints to Prefix class (#34135) 2022-11-28 13:49:57 +01:00
Satish Balay
12c23f2724
Revert "url_exists related improvements (#34095)" (#34144)
This reverts commit d06fd26c9a.

The problem is that Bitbucket's API forwards download requests to an S3 bucket using a temporary URL. This URL includes a signature for the request, which embeds the HTTP verb. That means only GET requests are allowed, and HEAD requests would fail verification, leading to 403 erros. The same is observed when using `curl -LI ...`
2022-11-26 17:56:36 +00:00
Harmen Stoppels
2167cbf72c
Track locks by (dev, ino); close file handlers between tests (#34122) 2022-11-25 10:57:33 +01:00
Valentin Volkl
7847d4332e
docs: update info on XCode requirements (#34097) 2022-11-24 00:20:09 +01:00
Tom Scogland
0182603609
Control Werror by converting to Wno-error (#30882)
Using `-Werror` is good practice for development and testing, but causes us a great
deal of heartburn supporting multiple compiler versions, especially as newer compiler
versions add warnings for released packages.  This PR adds support for suppressing
`-Werror` through spack's compiler wrappers.  There are currently three modes for
the `flags:keep_werror` setting:

* `none`: (default) cancel all `-Werror`, `-Werror=*` and `-Werror-*` flags by
  converting them to `-Wno-error[=]*` flags
* `specific`: preserve explicitly selected warnings as errors, such as
  `-Werror=format-truncation`, but reverse the blanket `-Werror`
* `all`: keeps all `-Werror` flags

These can be set globally in config.yaml, through the config command-line flags, or
overridden by a particular package (some packages use Werror as a proxy for determining
support for other compiler features).  We chose to use this approach because:

1. removing `-Werror` flags entirely broke *many* build systems, especially autoconf
   based ones, because of things like checking `-Werror=feature` and making the
   assumption that if that did not error other flags related to that feature would also work
2. Attempting to preserve `-Werror` in some phases but not others caused similar issues
3. The per-package setting came about because some packages, even with all these
   protections, still use `-Werror` unsafely.  Currently there are roughly 3 such packages
   known.
2022-11-23 12:29:17 -08:00
Harmen Stoppels
d06fd26c9a
url_exists related improvements (#34095)
For reasons beyond me Python thinks it's a great idea to upgrade HEAD
requests to GET requests when following redirects. So, this PR adds a
better `HTTPRedirectHandler`, and also moves some ad-hoc logic around
for dealing with disabling SSL certs verification.

Also, I'm stumped by the fact that Spack's `url_exists` does not use
HEAD requests at all, so in certain cases Spack awkwardly downloads
something first to see if it can download it, and then downloads it
again because it knows it can download it. So, this PR ensures that both
urllib and botocore use HEAD requests.

Finally, it also removes some things that were there to support currently
unsupported Python versions.

Notice that the HTTP spec [section 10.3.2](https://datatracker.ietf.org/doc/html/rfc2616.html#section-10.3.2) just talks about how to deal
with POST request on redirect (whether to follow or not):

>   If the 301 status code is received in response to a request other
>   than GET or HEAD, the user agent MUST NOT automatically redirect the
>   request unless it can be confirmed by the user, since this might
>   change the conditions under which the request was issued.

>   Note: When automatically redirecting a POST request after
>   receiving a 301 status code, some existing HTTP/1.0 user agents
>   will erroneously change it into a GET request.

Python has a comment about this, they choose to go with the "erroneous change".
But they then mess up the HEAD request while following the redirect, probably
because they were too busy discussing how to deal with POST.

See https://github.com/python/cpython/pull/99731
2022-11-23 19:26:24 +00:00
Harmen Stoppels
63e4406514
Revert "gitlab: Add shared PR mirror to places pipelines look for binaries. (#33746)" (#34087)
This reverts commit 5c4137baf1.
2022-11-23 10:41:52 -08:00
Cory Bloor
1006c77374
rocm: add minimum versions for amdgpu_targets (#34030) 2022-11-23 14:23:38 +01:00
Adam J. Stewart
5b3b0130f2
Build System docs: consistent headers (#34047) 2022-11-23 13:35:55 +01:00
Michael Kuhn
0fd3c9f451
cmd/checksum: allow adding new versions to package (#24532)
This adds super-lazy maintainer mode to `spack checksum`: Instead of
only printing the new checksums to the terminal, `-a` and
`--add-to-package` will add the new checksums to the `package.py` file
and open it in the editor afterwards for final checks.
2022-11-22 16:30:49 -08:00
Harmen Stoppels
4bf964e6b3
spack uninstall: use topo order (#34053) 2022-11-22 07:22:07 -07:00
Massimiliano Culpo
bd198312c9
Revert "Warn about removal of deprecated format strings (#33829)" (#34056)
This reverts commit 7f9af8d4a0.
2022-11-22 12:35:36 +01:00
Greg Becker
7f9af8d4a0
Warn about removal of deprecated format strings (#33829)
Co-authored-by: becker33 <becker33@users.noreply.github.com>
2022-11-22 10:56:57 +01:00
John W. Parent
793a7bc6a9
Windows: add registry query and SDK/WDK packages (#33021)
* Add a WindowsRegistryView class, which can query for existing
  package installations on Windows. This is particularly important
  because some Windows packages (including those added here)
  do not allow two simultaneous installs, and this can be
  queried in order to provide a clear error message.
* Consolidate external path detection logic for Windows into
  WindowsKitExternalPaths and WindowsCompilerExternalPaths objects.
* Add external-only packages win-sdk and wgl
* Add win-wdk (including external detection) which depends on
  win-sdk
* Replace prior msmpi implementation with a source-based install
  (depends on win-wdk). This install can control the install
  destination (unlike the binary installation).
* Update MSVC compiler to choose vcvars based on win-sdk dependency
* Provide "msbuild" module-level variable to packages during build
* When creating symlinks on Windows, need to explicitly specify when
  a symlink target is a directory
* executables_in_path no-longer defaults to using PATH (this is
  now expected to be taken care of by the caller)
2022-11-22 00:27:42 -08:00
Harmen Stoppels
44c22a54c9
Spec traversal: add option for topological ordering (#33817)
Spec traversals can now specify a topological ordering. A topologically-
ordered traversal with input specs X1, X2... will

* include all of X1, X2... and their children
* be ordered such that a given node is guaranteed to appear before any
  of its children in the traversal

Other notes:

* Input specs can be children of other input specs (this is useful if
  a user specifies a set of specs to uninstall: some of those specs
  might be children of others)
* `direction="parents"` will produce a reversed topological order
  (children always come before parents).
* `cover="edges"` will generate a list of edges L such that (a) input
  edges will always appear before output edges and (b) if you create
  a list with the destination of each edge in L the result is
  topologically ordered
2022-11-21 18:33:35 -08:00
Massimiliano Culpo
0e4ee3d352
Speed-up a few unit-tests (#34044)
* test_suite.py: speed up slow test by using mock packages

* Don't resolve the sha during unit-tests

* Skip long-running test that fails, instead of executing it
2022-11-21 23:50:55 +01:00
Scott Wittenburg
6411cbd803
ci: restore ability to reproduce gitlab job failures (#33953) 2022-11-21 10:39:03 -06:00
Harmen Stoppels
8ea366b33f
uninstall: fix accidental cubic complexity (#34005)
* uninstall: fix accidental cubic complexity

Currently spack uninstall runs in worst case cubic time complexity
thanks to traversal during traversal during traversal while collecting
the specs to be uninstalled.

Also brings down the number of error messages printed to something
linear in the amount of matching specs instead of quadratic.
2022-11-21 16:44:48 +01:00
Massimiliano Culpo
45b4cedb7e
spack find: remove deprecated "--bootstrap" option (#34015) 2022-11-19 16:09:34 +01:00
Chris Green
409cf185ce
package_base.py: Fix #34006: test msg needs to be a string (#34007) 2022-11-19 13:02:51 +01:00
Chris Green
e715901cb2
PackageBase should not define builder legacy attributes (#33942)
* Add a regression test for 33928

* PackageBase should not set `(build|install)_time_test_callbacks`

* Fix audits by preserving the current semantic

Co-authored-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
2022-11-18 22:22:51 +01:00
Massimiliano Culpo
839a14c0ba
Improve error message for requirements (#33988)
refers #33985
2022-11-18 15:49:46 +01:00
Jared Popelar
381bedf369
Hdf5 package: build on Windows (#31141)
* Enable hdf5 build (including +mpi) on Windows
* This includes updates to hdf5 dependencies openssl (minor edit) and
  bzip2 (more-extensive edits)
* Add binary-based installation of msmpi (this is currently the only
  supported MPI implementation in Spack for Windows). Note that this
  does not install to the Spack-specified prefix. This implementation
  will be replaced with a source-based implementation

Co-authored-by: John Parent <john.parent@kitware.com>
2022-11-17 10:40:53 -08:00
Chris Green
22aada0e20
Waf build system: fix typo in legacy_attributes (#33958)
Fix erroneous duplication of `build_time_test_callbacks` in
`legacy_attributes`: one of the duplicates should be
`install_time_test_callbacks`
2022-11-17 16:54:46 +01:00
Harmen Stoppels
cc2d0eade6
docs: fix typo in multiple build systems (#33965) 2022-11-17 15:20:10 +01:00
Harmen Stoppels
f00e411287
relocate.py: small refactor for file_is_relocatable (#33967) 2022-11-17 13:21:27 +01:00
Massimiliano Culpo
da0a6280ac
Remove deprecated subcommands from "spack bootstrap" (#33964)
These commands are slated for removal in v0.20
2022-11-17 12:42:57 +01:00
Michael Kuhn
93eecae0c3
Add sgid notice when running on AFS (#30247) 2022-11-17 09:17:41 +01:00
Brian Vanderwende
c721aab006
lib/spack/spack/store.py: Fix #28170 for padding relocation (#33122) 2022-11-17 03:56:00 +01:00
Greg Becker
1263b5c444
initial implementation of slingshot detection (#33793) 2022-11-16 13:01:37 -08:00
psakievich
90f0a8eacc
Upstreams: add canonicalize path (#33946) 2022-11-16 14:37:32 -06:00
John W. Parent
61a7420c94
Windows bootstrapping: remove unneeded call to add dll to PATH (#33622)
#32942 fixed bootstrapping on Windows by having the core Spack
code explicitly add the Clingo package bin/ directory as a
DLL path.

Since then, #33400 has been merged, which ensures that the Python
module installed by the Spack `clingo` package can find the DLLs
in bin/.

Note that this only works for Spack instances which have been
bootstrapped after #33400: for installations bootstrapped before
then, you will need to run `spack clean -b` (this would only
be needed for Spack instances running on Windows).
2022-11-16 12:04:57 -08:00
Stephen Sachs
39a1f1462b
SIP build system: fix "python not defined in builder" (#33906)
Co-authored-by: Stephen Sachs <stesachs@amazon.com>
2022-11-16 13:36:25 -06:00
Harmen Stoppels
0a952f8b7b
docs updates for spack env depfile (#33937) 2022-11-16 15:47:31 +01:00
Harmen Stoppels
d18cccf7c5
spack env depfile in Gitlab CI should use install-deps/pkg-version-hash target (#33936) 2022-11-16 14:02:56 +00:00
Kevin Broch
fbe6b4b486
Change code suggestions to output black formatter compliant code (#33931) 2022-11-16 12:08:20 +01:00
Adam J. Stewart
93430496e2
Getting Started: Python 2 is no longer supported (#33927) 2022-11-16 08:36:49 +01:00
Michael Kuhn
901b31a7aa
docs: fix typo (#33926) 2022-11-15 16:06:12 -08:00
Harmen Stoppels
a0182c069f
Show time per phase (#33874) 2022-11-15 21:10:07 +01:00
Harmen Stoppels
af74680405
depfile: improve tab completion (#33773)
This PR allows you to do:

```
spack env create -d .
spack -e . add python
spack -e . concretize
spack -e . env depfile -o Makefile

make in<tab>              # -> install
make install-<tab>        # -> install-deps/
make install-deps/py<tab> # -> install-deps/python-x.y.z-hash
make install/zl<tab>      # -> install/zlib-x.y.z-hash

make SP<tab>              # -> make SPACK
make SPACK_<tab>          # -> make SPACK_INSTALL_FLAGS=
```
2022-11-15 18:03:17 +01:00
Harmen Stoppels
d1715c5fdf
Fixup: start the timer before the phase (#33917) 2022-11-15 16:52:43 +01:00
Harmen Stoppels
b245f1ece1
Fix incorrect timer (#33900)
Revamp the timer so we always have a designated begin and end.

Fix a bug where the phase timer was stopped before the phase started,
resulting in incorrect timing reports in timers.json.
2022-11-15 16:33:47 +01:00
Brian Van Essen
fd4f905ce5
External find now searches all dynamic linker paths (#33800)
Add spack.ld_so_conf.host_dynamic_linker_search_paths

Retrieve the current host runtime search paths for shared libraries;
for GNU and musl Linux we try to retrieve the dynamic linker from the
current Python interpreter and then find the corresponding config file
(e.g. ld.so.conf or ld-musl-<arch>.path). Similar can be done for
BSD and others, but this is not implemented yet. The default paths
are always returned. We don't check if the listed directories exist.

Use this in spack external find for libraries.

Co-authored-by: Harmen Stoppels <harmenstoppels@gmail.com>
2022-11-15 14:48:15 +01:00
Harmen Stoppels
2948248d7a
Remove exit(0) (#33896)
Since they cause --backtrace to report backtraces even with exit code 0
2022-11-15 14:35:44 +01:00
Massimiliano Culpo
b3124bff7c
Stop using six in Spack (#33905)
Since we dropped support for Python 2.7, there's no need
so use `six` anymore. We still need to vendor it until
we update our vendored dependencies.
2022-11-15 10:07:54 +01:00
Scott Wittenburg
5c4137baf1
gitlab: Add shared PR mirror to places pipelines look for binaries. (#33746)
While binaries built for PRs that get merged must still be rebuilt
in develop pipelines, they can be used by other PRs that find they
would otherwise need to rebuild them.  Now that spackbot is
managing copying PR binaries from merged PRs into a shared location,
keeping it pruned to a reasonable size, and making sure the indices
are up to date, spack can use these mirrors as a potential source
of binaries.
2022-11-14 19:37:23 -07:00
psakievich
2460c4fc28
Add $date option to the list of config variables (#33875)
I'm finding I often want the date in my paths and it would be nice if spack had a config variable for this.

Co-authored-by: Tamara Dahlgren <35777542+tldahlgren@users.noreply.github.com>
2022-11-14 10:13:30 -08:00
Cory Bloor
6e39efbb9a
rocm: add all GFX9, GFX10 and GFX11 amdgpu_targets (#33871)
This change adds all documented AMDGPU processors from GFX9 through GFX11 and sorts the list.
2022-11-14 10:11:22 -08:00
Todd Gamblin
6ecb57e91f Bump version to v0.20.0.dev0 2022-11-14 08:22:29 -06:00
Harmen Stoppels
a75af62fe3
Get rid of context for exceptions outside PackageBase (#33887) 2022-11-14 14:11:22 +01:00
Massimiliano Culpo
e4e02dbeae
Fix a bug/typo in a config_values.py fixture (#33886) 2022-11-14 05:26:14 -07:00
Massimiliano Culpo
3efa4ee26f
Remove support for running with Python 2.7 (#33063)
* Remove CI jobs related to Python 2.7

* Remove Python 2.7 specific code from Spack core

* Remove externals for Python 2 only

* Remove llnl.util.compat
2022-11-14 13:11:28 +01:00
Harmen Stoppels
a4cec82841
Speed up traverse unit tests (#33840) 2022-11-14 09:34:14 +01:00
Todd Gamblin
3d811617e6
hotfix: ensure that schema is compatible with tutorial VM config
We added a hotfix to releases/v0.19 with a feature flag, but the flag
is incompatible with the config schema on `develop`.

- [x] Ensure schema is compatible on develop even though config option is unused.
2022-11-13 09:14:00 -06:00
Massimiliano Culpo
03224e52d2
Speed-up bootstrap and architecture unit tests (#33865)
* Speed-up bootstrap mirror unit test

The unit test doesn't need to concretize, since it checks
only metadata for the mirror.

* architecture.py: use "default_mock_concretization" for slow test
2022-11-13 13:09:22 +01:00
Greg Becker
4ebe57cd64
update tutorial command to newest release branch (#33867) 2022-11-12 13:29:38 -08:00
Greg Becker
343cd04a54
use spack.version_info as source of version truth for spack tutorial command (#33860)
* Use spack.spack_version_info as source of truth

Co-authored-by: Todd Gamblin <gamblin2@llnl.gov>
2022-11-12 11:42:59 -08:00
Massimiliano Culpo
022a2d2eaf
Speed-up unit tests by caching default mock concretization (#33755) 2022-11-11 21:32:40 +01:00
Greg Becker
2d2c591633
ensure view projections for extensions always point to extendee (#33848) 2022-11-11 10:59:23 -07:00
Harmen Stoppels
c14dc2f56a
docs: updates related to extensions (#33837) 2022-11-11 13:24:17 +01:00
Harmen Stoppels
0f54a63dfd
remove activate/deactivate support in favor of environments (#29317)
Environments and environment views have taken over the role of `spack activate/deactivate`, and we should deprecate these commands for several reasons:

- Global activation is a really poor idea:
   - Install prefixes should be immutable; since they can have multiple, unrelated dependents; see below
   - Added complexity elsewhere: verification of installations, tarballs for build caches, creation of environment views of packages with unrelated extensions "globally activated"... by removing the feature, it gets easier for people to contribute, and we'd end up with fewer bugs due to edge cases.
- Environment accomplish the same thing for non-global "activation" i.e. `spack view`, but better.

Also we write in the docs:

```
However, Spack global activations have two potential drawbacks:

#. Activated packages that involve compiled C extensions may still
   need their dependencies to be loaded manually.  For example,
   ``spack load openblas`` might be required to make ``py-numpy``
   work.

#. Global activations "break" a core feature of Spack, which is that
   multiple versions of a package can co-exist side-by-side.  For example,
   suppose you wish to run a Python package in two different
   environments but the same basic Python --- one with
   ``py-numpy@1.7`` and one with ``py-numpy@1.8``.  Spack extensions
   will not support this potential debugging use case.
```

Now that environments are established and views can take over the role of activation
non-destructively, we can remove global activation/deactivation.
2022-11-11 00:50:07 -08:00
Greg Becker
f11778bb02
remove deprecated top-level module config (#33828)
* remove deprecated top-level module config per deprecation in 0.18
2022-11-10 23:35:33 -08:00
Greg Becker
277234c044
remove deprecated concretization environment key (#33774) 2022-11-11 00:11:52 +00:00
Harmen Stoppels
0077a25639
Use bfs order in spack find --deps tree (#33782)
* Use bfs order in spack find --deps tree
* fix printing tests
2022-11-10 15:39:07 -08:00
Massimiliano Culpo
cfd0dc6d89
spack location: fix attribute lookup after multiple build systems (#33791)
fixes #33785
2022-11-10 01:53:59 -07:00
Chris White
bb1cd430c0
always use the cxx compiler as a host compiler (#33771) 2022-11-09 13:22:43 -08:00
Harmen Stoppels
d1d668a9d5
Revert "fix racy sbang (#33549)" (#33778)
This reverts commit 4d28a64661.
2022-11-09 09:31:27 +00:00
Greg Becker
284c3a3fd8
ensure external PythonPackages have python deps (#33777)
Currently, external `PythonPackage`s cause install failures because the logic in `PythonPackage` assumes that it can ask for `spec["python"]`.  Because we chop off externals' dependencies, an external Python extension may not have a `python` dependency.

This PR resolves the issue by guaranteeing that a `python` node is present in one of two ways:
1. If there is already a `python` node in the DAG, we wire the external up to it.
2. If there is no existing `python` node, we wire up a synthetic external `python` node, and we assume that it has the same prefix as the external.

The assumption in (2) isn't always valid, but it's better than leaving the user with a non-working `PythonPackage`.

The logic here is specific to `python`, but other types of extensions could take advantage of it.  Packages need only define `update_external_dependencies(self)`, and this method will be called on externals after concretization.  This likely needs to be fleshed out in the future so that any added nodes are included in concretization, but for now we only bolt on dependencies post-concretization.

Co-authored-by: Todd Gamblin <tgamblin@llnl.gov>
2022-11-09 08:25:30 +00:00
Massimiliano Culpo
ec89c47aee
Account for patchelf binaries when creating local bootstrap mirror (#33776)
This was overlooked when we added binary patchelf buildcaches
2022-11-08 23:05:03 -08:00
Harmen Stoppels
4d28a64661
fix racy sbang (#33549)
Spack currently creates a temporary sbang that is moved "atomically" in place,
but this temporary causes races when multiple processes start installing sbang.

Let's just stick to an idempotent approach. Notice that we only re-install sbang
if Spack updates it (since we do file compare), and sbang was only touched
18 times in the past 6 years, whereas we hit the sbang tempfile issue
frequently with parallel install on a fresh spack instance in CI.

Also fixes a bug where permissions weren't updated if config changed but
the latest version of the sbang file was already installed.
2022-11-08 11:05:05 -08:00
Greg Becker
97fe7ad32b
use pwd for usernames on unix (#19980) 2022-11-08 10:36:10 -08:00
Stephen Sachs
80f5939a94
Install from source if binary cache checksum validation fails (#31696)
* Fix https://github.com/spack/spack/issues/31640

Some packages in the binary cache fail checksum validation. Instead of having to
go back and manually install all failed packages with `--no-cache` option,
requeue those failed packages for installation from source

```shell
$ spack install py-pip
==> Installing py-pip-21.3.1-s2cx4gqrqkdqhashlinqyzkrvuwkl3x7
==> Fetching https://binaries.spack.io/releases/v0.18/build_cache/linux-amzn2-graviton2-gcc-7.3.1-py-pip-21.3.1-s2cx4gqrqkdqhashlinqyzkrvuwkl3x7.spec.json.sig
gpg: Signature made Wed 20 Jul 2022 12:13:43 PM UTC using RSA key ID 3DB0C723
gpg: Good signature from "Spack Project Official Binaries <maintainers@spack.io>"
==> Fetching https://binaries.spack.io/releases/v0.18/build_cache/linux-amzn2-graviton2/gcc-7.3.1/py-pip-21.3.1/linux-amzn2-graviton2-gcc-7.3.1-py-pip-21.3.1-s2cx4gqrqkdqhashlinqyzkrvuwkl3x7.spack
==> Extracting py-pip-21.3.1-s2cx4gqrqkdqhashlinqyzkrvuwkl3x7 from binary cache
==> Error: Failed to install py-pip due to NoChecksumException: Requeue for manual installation.
==> Installing py-pip-21.3.1-s2cx4gqrqkdqhashlinqyzkrvuwkl3x7
==> Using cached archive: /shared/spack/var/spack/cache/_source-cache/archive/de/deaf32dcd9ab821e359cd8330786bcd077604b5c5730c0b096eda46f95c24a2d
==> No patches needed for py-pip
==> py-pip: Executing phase: 'install'
==> py-pip: Successfully installed py-pip-21.3.1-s2cx4gqrqkdqhashlinqyzkrvuwkl3x7
  Fetch: 0.01s.  Build: 2.81s.  Total: 2.82s.
[+] /shared/spack/opt/spack/linux-amzn2-graviton2/gcc-7.3.1/py-pip-21.3.1-s2cx4gqrqkdqhashlinqyzkrvuwkl3x7
```

* Cleanup style

* better wording

Co-authored-by: Tamara Dahlgren <35777542+tldahlgren@users.noreply.github.com>

* Update lib/spack/spack/installer.py

Co-authored-by: Tamara Dahlgren <35777542+tldahlgren@users.noreply.github.com>

* changes quotes for style checks

* Update lib/spack/spack/installer.py

Co-authored-by: kwryankrattiger <80296582+kwryankrattiger@users.noreply.github.com>

* Addressing @kwryankrattiger comment to use local 'use_cache`

Co-authored-by: Stephen Sachs <stesachs@amazon.com>
Co-authored-by: Tamara Dahlgren <35777542+tldahlgren@users.noreply.github.com>
Co-authored-by: kwryankrattiger <80296582+kwryankrattiger@users.noreply.github.com>
2022-11-08 09:19:55 -08:00
Massimiliano Culpo
89976af732
scons: fix Scons builder after multi build-system refactoring (#33753) 2022-11-08 16:03:15 +01:00
Massimiliano Culpo
e4218595de
Rework unit test to avoid tripping into concretization slowdown (#33749) 2022-11-08 10:56:24 +01:00
Greg Becker
c9561c5a0e
intel oneapi classic bootstrapping (#31285)
The `intel` compiler at versions > 20 is provided by the `intel-oneapi-compilers-classic`
package (a thin wrapper around the `intel-oneapi-compilers` package), and the `oneapi`
compiler is provided by the `intel-oneapi-compilers` package. 

Prior to this work, neither of these compilers could be bootstrapped by Spack as part of
an install with `install_missing_compilers: True`.

Changes made to make these two packages bootstrappable:

1. The `intel-oneapi-compilers-classic` package includes a bin directory and symlinks
   to the compiler executables, not just logical pointers in Spack.
2. Spack can look for bootstrapped compilers in directories other than `$prefix/bin`,
   defined on a per-package basis
3. `intel-oneapi-compilers` specifies a non-default search directory for the
   compiler executables.
4. The `spack.compilers` module now can make more advanced associations between
   packages and compilers, not just simple name translations
5. Spack support for lmod hierarchies accounts for differences between package
   names and the associated compiler names for `intel-oneapi-compilers/oneapi`,
   `intel-oneapi-compilers-classic/intel@20:`, `llvm+clang/clang`, and
   `llvm-amdgpu/rocmcc`.

- [x] full end-to-end testing
- [x] add unit tests
2022-11-07 21:50:16 -08:00
Peter Scheibel
1a3415619e
"spack uninstall": don't modify env (#33711)
"spack install foo" no longer adds package "foo" to the environment
(i.e. to the list of root specs) by default: you must specify "--add".
Likewise "spack uninstall foo" no longer removes package "foo" from
the environment: you must specify --remove. Generally this means
that install/uninstall commands will no longer modify the users list
of root specs (which many users found problematic: they had to
deactivate an environment if they wanted to uninstall a spec without
changing their spack.yaml description).

In more detail: if you have environments e1 and e2, and specs [P, Q, R]
such that P depends on R, Q depends on R, [P, R] are in e1, and [Q, R]
are in e2:

* `spack uninstall --dependents --remove r` in e1: removes R from e1
  (but does not uninstall it) and uninstalls (and removes) P
* `spack uninstall -f --dependents r` in e1: will uninstall P, Q, and
   R (i.e. e2 will have dependent specs uninstalled as a side effect)
* `spack uninstall -f --dependents --remove r` in e1: this uninstalls
   P, Q, and R, and removes [P, R] from e1
* `spack uninstall -f --remove r` in e1: uninstalls R (so it is
  "missing" in both environments) and removes R from e1 (note that e1
  would still install R as a dependency of P, but it would no longer
  be listed as a root spec)
* `spack uninstall --dependents r` in e1: will fail because e2 needs R

Individual unit tests were created for each of these scenarios.
2022-11-08 03:24:51 +00:00
Jordan Galby
84a3d32aa3
Fix missing "*.spack*" files in views (#30980)
All files/dirs containing ".spack" anywhere their name were ignored when
generating a spack view.

For example, this happened with the 'r' package.
2022-11-08 02:58:19 +00:00
Harmen Stoppels
3693622edf
reorder packages.yaml: requirements first, then preferences (#33741)
* reorder packages.yaml: requirements first, then preferences
* expand preferences vs reuse vs requirements
2022-11-07 16:16:11 -08:00
Scott Wittenburg
b3b675157c
gitlab ci: Add "script_failure" as a reason for retrying service jobs (#33420)
Somehow a network error when cloning the repo for ci gets
categorized by gitlab as a script failure.  To make sure we retry
jobs that failed for that reason or a similar one, include 
"script_failure" as one of the reasons for retrying service jobs
(which include "no specs to rebuild" jobs, update buildcache
index jobs, and temp storage cleanup jobs.
2022-11-07 16:11:04 -07:00
Tom Scogland
6241cdb27b
encode development requirements in pyproject.toml (#32616)
Add a `project` block to the toml config along with development and CI
dependencies and a minimal `build-system` block, doing basically
nothing, so that spack can be bootstrapped to a full development
environment with:

```shell
$ hatch -e dev shell
```

or for a minimal environment without hatch:

```shell
$ python3 -m venv venv
$ source venv/bin/activate
$ python3 -m pip install --upgrade pip
$ python3 -m pip install -e '.[dev]'
```

This means we can re-use the requirements list throughout the workflow
yaml files and otherwise maintain this list in *one place* rather than
several disparate ones.  We may be stuck with a couple more temporarily
to continue supporting python2.7, but aside from that it's less places
to get out of sync and a couple new bootstrap options.

Co-authored-by: Adam J. Stewart <ajstewart426@gmail.com>
2022-11-07 15:00:22 -08:00
Scott Wittenburg
28a77c2821
binary_distribution: Speed up buildcache update-index (#32796)
This change uses the aws cli, if available, to retrieve spec files
from the mirror to a local temp directory, then parallelizes the
reading of those files from disk using multiprocessing.ThreadPool.

If the aws cli is not available, then a ThreadPool is used to fetch
and read the spec files from the mirror.

Using aws cli results in ~16 times speed up to recreate the binary
mirror index, while just parallelizing the fetching and reading
results in ~3 speed up.
2022-11-07 21:31:14 +01:00
Harmen Stoppels
cc84ab1e92
Remove known issues (#33738) 2022-11-07 19:41:16 +00:00
Greg Becker
ec05543054
Bugfix: Compiler bootstrapping for compilers that are independently present in env (#32228)
The compiler bootstrapping logic currently does not add a task when the compiler package is already in the install task queue. This causes failures when the compiler package is added without the additional metadata telling the task to update the compilers list.

Solution: requeue compilers for bootstrapping when needed, to update `task.compiler` metadata.
2022-11-07 09:38:51 -08:00
Greg Becker
a30b60f9a6
Apply dev specs for dependencies of roots (#30909)
Currently, develop specs that are not roots and are not explicitly listed dependencies 
of the roots are not applied.

- [x] ensure dev specs are applied.

Co-authored-by: Todd Gamblin <tgamblin@llnl.gov>
2022-11-07 09:37:03 -08:00
Harmen Stoppels
47df88404a
Simplify repeated _add_dependency calls for same package (#33732) 2022-11-07 16:33:18 +01:00
Axel Huebl
1eb35d0378
Doc: lsb-release (#32479)
Without the `lsb-release` tool installed, Spack cannot identify the
Ubuntu/Debian version.
2022-11-07 16:13:17 +01:00
Harmen Stoppels
2ab974f530
concretizer:unify:true as a default (#31787)
`spack env create` enables a view by default (in a weird hidden
directory, but well...). This is asking for trouble with the other
default of `concretizer:unify:false`, since having different flavors of
the same spec in an environment, leads to collision errors when
generating the view.

A change of defaults would improve user experience:

However, `unify:true` makes most sense, since any time the issue is
brought up in Slack, the user changes the concretization config, since
it wasn't the intention to have different flavors of the same spec, and
install times are decreased.

Further we improve the docs and drop the duplicate root spec limitation
2022-11-07 15:38:24 +01:00
Massimiliano Culpo
e045dabb3a
archspec: update version, translate renamed uarchs (#33556)
* Update archspec version

* Add a translation table from old names
2022-11-07 04:50:38 -08:00
Greg Becker
4b84cd8af5
bugfix for matrices with dependencies by hash (#22991)
Dependencies specified by hash are unique in Spack in that the abstract
specs are created with internal structure. In this case, the constraint
generation for spec matrices fails due to flattening the structure.

It turns out that the dep_difference method for Spec.constrain does not
need to operate on transitive deps to ensure correctness. Removing transitive
deps from this method resolves the bug.

- [x] Includes regression test
2022-11-06 16:49:35 -08:00
Greg Becker
fce7bf179f
solver setup: extract virtual dependencies from reusable specs (#32434)
* extract virtual dependencies from reusable specs
* bugfix to avoid establishing new node for virtual
2022-11-06 16:47:07 -08:00
Greg Becker
f3db624b86
package preferences: allow specs to be configured buildable when their virtuals are not (#18269)
* respect spec buildable that overrides virtual buildable
2022-11-06 16:45:38 -08:00
Greg Becker
22c2f3fe89
improve error message for dependency on nonexistant compiler (#32084) 2022-11-06 16:44:11 -08:00
Greg Becker
52cc798948
solver: do not punish explicitly requested compiler mismatches (#30074) 2022-11-06 16:40:00 -08:00
Michael Kuhn
258edf7dac
MesonPackage: disable automatic download and install of dependencies (#33717)
Without this, Meson will use its Wraps to automatically download and
install dependencies. We want to manage dependencies explicitly,
therefore disable this functionality.
2022-11-06 19:34:43 +00:00
Greg Becker
d4b45605c8
allow multiple compatible deps from CLI (#21262)
Currently, Spack can fail for a valid spec if the spec is constructed from overlapping, but not conflicting, concrete specs via the hash.

For example, if abcdef and ghijkl are the hashes of specs that both depend on zlib/mnopqr, then foo ^/abcdef ^/ghijkl will fail to construct a spec, with the error message "Cannot depend on zlib... twice".

This PR changes this behavior to check whether the specs are compatible before failing.

With this PR, foo ^/abcdef ^/ghijkl will concretize.

As a side-effect, so will foo ^zlib ^zlib and other specs that are redundant on their dependencies.
2022-11-06 11:30:37 -08:00
Greg Becker
27e1d28c0b
canonicalize_path: add arch information to substitutions (#29810)
Co-authored-by: becker33 <becker33@users.noreply.github.com>
2022-11-06 10:11:59 +01:00
Massimiliano Culpo
5558940ce6
Add support for Python 3.11 (#33505)
Argparse started raising ArgumentError exceptions
when the same parser is added twice. Therefore, we
perform the addition only if the parser is not there
already

Port match syntax to our unparser
2022-11-05 15:59:12 +01:00
Tom Scogland
3346c0918b
Fix relocation to avoid overwriting merged constant strings (#32253)
Compilers and linker optimize string constants for space by aliasing
them when one is a suffix of another. For gcc / binutils this happens
already at -O1, due to -fmerge-constants. This means that we have
to take care during relocation to always preserve a certain length
of the suffix of those prefixes that are C-strings. 

In this commit we pick length 7 as a safe suffix length, assuming the
suffix is typically the 7 characters from the hash (i.e. random), so
it's unlikely to alias with any string constant used in the sources.

In general we now pad shortened strings from the left with leading
dir seperators, but in the case of C-strings that are much shorter
and don't share a common suffix (due to projections), we do allow
shrinking the C-string, appending a null, and retaining the old part
of the prefix.

Also when rewiring, we ensure that the new hash preserves the last
7 bytes of the old hash.

Co-authored-by: Harmen Stoppels <harmenstoppels@gmail.com>
2022-11-05 11:09:35 +01:00
Peter Scheibel
71d480515b
packages.yaml: set url/git (#33275)
A user may want to set some attributes on a package without actually modifying the package (e.g. if they want to git pull updates to the package without conflicts). This PR adds a per-package configuration section called "set", which is a dictionary of attribute names to desired values. For example:

packages:
  openblas:
    package_attributes:
      submodules: true
      git: "https://github.com/myfork/openblas"

in this case, the package will always retrieve git submodules, and will use an alternate location for the git repo.

While git, url, and submodules are the attributes for which we envision the most usage, this allows any attribute to be overridden, and the acceptable values are any value parseable from yaml.
2022-11-05 08:44:50 +00:00
Massimiliano Culpo
c0ed5612ab
unparser: fix bug in unit test assertion (#33722) 2022-11-05 09:00:54 +01:00
iarspider
9becc82dfc
Fix formatting in packaging guide (#33714) 2022-11-05 02:00:16 +00:00
Greg Becker
912d544afe
demote warning for no source id to debug message (#33657)
* demote warning for no source id to debug message
2022-11-04 21:52:58 +00:00
Greg Becker
53fbaa5dcd
Cray support: use linux platform for newer craype versions (#29392)
Newer versions of the CrayPE for EX systems have standalone compiler executables for CCE and compiler wrappers for Cray MPICH. With those, we can treat the cray systems as part of the linux platform rather than having a separate cray platform.

This PR:
- [x] Changes cray platform detection to ignore EX systems with Craype version 21.10 or later
- [x] Changes the cce compiler to be detectable via paths
- [x] Changes the spack compiler wrapper to understand the executable names for the standalone cce compiler (`craycc`, `crayCC`, `crayftn`).
2022-11-04 14:52:11 -07:00
Greg Becker
a88c74dc17
delegate to cray modules for target args on cray (#17857) 2022-11-04 14:50:05 -07:00
Matthieu Boileau
76ec64859a
Fix typo in docs (#33662) 2022-11-04 20:19:34 +01:00
Massimiliano Culpo
a4f3fe2ac7
Deprecate old YAML format for buildcaches (#33707) 2022-11-04 12:06:42 -07:00
Tamara Dahlgren
d338ac0634
Updates to stand-alone test documentation (#33703) 2022-11-04 18:55:38 +00:00
Greg Becker
17eaf34902
fix requires test for aarch64 (#33656) 2022-11-04 18:12:55 +00:00
Harmen Stoppels
1d4919924d
Add in-place RPATH replacement (#27610)
Whenever the rpath string actually _grows_, it falls back to patchelf,
when it stays the same length or gets shorter, we update it in-place,
padded with null bytes.

This PR only deals with absolute -> absolute rpath replacement. We don't
use `_build_tarball(relative=True)` in our CI. If `relative` then it falls
back to the old replacement code.

With this PR, relocation time goes down significantly, likely because patchelf
does some odd things with mmap, causing lots of overhead. Example:

- `binutils`: 700MB installed, goes from `1.91s` to `0.57s`, or `3.4x` faster.
   Relocation time: 27% -> 10% of total install time
- `llvm`: 6.8GB installed, goes from `28.56s` to `5.38`, or `5.3x` faster.
   Relocation time: 44% -> 13% of total install time

The bottleneck is now decompression.

Note: I'm somewhat confused about the "relative rpath" code paths. Right
now this PR only deals with absolute -> absolute replacement. As far as
I understand, if you embrace relative rpaths when uploading to the
buildcache, the whole point is you _don't_ want to patch rpaths on
install? So it seems fine to not expand `$ORIGIN` again imho.
2022-11-04 02:30:53 -07:00
Jordan Galby
b1f896e6c7
Fix non-parallel make under depfile jobserver (#32862)
When a package asks for non-parallel make, we need to force `make -j1` because just doing `make` will run in parallel under jobserver (e.g. `spack env depfile`).

We now always add `-j1` when asked for a non-parallel execution (even if there is no jobserver).

And each `MakeExecutable` can now ask for jobserver support or not. For example: the default `ninja` does not support jobserver so spack applies the default `-j`, but `ninja@kitware` or `ninja-fortran` does, so spack doesn't add `-j`.

Tips: you can run `SPACK_INSTALL_FLAGS=-j1 make -f spack-env-depfile.make -j8` to avoid massive job-spawning because of build tools that don't support jobserver (ninja).
2022-11-04 02:05:22 -07:00
Todd Gamblin
9c5c327a6f
propagation: don't count propagated variant values as non-default (#33687)
We try to avoid non-default variant values in the concretizer, but this doesn't make
sense for variants forced to take some non-default value by variant propagation.
Counting this as a penalty effectively biases the concretizer for small specs dependency
graphs -- something we try very hard to avoid elsewhere because it can lead to very
strange decisions.

Example: with the penalty, `spack spec hdf5` will choose the default `openmpi` as its
`mpi` provider, but `spack spec hdf5 ~~shared` will choose `mpich` because it has to set
fewer non-default variant values because `mpich`'s DAG is smaller. That's not a good
reason to prefer a non-default virtual provider.

To fix this, if the user explicitly requests a non-default value to be propagated, there
shouldn't be a penalty. Variant values set on the CLI already don't count as default; we
just need to extend that to propagated values.
2022-11-03 18:26:03 -06:00
Harmen Stoppels
b52be75978
Experimental binding of shared ELF libraries (#31948)
Adds another post install hook that loops over the install prefix, looking for shared libraries type of ELF files, and sets the soname to their own absolute paths.

The idea being, whenever somebody links against those libraries, the linker copies the soname (which is the absolute path to the library) as a "needed" library, so that at runtime the dynamic loader realizes the needed library is a path which should be loaded directly without searching.

As a result:

1. rpaths are not used for the fixed/static list of needed libraries in the dynamic section (only for _actually_ dynamically loaded libraries through `dlopen`), which largely solves the issue that Spack's rpaths are a heuristic (`<prefix>/lib` and `<prefix>/lib64` might not be where libraries really are...)
2. improved startup times (no library search required)
2022-11-03 17:34:00 -06:00
Scott Wittenburg
b55509ffa8
gitlab: Prune untouched specs less aggressively (#33669)
Untouched spec pruning was added to reduce the number of specs
developers see getting rebuilt in their PR pipelines that they
don't understand.  Because the state of the develop mirror lags
quite far behind the tip of the develop branch, PRs often find
they need to rebuild things untouched by their PR.

Untouched spec pruning was previously implemented by finding all
specs in the environment with names of packages touched by the PR,
traversing in both directions the DAGS of those specs, and adding
all dependencies as well as dependents to a list of concrete specs
that should not be considered for pruning.

We found that this heuristic results in too many pruned specs, and
that dependents of touched specs must have all their dependencies
added to the list of specs that should not be considered for pruning.
2022-11-03 13:33:52 -06:00
Harmen Stoppels
243dfe91e9
Use spack.traverse.traverse_nodes where useful (#33677) 2022-11-03 11:34:24 +01:00
Massimiliano Culpo
0d82688903
Update metadata for bootstrapping (#33665) 2022-11-03 09:05:03 +00:00
Greg Becker
c716c6ca95
Bugfix for spec objects modified by flag handlers (#33682)
This issue was introduced in #29761:

```
==> Installing ncurses-6.3-22hz6q6cvo3ep2uhrs3erpp2kogxncbn
==> No binary for ncurses-6.3-22hz6q6cvo3ep2uhrs3erpp2kogxncbn found: installing from source
==> Using cached archive: /spack/var/spack/cache/_source-cache/archive/97/97fc51ac2b085d4cde31ef4d2c3122c21abc217e9090a43a30fc5ec21684e059.tar.gz
==> No patches needed for ncurses
==> ncurses: Executing phase: 'autoreconf'
==> ncurses: Executing phase: 'configure'
==> ncurses: Executing phase: 'build'
==> ncurses: Executing phase: 'install'
==> Error: AttributeError: 'str' object has no attribute 'propagate'

The 'ncurses' 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

/spack/lib/spack/spack/build_environment.py:1075, in _setup_pkg_and_run:
       1072        tb_string = traceback.format_exc()
       1073
       1074        # build up some context from the offending package so we can
  >>   1075        # show that, too.
       1076        package_context = get_package_context(tb)
       1077
       1078        logfile = None
```

It turns out this was caused by a bug that had been around much longer, in which the flags were passed by reference to the flag_handler, and the flag_handler was modifying the spec object, not just the flags given to the build system. The scope of this bug was limited by the forking model in Spack, which is how it went under the radar for so long.

PR includes regression test.
2022-11-02 21:09:43 -07:00
Harmen Stoppels
b652fe72d7
remove deptype_query remnants and fix incorrect deptypes kwarg (#33670)
* remove deptype_query remnants
* deptypes -> deptype

These arguments haven't existed since 2017, but `traverse` now fails on unknown **kwargs, so they have finally popped up.
2022-11-02 14:24:59 -07:00
Gregory Becker
aa4f478ab8 propagation: improve performance
This updates the propagation logic used in `concretize.lp` to avoid rules with `path()`
in the body and instead base propagation around `depends_on()`.
2022-11-02 09:43:57 -07:00
Kayla Butler
bc209c470d flags/variants: Add ++/~~/== syntax for propagation to dependencies
Currently, compiler flags and variants are inconsistent: compiler flags set for a
package are inherited by its dependencies, while variants are not. We should have these
be consistent by allowing for inheritance to be enabled or disabled for both variants
and compiler flags.

- [x] Make new (spec language) operators
- [x] Apply operators to variants and compiler flags
- [x] Conflicts currently result in an unsatisfiable spec
      (i.e., you can't propagate two conflicting values)

What I propose is using two of the currently used sigils to symbolized that the variant
or compiler flag will be inherited:

Example syntax:
- `package ++variant`
      enabled variant that will be propagated to dependencies
- `package +variant`
      enabled variant that will NOT be propagated to dependencies
- `package ~~variant`
      disabled variant that will be propagated to dependencies
- `package ~variant`
      disabled variant that will NOT be propagated to dependencies
- `package cflags==True`
      `cflags` will be propagated to dependencies
- `package cflags=True`
      `cflags` will NOT be propagated to dependencies

Syntax for string-valued variants is similar to compiler flags.
2022-11-02 09:43:57 -07:00
Todd Gamblin
a4d978be59
tests: fix group membership check in sbang tests. (#33658)
Fixes an issue on the RHEL8 UBI container where this test would fail because `gr_mem`
was empty for every entry in the `grp` DB.

You have to check *both* the `pwd` database (which has primary groups) and `grp` (which
has other gorups) to do this correctly.

- [x] update `llnl.util.filesystem.group_ids()` to do this
- [x] use it in the `sbang` test
2022-11-02 11:00:16 +01:00
Harmen Stoppels
4bad9f9b13
Consolidate DAG traversal in traverse.py, support DFS/BFS (#33406)
This PR introduces breadth-first traversal, and moves depth-first traversal
logic out of Spec's member functions, into `traverse.py`.

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

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

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

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

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

---

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

- Sometimes roots have to be handled differently (e.g. follow build edges of
  roots but not of deps). BFS ensures that root nodes are always discovered at
  depth 0, instead of at any depth > 1 as a dep of another root.
- When printing a tree, it would be nice to reduce indent levels so it fits in the 
  terminal, and ensure that e.g. `zlib` is not printed at indent level 10 as a 
  dependency of a build dep of a build dep -- rather if it's a direct dep of my
  package, I wanna see it at depth 1. This basically requires one breadth-first
  traversal to construct a tree, which can then be printed with depth-first traversal.
- In environments in general, it's sometimes inconvenient to have a double
  loop: first over the roots then over each root's deps, and maintain your own
  `visited` set outside. With BFS, you can simply init the queue with the
  environment root specs and it Just Works. [Example here](3ec7304699/lib/spack/spack/environment/environment.py (L1815-L1816))
2022-11-01 23:04:47 -07:00
Greg Becker
f696f02a46
Unit tests: make unit tests work for aarch64 machines (#33625)
Currently, many tests hardcode to older versions of gcc for comparisons of
concretization among compiler versions. Those versions are too old to concretize for
`aarch64`-family targets, which leads to failing tests on `aarch64`.

This PR fixes those tests by updating the compiler versions used for testing.

Currently, many tests hardcode the expected architecture result in concretization to the
`x86_64` family of architectures.

This PR generalizes the tests that can be generalized, to cover multiple architecture
families. For those that test specific relationships among `x86_64`-family targets, it
ensures that concretization uses the `x86_64`-family targets in those cases.

Currently, many tests rely on the fact that `AutotoolsPackage` imposes no dependencies
on the inheriting package. That is not true on `aarch64`-family architectures.

This PR ensures that the fact `AutotoolsPackage` on `aarch64` pulls in a dependency on
`gnuconfig` is ignored when testing for the appropriate relationships among dependencies

Additionally, 5 tests currently prompt the user for input when `gpg` is available in the
user's path. This PR fixes that issue. And 7 tests fail currently when the user has a
yubikey available. This PR fixes the incorrect gpg argument causing those issues.
2022-11-01 16:25:55 -06:00
Greg Sjaardema
e0265745bc
Update command option for example (#33321)
The `spack info <package>` command does not show the `Virtual Packages:` output unless the `--virtuals` command option is passed.  Before this changes, the information that the command is supposed to be illustrating is not shown in the example and is confusing.
2022-11-01 15:29:50 -06:00
Massimiliano Culpo
75360bdc21
Allow target requirements in packages.yaml (#32528)
This PR solves the issue reported in #32471 specifically for targets and operating systems, 
by avoiding to add a default platform to anonymous specs.
2022-11-01 22:11:49 +01:00
Harmen Stoppels
230e96fbb8
Add elf parsing utility function (#33628)
Introduces `spack.util.elf.parse_elf(file_handle)`
2022-11-01 19:42:06 +00:00
Harmen Stoppels
156dd5848e
Relocate links using prefix to prefix map (#33636)
Previously symlinks were not relocated when they pointed across packages
2022-11-01 16:00:51 +01:00
John W. Parent
222cef9b7c
Windows: fix library loading and enable Clingo bootstrapping (#33400)
Changes to improve locating shared libraries on Windows, which in
turn enables the use of Clingo. This PR attempts to establish a
proper distinction between linking on Windows vs. Linux/Mac: on
Windows, linking is always done with .lib files (never .dll files).
This somewhat complicates the model since the Spec.lib method could
return libraries that were used for both linking and loading, but
since these are not always the same on Windows, it was decided to
treat Spec.libs as being for link-time libraries. Additional functions
are added to help dependents locate run-time libraries.

* Clingo is now the default concretizer on Windows
* Clingo is now the concretizer used for unit tests on Windows
* Fix a permissions issue that can occur while moving Git files during
  fetching/staging
* Packages can now implement "win_add_library_dependent" to register
  files/directories that include libraries that would need to link
  to dependency dlls
* Packages can now implement "win_add_rpath" to register the locations
  of dlls that dependents would want to load
* "Spec.libs" on Windows is updated to return link-time libraries
  (i.e. .lib files, rather than .dll files)
* PackageBase.rpath on Windows is now updated to return the most-likely
  locations where .dlls will be found (which is generally in the bin/
  directory)
2022-10-31 09:36:52 -07:00
Harmen Stoppels
a4930c74cb
Make --backtrace show non-SpackError backtraces (#33540) 2022-10-31 12:49:19 +00:00
Harmen Stoppels
1ab888cdc1
remove sequential filter in binary relo (#33608)
Currently there's a slow sequential step in binary relocation where all
strings of a binary are collected, with rpaths removed, and then
filtered for the old install root.

This is completely unnecessary, and also incorrect, since we replace
more than just the old install root in the prefix to prefix mapping. And
in fact the prefix to prefix mapping is parallel, and a single pass. So
even as an optimization, this filter makes no sense anymore.

Therefor we remove it
2022-10-31 10:41:59 +01:00
Harmen Stoppels
616d5a89d4
_replace_prefix_bin performance improvements (#33590)
- single pass over the binary data matching all prefixes
- collect offsets and replacement strings
- do in-place updates with `fseek` / `fwrite`, since typically our
  replacement touch O(few bytes) while the file is O(many megabytes)
- be nice: leave the file untouched if some string can't be
  replaced
2022-10-31 10:08:16 +01:00
Massimiliano Culpo
7e645f54c5
Deprecate spack bootstrap trust/untrust (#33600)
* Deprecate spack bootstrap trust/untrust
* Update CI
* Update tests
2022-10-29 12:24:26 -07:00
Chris White
d4a0f588e9
CachedCMakePackage: Add back initconfig as a defined phase (#33575)
Also: add type annotation to indicate that "phases" is always a
tuple of strings.
2022-10-27 23:04:18 -07:00
Massimiliano Culpo
605411a9fb
LuaPackage: add missing attribute (#33551)
fixes #33544
2022-10-27 06:17:54 -06:00
百地 希留耶
4ff8a6a9b7
Windows: fix bootstrap and package install failure (#32942)
* Add patches for building clingo with MSVC
* Help python find clingo DLL
* If an executable is located in "C:\Program Files", Executable was
  running into issues with the extra space. This quotes the exe
  to ensure that it is treated as a single value.

Signed-off-by: Kiruya Momochi <65301509+KiruyaMomochi@users.noreply.github.com>
2022-10-26 13:45:35 -07:00
Massimiliano Culpo
30c9ff50dd
Allow for packages with multiple build-systems (#30738)
This commit extends the DSL that can be used in packages
to allow declaring that a package uses different build-systems
under different conditions.

It requires each spec to have a `build_system` single valued
variant. The variant can be used in many context to query, manipulate
or select the build system associated with a concrete spec.

The knowledge to build a package has been moved out of the
PackageBase hierarchy, into a new Builder hierarchy. Customization
of the default behavior for a given builder can be obtained by
coding a new derived builder in package.py.

The "run_after" and "run_before" decorators are now applied to
methods on the builder. They can also incorporate a "when="
argument to specify that a method is run only when certain
conditions apply.

For packages that do not define their own builder, forwarding logic
is added between the builder and package (methods not found in one
will be retrieved from the other); this PR is expected to be fully
backwards compatible with unmodified packages that use a single
build system.
2022-10-26 20:17:32 +02:00
Harmen Stoppels
6413862f84
fix use of non-existing kwarg (#33520) 2022-10-26 09:03:40 -07:00
Harmen Stoppels
b92bdf8c72
Relocation regex single pass (#33496)
Instead of looping over multiple regexes and the entire text file
contents, create a giant regex with all literal prefixes and do a single
pass over files to detect prefixes. Not only is a single pass faster,
it's also likely that the regex is compiled better, given that most
prefixes share a common ... prefix.
2022-10-26 10:41:31 +02:00
Harmen Stoppels
a2520e80c0
gitlab ci: install binary deps faster (#33248)
* Fast Gitlab CI job setup, and better legibility

* Use a non-broken, recent GNU Make
2022-10-26 09:19:24 +02:00
Harmen Stoppels
d039744a5b
dfs traversal: simplify edges in reverse mode (#33481)
In the dfs code, flip edges so that `parent` means `from` and
`spec` means `to` in the direction of traversal. This makes it slightly
easier to write generic/composable code. For example when using visitors
where one visitor reverses direction, and another only cares about
accepting particular edges or not depending on whether the target node
is seen before, it would be good if the second visitor didn't have to
know whether the order was changed or not.
2022-10-25 22:55:05 -07:00
Harmen Stoppels
b538acb2a9
binary_distribution: compress level 9 -> 6 (#33513)
Use the same compression level as `gzip` (6) instead of what Python uses
(9).

The LLVM tarball takes 4m instead of 12m to create, and is <1% larger.
That's not worth the wait...
2022-10-25 22:15:16 +00:00
Tamara Dahlgren
512f8d14d2
feature: Add -x|--explicit option to 'spack test run' (#32910) 2022-10-25 12:32:55 -07:00
Jonathon Anderson
9d5151ba25
BinaryCacheIndex: track update failures with cooldown (#33509)
#32137 added an option to update() a BinaryCacheIndex with a
cooldown: repeated attempts within this cooldown would not
actually retry. However, the cooldown was not properly
tracked for failures (which is common when the mirror
does not store any binaries and therefore has no index.json).

This commit ensures that update(..., with_cooldown=True) will
also skip the update even if a failure has occurred within the
cooldown period.
2022-10-25 11:36:12 -07:00
Harmen Stoppels
09e0bd55c2
spec.py: prefer transitive link and direct build/run/test deps (#33498)
Due to reuse concretization, we may generate DAGs with two occurrences
of the same package corresponding to distinct specs. This happens when
build dependencies are reused, since their dependencies are ignored in
concretization.

This caused a regression, for example: `spec['openssl']` would take the
'openssl' of the build dep `cmake`, instead of the direct `openssl`
dependency, simply because the edge to `cmake` was traversed first and
we do depth first traversal.

One solution that was discussed is to limit `spec[name]` to just direct
deps, or direct deps + transitive link deps, but this is too breaking.
Instead, this PR simply prioritizes transitive link and direct
build/run/test deps, and then falls back to a full DAG traversal. So,
it's just about order of iteration.
2022-10-25 16:47:50 +02:00
Massimiliano Culpo
4b237349a3
Remove recursive symbolic link in lib/spack/docs from git repository (#33483)
Delete code removing the symlink during CI
2022-10-25 12:27:13 +02:00
Harmen Stoppels
d361378553
Improve legibility of Gitlab CI (#33482)
Use --backtrace in ci instead of --debug to reduce verbosity
and don't show log on error, since log is already printed
2022-10-25 12:21:34 +02:00
iarspider
e7512bcb7b
Add filename to text_to_relocate only if it needs to be relocated (#31074)
Scan the text files for relocatable prefixes *before* creating a tarball,
to reduce the amount of work to be done during install from binary
cache. 

Co-authored-by: Harmen Stoppels <harmenstoppels@gmail.com>
2022-10-24 23:32:46 +02:00
Danny McClanahan
0b971a1aef
redact line numbers from grouped exception message (#33485) 2022-10-24 17:08:18 +00:00
Harmen Stoppels
d67b12eb79
locks: improved errors (#33477)
Instead of showing

```
==> Error: Timed out waiting for a write lock.
```

show

```
==> Error: Timed out waiting for a write lock after 1.200ms and 4 attempts on file: /some/file
```

s.t. we actually get to see where acquiring a lock failed even when not
running in debug mode.

And use pretty time units everywhere, so we don't get 1.45e-9 seconds
but 1.450ns etc.
2022-10-24 11:54:49 +02:00
Harmen Stoppels
7d99fbcafd
backtraces with --backtrace (#33478)
* backtraces without --debug

Currently `--debug` is too verbose and not-`--debug` gives to little
context about where exceptions are coming from.

So, instead, it'd be nice to have `spack --backtrace` and
`SPACK_BACKTRACE=1` as methods to get something inbetween: no verbose
debug messages, but always a full backtrace.

This is useful for CI, where we don't want to drown in debug messages
when installing deps, but we do want to get details where something goes
wrong if it goes wrong.

* completion
2022-10-23 18:12:38 -07:00
Harmen Stoppels
f9112a6244
Relocation should take hardlinks into account (#33460)
Currently `relocate_text` and `relocate_text_bin` are unsafe in the
sense that they run in parallel, and lead to races when modifying
different items pointing to the same inode.

This leads to the issue observed in #33453.

This PR:

1. Renames those functions to `unsafe_*` so people are aware
2. Adds logic to deal with hardlinks in current binary packages
3. Adds logic to deal with hardlinks when creating new binary tarballs,
   so the install side doesn't have to de-dupe hardlinks.
4. Adds a test for 3

The assumption is that all our relocation logic preserves inodes. That
is, we should never copy a file, modify it, and then move it back. I
quickly verified, and its seems like this is true for (binary) text
relocation, as well as rpath patching in patchelf (even when the file
grows) and mach-o fixes.
2022-10-21 18:30:26 +02:00
Massimiliano Culpo
abf3a696bd
Remove "spack buildcache copy" in v0.19.0 (#33437) 2022-10-21 12:17:53 +02:00
Scott Wittenburg
9a1957c881
gitlab: Do not use root_spec['pkg_name'] anymore (#33403)
* gitlab: Do not use root_spec['pkg_name'] anymore

For a long time it was fine to index a concrete root spec with the name
of a dependency in order to access the concrete dependency spec.  Since
pipelines started using `--use-buildcache dependencies:only,package:never`
though, it has exposed a scheduling issue in how pipelines are
generated.  If a concrete root spec depends on two different hashes of
`openssl` for example, indexing that root with just the package name
is ambiguous, so we should no longer depend on that approach when
scheduling jobs.

* env: make sure exactly one spec in env matches hash
2022-10-20 10:33:18 -06:00
Harmen Stoppels
e1344067fd
depfile: buildcache support (#33315)
When installing some/all specs from a buildcache, build edges are pruned
from those specs. This can result in a much smaller effective DAG. Until
now, `spack env depfile` would always generate a full DAG.

Ths PR adds the `spack env depfile --use-buildcache` flag that was
introduced for `spack install` before. This way, not only can we drop
build edges, but also we can automatically set the right buildcache
related flags on the specific specs that are gonna get installed.

This way we get parallel installs of binary deps without redundancy,
which is useful for Gitlab CI.
2022-10-19 13:57:06 -07:00
Massimiliano Culpo
7ad7fde09c
Add a command to bootstrap Spack right now (#33407) 2022-10-19 19:25:20 +02:00
Stephen Sachs
25cbb34579
Relocate "run" type dependencies too (#33191)
When downloading from binary cache not only replace RPATHs to dependencies, but
also text references to dependencies.

Example:
`autoconf@2.69` contains a text reference to the executable of its dependency
`perl`:

```
$ grep perl-5 /shared/spack/opt/spack/linux-amzn2-x86_64_v3/gcc-7.3.1/autoconf-2.69-q3lo/bin/autoreconf
eval 'case $# in 0) exec /shared/spack/opt/spack/linux-amzn2-x86_64_v3/gcc-7.3.1/perl-5.34.1-yphg/bin/perl -S "$0";; *) exec /shared/spack/opt/spack/linux-amzn2-x86_64_v3/gcc-7.3.1/perl-5.34.1-yphg/bin/perl -S "$0" "$@";; esac'
```

These references need to be replace or any package using `autoreconf` will fail
as it cannot find the installed `perl`.

Co-authored-by: Stephen Sachs <stesachs@amazon.com>
2022-10-19 17:37:07 +02:00
Jonathon Anderson
a423dc646a
Update the binary index before attempting direct fetches (#32137)
"spack install" will not update the binary index if given a concrete
spec, which causes it to fall back to direct fetches when a simple
index update would have helped. For S3 buckets in particular, this
significantly and needlessly slows down the install process.

This commit alters the logic so that the binary index is updated
whenever a by-hash lookup fails. The lookup is attempted again with
the updated index before falling back to direct fetches. To avoid
updating too frequently (potentially once for each spec being
installed), BinaryCacheIndex.update now includes a "cooldown"
option, and when this option is enabled it will not update more
than once in a cooldown window (set in config.yaml).

Co-authored-by: Tamara Dahlgren <35777542+tldahlgren@users.noreply.github.com>
2022-10-19 09:36:27 -06:00
Tamara Dahlgren
3ec7304699
spack checksum: warn if version is deprecated (#32438)
Co-authored-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
2022-10-18 22:51:38 +00:00
Tamara Dahlgren
13356f3bfa
Docs: Spack info option updates (#33376) 2022-10-18 21:11:21 +02:00
Harmen Stoppels
c6c5e56ec1
Reusable --use-buildcache with better validation (#33388)
Co-authored-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
2022-10-18 18:52:28 +00:00
Robert Underwood
da6aeaad44
Initial contribution of LibPressio ecosystem (#32630)
* Add libpressio and dependencies; some of these packages are
  maintained as forks of the original repositories and in those
  cases the docstring mentions this.
* Add optional dependency in adios2 on libpressio
* cub package: set CUB_DIR environment variable for dependent
  installations
* Clear R_HOME/R_ENVIRON before Spack installation (avoid sources
  outside of Spack from affecting the installation in Spack)
* Rename dlib to dorian3d-dlib and update dependents; add new dlib
  implementation. Pending an official policy on how to handle
  packages with short names, reviewer unilaterally decided that
  the rename was acceptable given that the new Spack dlib package
  is referenced more widely (by orders of magnitude) than the
  original

Co-authored-by: Samuel Li <shaomeng@users.noreply.github.com>
2022-10-17 13:30:54 -06:00
Harmen Stoppels
e7b14dd491
database: don't warn adding missing build deps (#33361)
When installing an individual spec `spack --only=package --cache-only /xyz`
from a buildcache, Spack currently issues tons of warnings about
missing build deps (and their deps) in the database.

This PR disables these warnings, since it's fine to have a spec without
its build deps in the db (they are just "missing").
2022-10-17 18:30:19 +02:00
Harmen Stoppels
39105a3a6f
installer.py: traverse_dependencies has local deptype (#33367)
Currently `traverse_dependencies` fixes deptypes to traverse once and
for all in the recursion, but this is incorrect, since deptypes depend
on the node (e.g. if it's a dependency and cache-only, don't follow
build type edges, even if the parent is build from sources and needs
build deps.)
2022-10-17 16:14:12 +00:00
Scott Wittenburg
29df7e9be3
Support spackbot rebuilding all specs from source (#32596)
Support spackbot rebuilding all specs from source when asked (with "rebuild everything")

- Allow overriding --prune-dag cli opt with env var
- Use job variable to optionally prevent rebuild jobs early exit behavior
- ci rebuild: Use new install argument to insist deps are always installed from binary, but
package is only installed from source.
- gitlab: fix bug w/ untouched pruning
- ci rebuild: install from hash rather than json file
- When doing a "rebuild everything" pipeline, make sure that each install job only consumes
binary dependencies from the mirror being populated by the current pipeline.  This avoids
using, e.g. binaries from develop, when rebuilding everything on a PR.
- When running a pipeline to rebuild everything, do not die because we generated a hash on
the broken specs list.  Instead only warn in that case.
- bugfix: Replace broken no-args tty.die() with sys.exit(1)
2022-10-17 09:45:09 -06:00
Harmen Stoppels
e882583b01
installer.py: fix/test get_deptypes (#33363)
Fixing an oversight in https://github.com/spack/spack/pull/32537

`get_deptypes` should depend on new `package/dependencies_cache_only`
props.
2022-10-17 08:57:58 -06:00
Scott Wittenburg
1be6506e29
gitlab ci: Do not force protected build jobs to run on aws runners (#33314) 2022-10-17 07:29:56 -07:00
Harmen Stoppels
2c802c12a5
installer.py: show timers for binary install (#33305)
Print a message of the form
```
Fetch mm:ss.  Build: mm:ss.  Total: mm:ss
```
when installing from buildcache. 

Previously this only happened for source builds.
2022-10-17 15:54:40 +02:00
Jonathon Anderson
10491e98a8
CI: allow multiple matches to combine tags (#32290)
Currently "spack ci generate" chooses the first matching entry in
gitlab-ci:mappings to fill attributes for a generated build-job,
requiring that the entire configuration matrix is listed out
explicitly. This unfortunately causes significant problems in
environments with large configuration spaces, for example the
environment in #31598 (spack.yaml) supports 5 operating systems,
3 architectures and 130 packages with explicit size requirements,
resulting in 1300 lines of configuration YAML.

This patch adds a configuraiton option to the gitlab-ci schema called
"match_behavior"; when it is set to "merge", all matching entries
are applied in order to the final build-job, allowing a few entries
to cover an entire matrix of configurations.

The default for "match_behavior" is "first", which behaves as before
this commit (only the runner attributes of the first match are used).

In addition, match entries may now include a "remove-attributes"
configuration, which allows matches to remove tags that have been
aggregated by prior matches. This only makes sense to use with
"match_behavior:merge". You can combine "runner-attributes" with
"remove-attributes" to effectively override prior tags.
2022-10-15 17:29:53 +00:00
Harmen Stoppels
2f6a56a43b
depfile: update docs (#33279) 2022-10-15 06:10:05 +02:00
Adam J. Stewart
d5ebb55338
meson: remove slash in path (#33292) 2022-10-13 20:26:51 -05:00
Scott Wittenburg
7da303334e
gitlab ci: Print better information about broken specs (#33124)
When a pipeline generation job is automatically failed because it
generated jobs for specs known to be broken on develop, print better
information about the broken specs that were encountered.  Include
at a minimum the hash and the url of the job whose failure caused it
to be put on the broken specs list in the first place.
2022-10-13 16:35:07 -06:00
Harmen Stoppels
599480ae9a
Add missing upperbound to docs/spack.yaml (#33280) 2022-10-13 11:54:20 -07:00
Harmen Stoppels
5009e3d94a
env depfile: allow deps only install (#33245)
* env depfile: allow deps only install

- Refactor `spack env depfile` to use a Jinja template, making it a bit
  easier to follow as a human being.
- Add a layer of indirection in the generated Makefile through an
  `<prefix>/.install-deps/<hash>` target, which allows one to specify
  different options when installing dependencies. For example, only
  verbose/debug mode on when installing some particular spec:
  ```
  $ spack -e my_env env depfile -o Makefile --make-target-prefix example
  $ make example/.install-deps/<hash> -j16
  $ make example/.install/<hash> SPACK="spack -d" SPACK_INSTALL_FLAGS=--verbose -j16
  ```

This could be used to speed up `spack ci rebuild`:
- Parallel install of dependencies from buildcache
- Better readability of logs, e.g. reducing verbosity when installing
  dependencies, and splitting logs into deps.log and current_spec.log

* Silence please!
2022-10-12 14:30:00 -07:00
Massimiliano Culpo
7efbd7d8eb
Fix typo in docs (#33182) 2022-10-12 08:31:48 +02:00
Harmen Stoppels
926dca9e5f
Specify GCC prefix in LLVM-based compilers (#33146)
* spack.compiler.Compiler: introduce prefix property

We currently don't really have something that gives the GCC install
path, which is used by many LLVM-based compilers (llvm, llvm-amdgpu,
nvhpc, ...) to fix the GCC toolchain once and for all.

This `prefix` property is dynamic in the sense that it queries the
compiler itself. This is necessary because it's not easy to deduce the
install path from the `cc` property (might be a symlink, might be a
filename like `gcc` which works by having the compiler load a module
that sets the PATH variable, might be a generic compiler wrapper based
on environment variables like on cray...).

With this property introduced, we can clean up some recipes that have
the logic repeated for GCC.

* intel-oneapi-compilers: set --gcc-sysroot to %gcc prefix
2022-10-11 17:45:51 -06:00
Massimiliano Culpo
de8c827983
Refactor a few classes related to package repositories (#32273)
Caches used by repositories don't reference the global spack.repo.path instance
anymore, but get the repository they refer to during initialization.
 
Spec.virtual now use the index, and computation done to compute the index 
use Repository.is_virtual_safe. 

Code to construct mock packages and mock repository has been factored into 
a unique MockRepositoryBuilder that is used throughout the codebase.

Add debug print for pushing and popping config scopes.

Changed spack.repo.use_repositories so that it can override or not previous repos

spack.repo.use_repositories updates spack.config.config according to the modifications done

Removed a peculiar behavior from spack.config.Configuration where push would always 
bubble-up a scope named command_line if it existed
2022-10-11 19:28:27 +02:00
Peter Scheibel
b594c0aee0
spack diff any specs you want (#32737)
Resolves #31782

With this change, if a spec is concrete after parsing (e.g. spec.yaml
or /hash-based), then it is not disambiguated (a process which requires
(a) that the spec be installed and (b) that it be part of the
currently-active environment).

This commit allows you to:

* Diff specs from an environment regardless of whether they have
  been installed (more useful for projection/matrix-based envs)
* Diff specs read from .yaml files which may or may not be entirely
  different installations of Spack

Co-authored-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
2022-10-11 10:03:31 -06:00
Axel Huebl
9d89dba292
Docs: Getting Started Dependencies (#32480)
* Docs: Getting Started Dependencies

Finally document what one needs to install to use Spack on
Linux and Mac :-)

With <3 for minimal container users and my colleagues with
their fancy Macs.

* Debian Update Packages: GCC, Python

- build-essential: includes gcc, g++ (thx Cory)
- Python: add python3-venv, python3-distutils (thx Pradyun)

* Add RHEL8 Dependencies
2022-10-10 23:25:37 +00:00
Brian Vanderwende
27cf8dddec
shell prompt: enclose control sequence in brackets (#33079)
When setting `PS1` in Bash, it's required to enclose non-printable characters in square brackets, so that the width of the terminal is handled correctly.

See https://www.gnu.org/software/bash/manual/bash.html#Controlling-the-Prompt
2022-10-10 07:29:58 -06:00
Adam J. Stewart
7cb745b03a
PythonPackage: fix libs/headers attributes (#32970) 2022-10-10 13:26:30 +00:00
Sergey Kosukhin
4bc8f66388
autotools: extend patching of the libtool script (#30768)
* filter_file: introduce argument 'start_at'

* autotools: extend patching of the libtool script

* autotools: refactor _patch_usr_bin_file

* autotools: improve readability of the filtering

* autotools: keep the modification time of the configure scripts

* autotools: do not try to patch directories

* autotools: explain libtool patching for posterity

Co-authored-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
Co-authored-by: Harmen Stoppels <harmenstoppels@gmail.com>
2022-10-07 22:04:44 +00:00
MatthewLieber
23f6c92f33
add compatibility for rocky8 and rhel8 (#33068) 2022-10-07 04:25:58 +00:00
Massimiliano Culpo
1a12ddbd2d
Add a warning on Python 2.7 deprecation (#33052)
Co-authored-by: alalazo <alalazo@users.noreply.github.com>
Co-authored-by: Todd Gamblin <tgamblin@llnl.gov>
2022-10-06 23:42:34 +02:00
Sergey Kosukhin
a520a7ef28
tcl module template: automatically unload automatically loaded modules (#32853)
Remove `module-info mode load` condition that prevents auto-unloading when autoloading is enabled. It looks like this condition was added to work around an issue in environment-modules that is no longer necessary.

Add quotes to make is-loaded happy
2022-10-06 20:15:28 +02:00
Harmen Stoppels
fc5da74998
docs: fix deprecated use of install_tree (#33004) 2022-10-06 09:45:46 +00:00
Andrew W Elble
28de7da0cc
cuda: add v11.8.0 (#33027)
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
2022-10-06 09:46:01 +02:00
Jordan Galby
6c12630e95
Optimize concurrent misc_cache provider index rebuild (#32874)
When concurrent misc_cache provider index rebuilds happen, try to
rebuild it only once, so we don't exceed misc_cache lock timeout.

For example, when using `spack env depfile`, with no previous
misc_cache, running `make -f depfile -j8` could run at most 8 concurrent
`spack install` locking on misc_cache to rebuild the provider index. If
one rebuild takes 30s, before this fix, the "worst" lock could wait up
to 30s * 7, easily exceeding misc_cache lock timeout. Now, the "worst"
lock would take 30s * 1 + ~1s * 6.
2022-10-05 06:01:59 -06:00
Chris MacMackin
53cea629b7
autotools: Filter libtools when building with dpcpp (#32876)
Due to a [known
issue](https://community.intel.com/t5/Intel-oneAPI-Data-Parallel-C/dpcpp-and-GNU-Autotools/m-p/1296985)
with dpcpp, autotool-based builds that try to use it will fail because
they try to link against temporary files that no longer exist. This
commit filters those files out of the libtools script so that linking
can work properly.
2022-10-05 11:57:37 +00:00
Greg Becker
5f59821433
BuildEnvironment: accumulate module changes to poke to all relevant modules (#32340)
Currently, module changes from `setup_dependent_package` are applied only to the module of the package class, but not to any parent classes' modules between the package class module and `spack.package_base`.

In this PR, we create a custom class to accumulate module changes, and apply those changes to each class that requires it. This design allows us to code for a single module, while applying the changes to multiple modules as needed under the hood, without requiring the user to reason about package inheritance.
2022-10-04 13:06:50 -07:00
Todd Gamblin
8c50b44bfe
find/list: display package counts last (#32946)
* find/list: display package counts last

We have over 6,600 packages now, and `spack list` still displays the number of packages
before it lists them all. This is useless for large sets of results (e.g., with no args)
as the number has scrolled way off the screen before you can see it. The same is true
for `spack find` with large installations.

This PR changes `spack find` and `spack list` so that they display the package count
last.

* add some quick testing

Co-authored-by: Danny McClanahan <1305167+cosmicexplorer@users.noreply.github.com>
2022-10-04 10:56:46 -07:00
Adam J. Stewart
450a3074e2
Fix typo in documentation (#32984) 2022-10-04 19:54:40 +02:00
John W. Parent
5a0f4970df
Fixup errors introduced by Clingo Pr: (#32905)
* re2c depends on cmake on Windows
* Winbison properly added to bootstrap package search list
2022-10-02 17:44:05 -07:00
Greg Becker
deae0c48e4
develop: canonicalize dev paths and base relative paths on env.path (#30075)
Allow environment variables and spack-specific path substitution variables (e.g. `$spack`) to be
used in the paths associated with develop specs, while maintaining the ability to keep those
paths relative to the environment rather than the working directory.
2022-09-30 20:56:53 +00:00
kwryankrattiger
a01c36da45
Install: Add use-buildcache option to install (#32537)
Install: Add use-buildcache option to install

* Allow differentiating between top level packages and dependencies when
determining whether to install from the cache or not.

* Add unit test for --use-buildcache

* Use metavar to display use-buildcache options.

* Update spack-completion
2022-09-29 13:48:06 -05:00
John W. Parent
650a668a9d
Windows: Support for Clingo and dependencies (#30690)
Make it possible to install the Clingo package on Windows; this
also provides a means to use Clingo with Spack on Windows.

This includes

* A new "winbison" package: Windows has a port of bison and flex where
  the two packages are grouped together. Clingo dependencies have been
  updated to use winbison on Windows and bison elsewhere (this avoids
  complicating the existin bison/flex packages until we can add support
  for implied virtuals).
* The CMake build system was incorrectly converting CMAKE_INSTALL_PREFIX
  to POSIX format.
* The re2c package has been modified to use CMake on Windows; for now
  this is done by overloading the configure/build/install methods to
  perform CMake-appropriate operations; the package should be refactored
  once support for multiple build systems in one Package is available.
2022-09-28 09:54:00 -06:00
Massimiliano Culpo
63dca0c6cc
Remove mentions of "best-effort" matrix expansion in the docs (#32755)
closes #20340
2022-09-28 09:15:36 +02:00
Alex Hornburg
67717c569e
shell.py: fix undefined variable in csh deactivate (#32816)
This commit fixes #27027.

The root cause of the issue is that the `SPACK_OLD_PROMPT` variable
was evaluated in string interpolation regardless of whether the
guard condition above evaluates to true or false. This commit uses
the `eval` keyword to defer evaluation until the command is executed.

Co-authored-by: Alexander Hornburg <alexande@xilinx.com>
2022-09-27 12:32:42 -07:00
Chris White
777271da18
improve lexing error (#32832) 2022-09-26 22:47:45 +00:00
John W. Parent
30f6fd8dc0
Fetching/decompressing: use magic numbers (#31589)
Spack currently depends on parsing filenames of downloaded files to
determine what type of archive they are and how to decompress them.
This commit adds a preliminary check based on magic numbers to
determine archive type (but falls back on name parsing if the
extension type cannot be determined).

As part of this work, this commit also enables decompression of
.tar.xz-compressed archives on Windows.
2022-09-26 00:01:42 -07:00
Tamara Dahlgren
4751881fd1
Fix two docstring typos (#32751) 2022-09-23 11:17:01 -07:00
Peter Scheibel
0a050785e9
Skip all tests using problematic fixture on python 2.7 (#32768) 2022-09-23 09:29:48 +02:00
Peter Scheibel
4094e59ab8
Fetching: log more exceptions (#32736)
Include exception info related to url retrieval in debug messages
which otherwise would be swallowed. This is intended to be useful
for detecting if CA configuration interferes with downloads from
HTTPS links.
2022-09-22 10:54:52 -07:00
Tamara Dahlgren
54d06fca79
Add hash hint to multi-spec message (#32652) 2022-09-22 09:18:43 +02:00
Massimiliano Culpo
7e01a1252a
Allow conditional variants as first values in a variant directive (#32740) 2022-09-21 19:22:58 +02:00
Tamara Dahlgren
f12ececee5
Docs: Update pipeline ci rebuild to add --tests (plus fixed typos) (#32048) 2022-09-21 14:23:58 +02:00
Manuela Kuhn
d4c13b0f8f
Add skip_import to PythonPackage and use it in py-nilearn (#32664)
* Add skip_import to PythonPackage and use it in py-nilearn

* Fix dependencies
2022-09-17 23:02:30 +00:00
Todd Gamblin
a0c7209dc1
bugfix: package hash should affect process, dag, and dunder hashes (#32516)
This fixes a bug where two installations that differ only by package hash will not show
up in `spack find`.

The bug arose because `_cmp_node` on `Spec` didn't include the package hash in its
yielded fields. So, any two `Spec` objects that were only different by package hash
would appear to be equal and would overwrite each other when inserted into the same
`dict`. Note that we could still *install* specs with different package hashes, and they
would appear in the database, but we code that needed to put them into data structures
that use `__hash__` would have issues.

This PR makes `Spec.__hash__` and `Spec.__eq__` include the `process_hash()`, and it
makes `Spec._cmp_node` include the package hash. All of these *should* include all
information in a spec so that we don't end up in a situation where we are blind to
particular field differences.

Eventually, we should unify the `_cmp_*` methods with `to_node_dict` so there aren't two
sources of truth, but this needs some thought, since the `_cmp_*` methods exist for
speed. We should benchmark whether it's really worth having two types of hashing now
that we use `json` instead of `yaml` for spec hashing.

- [x] Add `package_hash` to `Spec._cmp_node`
- [x] Add `package_hash` to `spack.solve.asp.spec_clauses` so that the `package_hash`
      will show up in `spack diff`.
- [x] Add `package_hash` to the `process_hash` (which doesn't affect abstract specs
      but will make concrete specs correct)
- [x] Make `_cmp_iter` report the dag_hash so that no two specs with different
      process hashes will be considered equal.
2022-09-16 00:57:10 +00:00
John W. Parent
deca34676f
Bugfix: find_libraries (#32653)
53a7b49 created a reference error which broke `.libs` (and
`find_libraries`) for many packages. This fixes the reference
error and improves the testing for `find_libraries` by actually
checking the extension types of libraries that are retrieved by
the function.
2022-09-14 14:45:42 -06:00
Peter Scheibel
7971985a06
Manifest parsing: skip invalid manifest files (#32467)
* catch json schema errors and reraise as property of SpackError
* no need to catch subclass of given error
* Builtin json library for Python 2 uses more generic type
* Correct instantiation of SpackError (requires a string rather than an exception)
* Use exception chaining (where possible)
2022-09-14 13:02:51 -07:00
psakievich
045a5e80cb
Allow version to accept the '=' token without activating lexer switch (#32257) 2022-09-14 10:16:28 -07:00
Sam Broderick
d6a3ffc301
Update module_file_support.rst (#32629)
Missing lead in "This may to inconsistent modulfiles if..."
2022-09-14 01:41:50 +00:00
John W. Parent
53a7b49619
Windows rpath support (#31930)
Add a post-install step which runs (only) on Windows to modify an
install prefix, adding symlinks to all dependency libraries.

Windows does not have the same concept of RPATHs as Linux, but when
resolving symbols will check the local directory for dependency
libraries; by placing a symlink to each dependency library in the
directory with the library that needs it, the package can then
use all Spack-built dependencies.

Note:

* This collects dependency libraries based on Package.rpath, which
  includes only direct link dependencies
* There is no examination of libraries to check what dependencies
  they require, so all libraries of dependencies are symlinked
  into any directory of the package which contains libraries
2022-09-13 10:28:29 -07:00
Tamara Dahlgren
62e788fb89
Added install phase test methods for CachedCMakePackage (inherited) and WafPackage (#32627) 2022-09-13 12:12:15 +02:00
Massimiliano Culpo
1427ddaa59
ci: restore coverage computation (#32585)
* ci: restore coverage computation

* Mark "test_foreground_background" as xfail

* Mark "test_foreground_background_output" as xfail

* Make number of processes explicit, remove verbosity on linux

* Run coverage on just 3 Python jobs for linux

* Run coverage on just 3 Python jobs for linux

* Run coverage on just 2 Python jobs for linux

* Add back verbose, since before we didn't encounter the xdist internal error

* Reduce the workers to 2

* Try to use command line
2022-09-10 07:25:44 -06:00
psakievich
b4a2b8d46c
GitRef Versions: Bug Fixes (#32437)
* Fix a version cmp bug in asp.py

* Fix submodule bug for git refs

* Add branch in logic for submodules

* Fix git version comparisons

main does not satisfy git.foo=main
git.foo=main does satisfy main
2022-09-09 11:02:40 -07:00
Peter Scheibel
02151ac649
CMakePackage: allow custom CMAKE_PREFIX_PATH entries (#32547)
* define `cmake_prefix_paths` property for packages

add to CMake arguments via CMakePackage

Co-authored-by: Robert Underwood <runderwood@anl.gov>
2022-09-08 16:23:04 -07:00
Peter Scheibel
021ff1c7da
Skip test which fails randomly on Python 2.7 (#32569) 2022-09-08 08:11:20 +02:00
Tom Scogland
762ba27036
Make GHA tests parallel by using xdist (#32361)
* Add two no-op jobs named "all-prechecks" and "all"

These are a suggestion from @tgamblin, they are stable named markers we
can use from gitlab and possibly for required checks to make CI more
resilient to refactors changing the names of specific checks.

* Enable parallel testing using xdist for unit testing in CI

* Normalize tmp paths to deal with macos

* add -u flag compatibility to spack python

As of now, it is accepted and ignored.  The usage with xdist, where it
is invoked specifically by `python -u spack python` which is then passed
`-u` by xdist is the entire reason for doing this.  It should never be
used without explicitly passing -u to the executing python interpreter.

* use spack python in xdist to support python 2

When running on python2, spack has many import cycles unless started
through main.  To allow that, this uses `spack python` as the
interpreter, leveraging the `-u` support so xdist doesn't error out when
it unconditionally requests unbuffered binary IO.

* Use shutil.move to account for tmpdir being in a separate filesystem sometimes
2022-09-07 20:12:57 +02:00
Seth R. Johnson
c7292aa4b6
Fix spack locking on some NFS systems (#32426)
Co-authored-by: Todd Gamblin <tgamblin@llnl.gov>
2022-09-06 09:50:59 -07:00
Massimiliano Culpo
d7d59a24d1
Mark a test xfail on Python 2.7 (#32526)
refers #32470
2022-09-06 11:56:44 +02:00
Tom Scogland
69f7a8f4d1
Reorder workflow execution in GHA (#32183)
This patchset refactors our GitHub actions into a single top-level ci workflow that
invokes a series of reusable actions.  The main goal of this is to be able to easily
control which tests run and in what order based on the success or failure of top-level
prechecks.  Our previous workflows ran in three sets:

* nix tests: style and verification first, then linux and macos tests if successful
* windows tests: style and verification first, then linux and macos tests if successful
* bootstrap tests

As a result, the bootstrap tests ran even if the style failed, and style and verification
had to run on two different platforms despite running identical checks.  I'm relatively
sure that's because of the limitation on dependencies between steps in the jobs.
Reusable workflows allow us to run the style, verification and now audit checks once,
then depending on the results, and the files changed, run the appropriate nix, windows
and bootstrap tests.  While it saves only a few minutes by itself, this makes it easier to
refactor checks to subset tests without having to replicate tests or other workflow
components in the future.

Co-authored-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
2022-09-02 14:09:23 -07:00
Harmen Stoppels
80389911cc
Update bootstrap buildcache to v0.3 (#32262)
This release allow to bootstrap patchelf from binaries.
2022-09-02 12:48:46 +02:00
Scott Wittenburg
6239198d65
Fix cause of checksum failures in public binary mirror (#32407)
Move the copying of the buildcache to a root job that runs after all the child
pipelines have finished, so that the operation can be coordinated across all
child pipelines to remove the possibility of race conditions during potentially
simlutandous copies. This lets us ensure the .spec.json.sig and .spack files
for any spec in the root mirror always come from the same child pipeline
mirror (though which pipeline is arbitrary).  It also allows us to avoid copying
of duplicates, which we now do.
2022-09-01 15:29:44 -06:00
Peter Scheibel
2968ae667f
New command, spack change, to change existing env specs (#31995)
If you have an environment like

```
$ cat spack.yaml
spack:
  specs: [openmpi@4.1.0+cuda]
```

this PR provides a new command `spack change` that you can use to adjust environment specs from the command line:

```
$ spack change openmpi~cuda
$ cat spack.yaml
spack:
  specs: [openmpi@4.1.0~cuda]
```

in other words, this allows you to tweak the details of environment specs from the command line.

Notes:

* This is only allowed for environments that do not define matrices
  * This is possible but not anticipated to be needed immediately
  * If this were done, it should probably only be done for "named"/not-anonymous specs (i.e. we can change `openmpi+cuda` but not spec like `+cuda` or `@4.0.1~cuda`)
2022-09-01 11:04:01 -07:00
Massimiliano Culpo
0df0b9a505
Port package sanity unit tests to audits (#32405) 2022-09-01 08:21:12 +02:00
Massimiliano Culpo
0c6e3188ac
ASP-based solver: allow to reuse installed externals (#31558)
fixes #31484

Before this change if anything was matching an external
condition, it was considered "external" and thus something
to be "built".

This was happening in particular to external packages
that were re-read from the DB, which then couldn't be
reused, causing the problems shown in #31484.

This PR fixes the issue by excluding specs with a
"hash" from being considered "external"

* Test that users have a way to select a virtual

This ought to be solved by extending the "require"
attribute to virtual packages, so that one can:
```yaml
mpi:
  require: 'multi-provider-mpi'
```

* Prevent conflicts to be enforced on specs that can be reused.

* Rename the "external_only" fact to "buildable_false", to better reflect its origin
2022-08-31 20:05:55 +00:00
Tamara Dahlgren
3894ceebc9
Environments: Add support for include URLs (#29026)
* Preliminary support for include URLs in spack.yaml (environment) files

This commit adds support in environments for external configuration files obtained from a URL with a preference for grabbing raw text from GitHub and gitlab for efficient downloads of the relevant files. The URL can also be a link to a directory that contains multiple configuration files.

Remote configuration files are retrieved and cached for the environment. Configuration files with the same name will not be overwritten once cached.
2022-08-30 11:13:23 -07:00
Betsy McPhail
ad95719a1d
Use threading.TIMEOUT_MAX when available (#32399)
This value was introduced in Python 3.2. Specifying a timeout greater than
this value will raise an OverflowError.
2022-08-26 17:37:56 -06:00
Massimiliano Culpo
51244abee9
Configuration: Allow requirements for virtual packages (#32369)
Extend the semantics of package requirements to
allow using them also under a virtual package
attribute in packages.yaml

These requirements are enforced whenever that
virtual spec is present in the DAG.
2022-08-26 13:17:40 -07:00
Massimiliano Culpo
b6ea2a46d1
Update archspec to latest commit (#32368)
Modifications:

- [x] Add graviton3
- [x] Optimize __eq__ for microarchitectures
2022-08-26 12:58:20 +02:00
Chris White
b31cd189a7
Improve error message for yaml config file (#32382)
* improve error message

* Update lib/spack/spack/config.py

Co-authored-by: Tamara Dahlgren <35777542+tldahlgren@users.noreply.github.com>

Co-authored-by: Tamara Dahlgren <35777542+tldahlgren@users.noreply.github.com>
2022-08-26 02:43:03 +00:00
Adam J. Stewart
507e06b5d2
Python: add new maintainer (#31755) 2022-08-25 09:46:09 -07:00
Massimiliano Culpo
8654197c56
ASP-based solver: prevent the use of hashes that are not available (#32354)
fixes #32348
2022-08-25 17:55:58 +02:00
Massimiliano Culpo
e2468c8928
Allow default requirements in packages.yaml (#32260)
Allow users to express default requirements in packages.yaml. 

These requirements are overridden if more specific requirements
are present for a given package.
2022-08-24 09:33:55 +02:00
Ryan Marcellino
af4788fdef
New package: py-griffe and new build backend: py-pdm-pep517 (#32335)
* New package: py-griffe and new build backend: py-pdm-pep517

* add pdm to build backend docs
2022-08-23 23:23:23 -05:00
Harmen Stoppels
707a099b69
spack -e x config --scope=y add z add to scope (#31746)
* `spack -e x config --scope=y add z` add to scope

instead of to the environment file.
2022-08-23 12:52:34 -07:00
Simon Pintarelli
44258a7cce
meson: create unique names for build directory (#32062)
Taken from CMakePackage
2022-08-23 13:24:32 +02:00
Tamara Dahlgren
3c3b18d858
spack ci: add support for running stand-alone tests (#27877)
This support requires adding the '--tests' option to 'spack ci rebuild'.
Packages whose stand-alone tests are broken (in the CI environment) can
be configured in gitlab-ci to be skipped by adding them to
broken-tests-packages.

Highlights include:
- Restructured 'spack ci' help to provide better subcommand summaries;
- Ensured only one InstallError (i.e., installer's) rather than allowing
  build_environment to have its own; and
- Refactored CI and CDash reporting to keep CDash-related properties and
  behavior in a separate class.

This allows stand-alone tests from `spack ci` to run when the `--tests`
option is used.  With `--tests`, stand-alone tests are run **after** a
**successful** (re)build of the package.  Test results are collected
and report(able) using CDash.

This PR adds the following features:
- Adds `-t` and `--tests` to `spack ci rebuild` to run stand-alone tests;
- Adds `--fail-fast` to stop stand-alone tests after the first failure;
- Ensures a *single* `InstallError` across packages
    (i.e., removes second class from build environment);
- Captures skipping tests for externals and uninstalled packages
    (for CDash reporting);
- Copies test logs and outputs to the CI artifacts directory to facilitate
    debugging;
- Parses stand-alone test results to report outputs from each `run_test` as
    separate test parts (CDash reporting);
- Logs a test completion message to allow capture of timing of the last
    `run_test` part;
- Adds the runner description to the CDash site to better distinguish entries
    in CDash tables;
- Adds `gitlab-ci` `broken-tests-packages` to CI configuration to skip
    stand-alone testing for packages with known issues;
- Changes `spack ci --help` so description of each subcommand is a single line;
- Changes `spack ci <subcommand> --help` to provide the full description of
    each command (versus no description); and
- Ensures `junit` test log file ends in an `.xml` extension (versus default where
    it does not).

Tasks:

- [x] Include the equivalent of the architecture information, or at least the host target, in the CDash output
- [x] Upload stand-alone test results files as  `test` artifacts
- [x] Confirm tests are run in GitLab
- [x] Ensure CDash results are uploaded as artifacts
- [x] Resolve issues with CDash build-and test results appearing on same row of the table 
- [x] Add unit tests  as needed
- [x] Investigate why some (dependency) packages don't have test results (e.g., related from other pipelines)
- [x] Ensure proper parsing and reporting of skipped tests (as `not run`) .. post- #28701 merge
- [x] Restore the proper CDash URLand or mirror ONCE out-of-band testing completed
2022-08-23 00:52:48 -07:00
sparkyniner
21e6679056
spack list: add --tag flag (#32016)
* modified list.py and added functionality for --tag

* Removed long and very long, shifted rest of code above return statement

* removed results variable

* added import statement at top

* added the line accidentally deleted

* added line accidentally deleted

* changed p.name to p, added line inside if statement

* line order switched

* [@spackbot] updating style on behalf of sparkyniner

* ran update completion command

* add tests

* Update lib/spack/spack/test/cmd/list.py

Co-authored-by: Adam J. Stewart <ajstewart426@gmail.com>

* [@spackbot] updating style on behalf of sparkyniner

* changed argument to mock_packages and moved code under filter by tag

* removed bad rebase code and added additional test

* [@spackbot] updating style on behalf of sparkyniner

* added line removed earlier

* added line removed earlier

* replaced function

* added more recommended changes

Co-authored-by: sairaj <sairaj@sairajs-MacBook-Pro.local>
Co-authored-by: Adam J. Stewart <ajstewart426@gmail.com>
2022-08-20 16:09:44 -06:00
Harmen Stoppels
2daea9e4b4
docs: add a note about an issue being solved on develop (#32261) 2022-08-19 12:40:41 +00:00
psakievich
abf847ce82
Add messages to assertions in asp.py (#32237)
Assertions without messages if/when hit create a blank error message for users.  

This PR adds error messages to all assertions in asp.py even
if it seems unlikely they will ever be needed.
2022-08-19 14:15:25 +02:00
Massimiliano Culpo
605d72133b
spack.util.package_hash: parametrize unit-tests (#32240)
* spack.util.package_hash: parametrize unit-tests

* Fix comment
2022-08-18 18:17:43 -07:00
Massimiliano Culpo
3c6b5b8afc
Remove unused argument in test fixture (#32236)
The argument is very likely a typo, and was meant to
be given to the fixture decorator. Since the value
being passed is the default, let's just remove it.
2022-08-18 10:22:50 -07:00
Massimiliano Culpo
9d55a0436b
spec: fix typo in Spec._finalize_concretization (#32210) 2022-08-18 15:04:08 +02:00
Tom Scogland
b9e57006c9
bugfix: use cmake version from dependency (#31739)
Ensure that build tools with module-level commands in spack use
the version built as part of their build graph if one exists.
This is now also required for mesa, scons, cmake and ctest, out
of graph versions of these tools in path will not be found unless
added as an external.

This bug appeared because a new version of rocprim needs cmake
3.16, while I have 3.14 in my path I had added an external for
cmake 3.20 to the dag, but 3.14 was still used to configure
rocprim causing it to fail. As far as I can tell, all the build
tools added in build_environment.py had this problem, despite the
fact that they should have been resolving these tools by name
with a path search and find the one in the dag that way. I'm
still investigating why the path searching and Executable logic
didn't do it, but this makes three of the build systems much more
explicit, and leaves only gmake and ninja as dependencies from
out in the system while ensuring the version in the dag is used
if there is one.

The additional sqlite version is to perturb the hash of python to
work around a relocation bug which will be fixed in a subsequent
PR.
2022-08-17 17:54:17 -07:00
Peter Scheibel
546c8a3092 Add c++14 support flag for xl compiler (#31826) 2022-08-17 13:57:13 +02:00
Wouter Deconinck
8f34a3ac5c
filesystem: in recursive mtime, check only files that exist (#32175)
* filesystem: use lstat in recursive mtime

When a `develop` path contains a dead symlink, the `os.stat` in the recursive `mtime` determination trips up over it.

Closes #32165.
2022-08-16 21:06:31 +00:00
Todd Gamblin
7e1890772c bugfix: silence clingo warning about requirement_policy/3
`requirement_policy/3` is generated and may not be in Spack's inputs to Clingo.
Currently this is causing warnings like:

```
$ spack spec zlib
/global/u2/t/tgamblin/src/spack/lib/spack/spack/solver/concretize.lp:510:3-43: info: atom does not occur in any rule head:
  requirement_policy(Package,X,"one_of")

/global/u2/t/tgamblin/src/spack/lib/spack/spack/solver/concretize.lp:517:3-43: info: atom does not occur in any rule head:
  requirement_policy(Package,X,"one_of")

/global/u2/t/tgamblin/src/spack/lib/spack/spack/solver/concretize.lp:523:3-43: info: atom does not occur in any rule head:
  requirement_policy(Package,X,"any_of")

/global/u2/t/tgamblin/src/spack/lib/spack/spack/solver/concretize.lp:534:3-43: info: atom does not occur in any rule head:
  requirement_policy(Package,X,"any_of")

Input spec
--------------------------------
zlib

Concretized
--------------------------------
zlib@1.2.11%gcc@7.5.0+optimize+pic+shared arch=cray-sles15-haswell
```

- [x] Silence warning with `#defined requirement_policy/3`
2022-08-16 12:56:37 -07:00
Peter Scheibel
8281a0c5fe
Configuration: allow users to enforce hard spec constraints (#27987)
Spack doesn't have an easy way to say something like "If I build
package X, then I *need* version Y":

* If you specify something on the command line, then you ensure
  that the constraints are applied, but the package is always built
* Likewise if you `spack add X...`` to your environment, the
  constraints are guaranteed to hold, but the environment always
  builds the package
* You can add preferences to packages.yaml, but these are not
  guaranteed to hold (Spack can choose other settings)

This commit adds a 'require' subsection to packages.yaml: the
specs added there are guaranteed to hold. The commit includes
documentation for the feature.

Co-authored-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
2022-08-16 11:44:30 -07:00
Peter Scheibel
4c2f357f0e
CI/documentation: constrain pygments to avoid latest version (2.13.0) (#32163)
All PRs are failing the docs build on account of an error with
pygments. These errors coincide with a new release of pygments
(2.13.0) and restricting to < 2.13 allows the doc tests to pass,
so this commit enforces that constraint for the docs build.

Co-authored-by: Adam J. Stewart <ajstewart426@gmail.com>
2022-08-15 18:00:33 -07:00
Massimiliano Culpo
2131bd7e8c
Check that no reserved names are overridden by package recipes (#32092)
A few attribute in packages are meant to be reserved for
Spack internal use. This audit checks packages to ensure none
of these attributes are overridden.

- [x] add additional audit check
2022-08-15 16:31:10 -07:00
renjithravindrankannath
08e75f7a3e
rocm: add v5.2 for the entire stack (#31591) 2022-08-12 09:20:47 +02:00
Massimiliano Culpo
1913dc2da3
Fix performance regression with spack mirror create --all (#32005)
This PR fixes the performance regression reported in #31985 and a few
other issues found while refactoring the spack mirror create command.

Modifications:

* (Primary) Do not require concretization for
  `spack mirror create --all`
* Forbid using --versions-per-spec together with --all
* Fixed a few issues when reading specs from input file (specs were
  not concretized, command would fail when trying to mirror
  dependencies)
* Fix issue with default directory for spack mirror create not being
  canonicalized
* Add more unit tests to poke spack mirror create
* Skip externals also when mirroring environments
* Changed slightly the wording for reporting (it was mentioning
  "Successfully created" even in presence of errors)
* Fix issue with colify (was not called properly during error
  reporting)
2022-08-11 16:51:01 -07:00