Commit graph

6300 commits

Author SHA1 Message Date
百地 希留耶
90ac0ef66e
Implement fish completion (#29549)
* commands: provide more information to Command

* fish: Add script to generate fish completion

* fish: auto prepend `spack` command to avoid duplication

* fish: impove completion generation code readability

* commands: replace match-case with if-else

* fish: fix optspec variable name prefix

* fish: fix return value in get_optspecs

* fish: fix return value in get_optspecs

* format: split long line and trim trailing space

* bugfix: replace f-string with interpolation

* fish: compete more specs and some fixes

* fish: complete hash spec starts with /

* fish: improve compatibility

* style: trim trailing whitespace

* commands: add fish to update args and update tests

* commands: add fish completion file

* style: merge imports

* fish: source completion in setup-env

* fish: caret only completes dependencies

* fish: make sure we always get same order of output

* fish: spack activate
only show installed packages that have extensions

* fish: update completion file

* fish: make dict keys sorted

* Blacken code

* Fix bad merge

* Undo style changes to setup-env.fish

* Fix unit tests

* Style fix

* Compatible with fish_indent

* Use list for stability of order

* Sort one more place

* Sort more things

* Sorting unneeded

* Unsort

* Print difference

* Style fix

* Help messages need quotes

* Arguments to -a must be quoted

* Update types

* Update types

* Update types

* Add type hints

* Change order of positionals

* Always expand help

* Remove shared base class

* Fix type hints

* Remove platform-specific choices

* First line of help only

* Remove unused maps

* Remove suppress

* Remove debugging comments

* Better quoting

* Fish completions have no double dash

* Remove test for deleted class

* Fix grammar in header file

* Use single quotes in most places

* Better support for remainder nargs

* No magic strings

* * and + can also complete multiple

* lower case, no period

---------

Co-authored-by: Adam J. Stewart <ajstewart426@gmail.com>
2023-07-22 08:55:12 -05:00
Massimiliano Culpo
c0b42151c3
Remove spack.repo.IndexError (#39029)
This exception is never used and
overrides a built-in.
2023-07-21 15:33:30 +02:00
Ashwin Kumar Karnad
405f563909
binary_caches.rst: fix typo (#39030) 2023-07-21 10:39:53 +02:00
Sergey Kosukhin
d2566e3d62
nag: update the versioning scheme (#35457)
* nag: append build number to the version
* nag: add version 7.1.7125
* nag: deprecate unavailable versions
2023-07-20 12:03:26 -07:00
Massimiliano Culpo
50b90e430d
spack.util.lock: add type-hints, remove **kwargs in method signatures (#39011) 2023-07-20 09:41:23 +02:00
Massimiliano Culpo
3a565c66e9
Respect custom user store when bootstrapping (#39001)
The user store is lazily evaluated. The change
in #38975 made it such that the first evaluation
was happening in the middle of swapping to user
configuration.

Ensure we construct the user store before that.
2023-07-19 19:53:33 -04:00
Xavier Delaruelle
d9fbdfbee9
modules: use curly braces to enclose value in Tcl modulefile (#38375)
Use curly braces instead of quotes to enclose value or text in Tcl
modulefile. Within curly braces Tcl special characters like [, ] or $
are treated verbatim whereas they are evaluated within quotes.

Curly braces is Tcl recommended way to enclose verbatim content [1].

Note: if curly braces charaters are used within content, they must be
balanced. This point has been checked against current repository and no
unbalanced curly braces has been spotted.

Fixes #24243

[1] https://wiki.tcl-lang.org/page/Tcl+Minimal+Escaping+Style
2023-07-19 17:57:37 +02:00
Harmen Stoppels
185bccb70f
Fetch & patch: actually acquire stage lock, and many more issues (#38903)
* Fetching patches wouldn't result in acquiring a stage lock during install
* The installer would acquire a stage lock *after* fetching instead of
   before, leading to races
* The name of the stage for patches was random, so on build failure
   (where stage dirs are not removed), these directories would continue
   to exist after a second successful install.
* There was this redundant "composite fetch" object -- there's already
   a composite stage. Remove this.
* For some reason we do *double* shasum validation of patches, before
   and after compression -- that's just too much? I removed it.
2023-07-19 15:06:56 +02:00
Harmen Stoppels
886946395d
drop redundant rpaths post install (#38976)
Spack heuristically adds `<install prefix>/lib` and `<install prefix>/lib64` as rpath entries, as it doesn't know what the install dir is going to be ahead of the build. This PR cleans up non-existing, absolute paths[^1], which

1. avoids redundant stat calls at runtime
2. drops redundant rpaths in `patchelf`, making it relocatable -- you don't need patchelf recursively then.

[^1]: It also removes relative paths not starting with `$` (so, `$ORIGIN/../lib` is retained -- we _could_ interpolate `$ORIGIN`, but that's hard to get right when symlinks have to be taken into account). Relative paths _are_ supported in glibc, but are relative to _the current working directory_, which is madness, and it would be better to drop those paths.
2023-07-19 09:48:31 +00:00
Massimiliano Culpo
f34c93c5f8
llnl.util.lock: add type-hints (#38977)
Also uppercase global variables in the module
2023-07-19 11:23:08 +02:00
Massimiliano Culpo
a7f2abf924
Remove LazyReference from code (#38944)
A LazyReference object is a reference to an attribute of a 
lazily evaluated singleton. Its only purpose is to let developers
use shorter names to refer to such attribute.

This class does more harm than good, as it obfuscates the fact
that we are using the attribute of a global object. Also, it can easily
go out of sync with the singleton it refers to if, for instance, the
singleton is updated but the references are not.

This commit removes the LazyReference class entirely, and access
the attributes explicitly passing through the global value to which
they are attached.
2023-07-19 11:08:51 +02:00
markus-ferrell
416edfa229
Windows testing: enable tests for installer components (#36970)
These tests now work without any changes to core. Furthermore, it is
surprising that they had to be disabled (at least, as long as the
installer.py tests are run on Windows: these tests are more-basic
and their functionality would have been exercised automatically).
2023-07-18 16:19:14 -07:00
Massimiliano Culpo
14f3297cca
Ensure the bootstrap store has a padding length of zero (#38975)
Without this PR, padded length was propagating from user configuration to
bootstrap configuration, and was causing the issue reported in #38963
2023-07-18 23:49:22 +02:00
markus-ferrell
f24f98a1e2
Windows testing: enable bootstrap test (#36972) 2023-07-18 14:42:26 -07:00
markus-ferrell
ffc283ab8b
test_clear_failures_success: run on Windows too (#36792) 2023-07-18 22:42:57 +02:00
Harmen Stoppels
3fef586cfb
binary cache docs: remove redundant flag and comment (#38960) 2023-07-18 22:38:04 +02:00
markus-ferrell
b710778bda
Windows testing: enable architecture test (#36973)
Works out of the box: remove skip.
2023-07-18 12:33:52 -07:00
markus-ferrell
a965fe9354
Windows testing: enable "spack clean" tests (#36840)
They work out out of the box on windows. Simply removing skips.
2023-07-18 12:25:32 -07:00
Harmen Stoppels
5b23c5dcc0
buildcache push: make --allow-root the default and deprecate the option (#38878)
Without --allow-root spack cannot push binaries that contain paths in
binaries. This flag is almost always needed, so there is no point of
requiring users to spell it out. 

Even without --allow-root, rpaths would still have to be patched, so the 
flag is not there to guarantee binaries are not modified on install.

This commit makes --allow-root the default, and drops the code 
required for it. It also deprecates `spack buildcache preview`, since 
the command made sense only with --allow-root.

As a side effect, Spack no longer depends on binutils for relocation
2023-07-18 18:45:14 +02:00
Massimiliano Culpo
ad1fdcdf48
Pin Spack dev dependencies on RtD (#38950) 2023-07-18 18:37:04 +02:00
Massimiliano Culpo
82aa27f5a5
Fix default construction of locks (#38953)
This fixes a typo introduced in a refactor
2023-07-18 14:36:41 +02:00
Xavier Delaruelle
8c7adbf8f3
modules: add support for conflict in lua modulefile (#36701)
Add support for conflict directives in Lua modulefile like done for Tcl
modulefile.

Note that conflicts are correctly honored on Lmod and Environment
Modules <4.2 only if mutually expressed on both modulefiles that
conflict with each other.

Migrate conflict code from Tcl-specific classes to the common part. Add
tests for Lmod and split the conflict test case in two.

Co-authored-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
2023-07-18 10:24:46 +02:00
Peter Scheibel
10165397da
"spack develop": always pull full history for git repos (#38343) 2023-07-18 09:53:33 +02:00
Dan Lipsa
4831d45852
Decompression: fix naming issues (#37749)
* When using system tools to unpack a .gz file, the input file needs a
  different name than the output file. Normally, we generate this new
  name by stripping off the .gz extension off of the file name.
  This was not sufficient if the file name did not have an extension,
  so we temporarily rename the file in that case.
* When using system tar utility to untar on Windows, we were (erroneously)
  skipping the actual untar step if the filename was lacking a .tar
  extension
* For foo.txz, we were not changing the extension of the decompressed file
  (i.e. we would decompress foo.txz to foo.txz). This did not cause any
  problems, but is confusing, so has been updated such that the output
  filename reflects its decompressed state (i.e. foo.tar).
* Added test for strip_compression_extension
* Update test_native_unpacking to test each archive type with and without
  an extension as part of the file name (i.e. we test "foo.tar.gz", but
  also make sure we decompress properly if it is named "foo").
2023-07-17 14:33:18 -07:00
Harmen Stoppels
f05837a480
Fix wrong StageComposite keep override (#38938)
`Stage(keep=True)` was ignored when put in a composite that doesn't
override the value.
2023-07-17 23:20:24 +02:00
Manuela Kuhn
884b4952af
Fix python import tests (#38928)
Running `spack test run <python package>` resulted in the error
```
'str' object is not callable
```
because the python executable was not set correctly.
2023-07-17 13:19:47 -07:00
Massimiliano Culpo
53ae969aa0
Lock, database and store don't need global configuration on construction (#33495)
Lock objects can now be instantiated independently,
without being tied to the global configuration. The
same is true for database and store objects.

The database __init__ method has been simplified to
take a single lock configuration object. Some common
lock configurations (e.g. NO_LOCK or NO_TIMEOUT) have
been named and are provided as globals.

The use_store context manager keeps the configuration
consistent by pushing and popping an internal scope.
It can also be tuned by passing extra data to set up
e.g. upstreams or anything else that might be related
to the store.
2023-07-17 16:51:04 +02:00
Adam J. Stewart
2b5a7bb4d7
Update new PythonPackage template to prefer --config-settings (#38918) 2023-07-17 08:03:05 -05:00
Peter Scheibel
31431f967a
Environment/depfile: fix bug with Git hash versions (attempt #2) (#37560)
Co-authored-by: Harmen Stoppels <me@harmenstoppels.nl>
2023-07-17 11:17:32 +00:00
Massimiliano Culpo
63b88c4b75
Minimal cleanup of a few tests in test/packaging.py (#38880)
* Minimal cleanup of a few tests in packaging.py

* Use f-strings
2023-07-17 10:36:29 +02:00
Harmen Stoppels
ac5976d17d
Remove unused context manager (#38897) 2023-07-14 18:41:30 +02:00
Rocco Meli
244dfb3a35
Fix issue on cray with super call (#38895) 2023-07-14 10:00:02 +00:00
Tamara Dahlgren
2e9e7ce7c4
Bugfix/spack spec: read and use the environment concretizer:unification option (#38248)
* Bugfix: spack.yaml concretizer:unify needs to be read and used
* Optional: add environment test to ensure configuration scheme is used
* Activate environment in unit tests
  A more proper solution would be to keep
  an environment instance configuration as
  an attribute, but that is a bigger refactor
* Delay evaluation of Environment.unify
* Slightly simplify unit tests

---------

Co-authored-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
2023-07-13 23:43:20 +02:00
Harmen Stoppels
033eb77aa9
spack buildcache push: improve argparse (#38876) 2023-07-13 16:01:09 +02:00
Harmen Stoppels
522d9e260b
mirrors: distinguish between source/binary mirror; simplify schema (#34523)
Allow the following formats:

```yaml
mirrors:
  name: <url>
```

```yaml
mirrors:
  name:
    url: s3://xyz
    access_pair: [x, y]
```

```yaml
mirrors:
  name:
    fetch: http://xyz
    push:
      url: s3://xyz
      access_pair: [x, y]
```

And reserve two new properties to indicate the mirror type (e.g.
mirror.spack.io is a source mirror, not a binary cache)

```yaml
mirrors:
  spack-public:
    source: true
    binary: false
    url: https://mirror.spack.io
```
2023-07-13 11:29:17 +00:00
Massimiliano Culpo
3261889e3a
spack audit: allow skipping version checks from package.py (#28372)
A few packages have version directives evaluated
within if statements, conditional on the value of
`platform.platform()`.

Sometimes there are no cases for e.g. platform=darwin and that
causes a lot of spurious failures with version existence
audits.

This PR allows expressing conditions to skip version
existence checks in audits and avoid these spurious reports.
2023-07-13 06:47:47 -04:00
Harmen Stoppels
161b30a32f
Add type hints to spack.installer (#38872) 2023-07-13 10:41:19 +00:00
Adam J. Stewart
b67f1f395b
Add missing space in error msg (#38863) 2023-07-13 10:24:02 +02:00
Adam J. Stewart
bb7f437bf5
Standardize subcommand help strings (#38804)
### Rationale

While working on #29549, I noticed a lot of inconsistencies in our argparse help messages. This is important for fish where these help messages end up as descriptions in the tab completion menu. See https://github.com/spack/spack/pull/29549#issuecomment-1627596477 for some examples of longer or more stylized help messages.

### Implementation

This PR makes the following changes:

- [x] help messages start with a lowercase letter.
- [x] Help messages do not end with a period
- [x] the first line of a help message is short and simple

    longer text is separated by an empty line
- [x] "help messages do not use triple quotes" 

    """(except docstrings)"""
- [x] Parentheses not needed for string concatenation inside function call
- [x] Remove "..." "..." string concatenation leftover from black reformatting
- [x] Remove Sphinx argument docs from help messages

The first 2 choices aren't very controversial, and are designed to match the syntax of the `--help` flag automatically added by argparse. The 3rd choice is more up for debate, and is designed to match our package/module docstrings. The 4th choice is designed to avoid excessive newline characters and indentation. We may actually want to go even further and disallow docstrings altogether.

### Alternatives

Choice 3 in particular has a lot of alternatives. My goal is solely to ensure that fish tab completion looks reasonable. Alternatives include:

1. Get rid of long help messages, only allow short simple messages
2. Move longer help messages to epilog
3. Separate by 2 newline characters instead of 1
4. Separate by period instead of newline. First sentence goes into tab completion description

The number of commands with long help text is actually rather small, and is mostly relegated to `spack ci` and `spack buildcache`. So 1 isn't actually as ridiculous as it sounds.

Let me know if there are any other standardizations or alternatives you would like to suggest.
2023-07-13 00:18:23 -07:00
Jonathon Anderson
90208da8a5
containers: retain shallow git data (#37734) 2023-07-12 21:03:10 +00:00
Michael Fink
c8026c3c87
Add path to MPI executables to ^mpi dependents (#35758) 2023-07-12 13:58:43 -05:00
Vicente Bolea
37ef31dc22
vtk-m: correct cuda_arch variant behavior (#38697)
Co-authored-by: eugeneswalker <eugenesunsetwalker@gmail.com>
2023-07-12 14:34:50 +02:00
Michael Kuhn
d5d0b8821c
installer: Improve status reporting (#37903)
Refactor `TermTitle` into `InstallStatus` and use it to show progress
information both in the terminal title as well as inline. This also
turns on the terminal title status by default.

The inline output will look like the following after this change:
```
==> Installing m4-1.4.19-w2fxrpuz64zdq63woprqfxxzc3tzu7p3 [4/4]
```
2023-07-12 08:54:45 +02:00
Todd Gamblin
757f8ae59c
find: add --hashes shortcut for piping to other commands (#38663)
People frequently ask us how to pipe `spack find` output to other commands, and we tell
them to do things like this:

```console
$ spack find --format "/{hash}" | spack uninstall -ay
```

Sometimes users don't know about hash references and come up with potentially ambiguous
formulations like this:

```console
spack find --format {name}@{version}%{compiler} | spack uninstall -ay
```

Since this is a common enough thing to want to do, and to make it more obvious how, this
PR adds a `-H` / `--hashes` as a shortcut, so you can now just do:

```console
spack find -H | spack uninstall -ay
```
2023-07-10 09:43:37 +02:00
Jonathon Anderson
db879a5679
ci: Fix broken SPACK_CHECKOUT_VERSION (#38778) 2023-07-09 12:37:36 -07:00
Harmen Stoppels
374fda1063
Don’t call spec.format in Database._get_matching_spec_key (#38792)
`"%s" % spec` formats the spec with deps included, which produces sometimes KBs
of data and is slow to run in pure Python. It can delay otherwise very short-lived
read/write locks on the database.

Discovered in #38762 where profile output showed about 2 seconds is spent in
`spec.format`, which is significant overhead when using multiprocessing to install
from binary cache in parallel (installation often takes <5s for small packages). With
this change, `spec.format` no longer shows up in profile output.

(This line hasn't changed since Spack v0.9 ;p)

* move format() call to custom NoSuchSpecError exception
* add a comment saying why, so we can eventually change `Spec.__str__`
2023-07-09 11:27:38 -04:00
Massimiliano Culpo
6958b49c2f
Remove "node_compiler" from the list of unknown atoms (#38753) 2023-07-07 13:19:53 +02:00
Harmen Stoppels
a1d33e97ec
Fix multiple quadratic complexity issues in environments (#38771)
1. Fix O(n^2) iteration in `_get_overwrite_specs`
2. Early exit `get_by_hash` on full hash
3. Fix O(n^2) double lookup in `all_matching_specs` with hashes
4. Fix some legibility issues
2023-07-07 10:51:58 +00:00
Massimiliano Culpo
ca9b52bbc5
Prevent "spack external find" to error out on wrong permissions (#38755)
fixes #38733
2023-07-07 12:05:32 +02:00
Andrey Parfenov
ae00d7c358
add info about spack env from spack-configs for oneAPI build tools (#38751)
Signed-off-by: Andrey Parfenov <andrey.parfenov@intel.com>
2023-07-07 03:47:54 +00:00