summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)AuthorFilesLines
2024-11-11mirrors: allow username/password as environment variables (#46549)kwryankrattiger9-57/+520
`spack mirror add` and `set` now have flags `--oci-password-variable`, `--oci-password-variable`, `--s3-access-key-id-variable`, `--s3-access-key-secret-variable`, `--s3-access-token-variable`, which allows users to specify an environment variable in which a username or password is stored. Storing plain text passwords in config files is considered deprecated. The schema for mirrors.yaml has changed, notably the `access_pair` list is generally replaced with a dictionary of `{id: ..., secret_variable: ...}` or `{id_variable: ..., secret_variable: ...}`.
2024-11-11solver: avoid parsing specs in setupTodd Gamblin5-16/+20
- [x] Get rid of a call to `parser.quote_if_needed()` during solver setup, which introduces a circular import and also isn't necessary. - [x] Rename `spack.variant.Value` to `spack.variant.ConditionalValue`, as it is *only* used for conditional values. This makes it much easier to understand some of the logic for variant definitions. Co-authored-by: Harmen Stoppels <me@harmenstoppels.nl> Signed-off-by: Todd Gamblin <tgamblin@llnl.gov>
2024-11-11imports: move `conditional` to `directives.py`Todd Gamblin3-15/+13
`conditional()`, which defines conditional variant values, and the other ways to declare variant values should probably be in a layer above `spack.variant`. This does the simple thing and moves *just* `conditional()` to `spack.directives` to avoid a circular import. We can revisit the public variant interface later, when we split packages from core. Co-authored-by: Harmen Stoppels <me@harmenstoppels.nl> Signed-off-by: Todd Gamblin <tgamblin@llnl.gov>
2024-11-11filesystem.py find: return directories and improve performance (#47537)Harmen Stoppels2-57/+49
2024-11-09Revert "fix patched dependencies across repositories (#42463)" (#47519)Todd Gamblin5-22/+12
This reverts commit da1d533877f90610571b72f070c01e13b9729108.
2024-11-08Fix style checks on develop (#47518)Massimiliano Culpo1-1/+2
`mypy` checks have been accidentally broken by #47213
2024-11-08fix patched dependencies across repositories (#42463)Greg Becker5-12/+22
Currently, if a package has a dependency from another repository and patches it, generation of the patch cache will fail. Concretization succeeds if a fixed patch cache is in place. - [x] don't assume that patched dependencies are in the same repo when indexing - [x] add some test fixtures to support multi-repo tests. --------- Signed-off-by: Todd Gamblin <tgamblin@llnl.gov> Co-authored-by: Todd Gamblin <tgamblin@llnl.gov>
2024-11-08`spack.compiler`/`spack.util.libc`: add caching (#47213)Harmen Stoppels7-37/+227
* spack.compiler: cache output * compute libc from the dynamic linker at most once per spack process * wrap compiler cache entry in class, add type hints * test compiler caching * ensure tests do not populate user cache, and fix 2 tests * avoid recursion: cache lookup -> compute key -> cflags -> real_version -> cache lookup * allow compiler execution in test that depends on get_real_version
2024-11-08llnl.util.filesystem: multiple entrypoints and max_depth (#47495)Harmen Stoppels6-111/+455
If a package `foo` doesn't implement `libs`, the default was to search recursively for `libfoo` whenever asking for `spec[foo].libs` (this also happens automatically if a package includes `foo` as a link dependency). This can lead to some strange behavior: 1. A package that is normally used as a build dependency (e.g. `cmake` at one point) is referenced like `depends_on(cmake)` which leads to a fully-recursive search for `libcmake` (this can take "forever" when CMake is registered as an external with a prefix like `/usr`, particularly on NFS mounts). 2. A similar hang can occur if a package is registered as an external with an incorrect prefix - [x] Update the default library search to stop after a maximum depth (by default, search the root prefix and each directory in it, but no lower). - [x] The following is a list of known changes to `find` compared to `develop`: 1. Matching directories are no longer returned -- `find` consistently only finds non-dirs, even at `max_depth` 2. Symlinked directories are followed (needed to support max_depth) 3. `find(..., "dir/*.txt")` is allowed, for finding files inside certain dirs. These "complex" patterns are delegated to `glob`, like they are on `develop`. 4. `root` and `files` arguments both support generic sequences, and `root` allows both `str` and `path` types. This allows us to specify multiple entry points to `find`. --------- Co-authored-by: Peter Scheibel <scheibel1@llnl.gov>
2024-11-08Add missing imports (#47496)Harmen Stoppels3-0/+5
2024-11-08 `spack env track` command (#41897)Alec Scott3-51/+290
This PR adds a sub-command to `spack env` (`track`) which allows users to add/link anonymous environments into their installation as named environments. This allows users to more easily track their installed packages and the environments they're dependencies of. For example, with the addition of #41731 it's now easier to remove all packages not required by any environments with, ``` spack gc -bE ``` #### Usage ``` spack env track /path/to/env ==> Linked environment in /path/to/env ==> You can activate this environment with: ==> spack env activate env ``` By default `track /path/to/env` will use the last directory in the path as the name of the environment. However users may customize the name of the linked environment with `-n | --name`. Shown below. ``` spack env track /path/to/env --name foo ==> Tracking environment in /path/to/env ==> You can activate this environment with: ==> spack env activate foo ``` When removing a linked environment, Spack will remove the link to the environment but will keep the structure of the environment within the directory. This will allow users to remove a linked environment from their installation without deleting it from a shared repository. There is a `spack env untrack` command that can be used to *only* untrack a tracked environment -- it will fail if it is used on a managed environment. Users can also use `spack env remove` to untrack an environment. This allows users to continue to share environments in git repositories while also having the dependencies of those environments be remembered by Spack. --------- Co-authored-by: Todd Gamblin <tgamblin@llnl.gov>
2024-11-07Revert "filesystem.py: add `max_depth` argument to `find` (#41945)"Harmen Stoppels3-290/+75
This reverts commit 38c8069ab42f44aa9f4779968937fc6842dc2109.
2024-11-07Revert "llnl.util.filesystem.find: restore old error handling (#47463)"Harmen Stoppels1-11/+20
This reverts commit a31c525778773b8c6a6fc35617454d954a05d74d.
2024-11-07Revert "`llnl.util.filesystem.find`: multiple entrypoints (#47436)"Harmen Stoppels4-178/+130
This reverts commit 73219e4b02e6561bbeef379081f63efb0dc78817.
2024-11-07spec.py: fix comparison with multivalued variants (#47485)Harmen Stoppels2-1/+5
2024-11-06`llnl.util.filesystem.find`: multiple entrypoints (#47436)Harmen Stoppels4-130/+178
You can now provide multiple roots to a single `find()` call and all of them will be searched. The roots can overlap (e.g. can be parents of one another). This also adds a library function for taking a set of regular expression patterns and creating a single OR expression (and that library function is used in `find` to improve its performance).
2024-11-06Fix `spack -c <override>` when env active (#47403)Massimiliano Culpo3-45/+40
Set command line scopes last in _main, so they are higher scopes Restore the global configuration in a spawned process by inspecting the result of ctx.get_start_method() Add the ability to pass a mp.context to PackageInstallContext. Add shell-tests to check overriding the configuration: - Using both -c and -C from command line - With and without an environment active
2024-11-06Fix various bootstrap/concretizer import issues (#47467)Harmen Stoppels4-9/+10
2024-11-06llnl.util.filesystem.find: restore old error handling (#47463)Harmen Stoppels1-20/+11
2024-11-06Feature: Allow variants to propagate if not available in source pkg (#42931)Richarda Butler7-35/+332
Variants can now be propagated from a dependent package to (transitive) dependencies, even if the source or transitive dependencies have the propagated variants. For example, here `zlib` doesn't have a `guile` variant, but `gmake` does: ``` $ spack spec zlib++guile - zlib@1.3%gcc@12.2.0+optimize+pic+shared build_system=makefile arch=linux-rhel8-broadwell - ^gcc-runtime@12.2.0%gcc@12.2.0 build_system=generic arch=linux-rhel8-broadwell - ^gmake@4.4.1%gcc@12.2.0+guile build_system=generic arch=linux-rhel8-broadwell ``` Adding this property has some strange ramifications for `satisfies()`. In particular: * The abstract specs `pkg++variant` and `pkg+variant` do not intersect, because `+variant` implies that `pkg` *has* the variant, but `++variant` does not. * This means that `spec.satisfies("++foo")` is `True` if: * for concrete specs: `spec` and its dependencies all have `foo` set if it exists * for abstract specs: no dependency of `spec` has `~foo` (i.e. no dependency contradicts `++foo`). * This also means that `Spec("++foo").satisfies("+foo")` is `False` -- we only know after concretization. The `satisfies()` semantics may be surprising, but this is the cost of introducing non-subset semantics (which are more useful than proper subsets here). - [x] Change checks for variants - [x] Resolve conflicts - [x] Add tests - [x] Add documentation --------- Co-authored-by: Gregory Becker <becker33@llnl.gov> Co-authored-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
2024-11-05libc.py: detect glibc also in chinese locale (#47434)Harmen Stoppels1-6/+18
2024-11-05Revert "Ci generate on change (#47318)" (#47431)Harmen Stoppels2-109/+27
This reverts commit 1462c357619fedf7354bc60f9178b2199258ebd2.
2024-11-05spack.concretize: add type-hints, remove kwargs (#47382)Massimiliano Culpo5-124/+52
Also remove find_spec, which was used by the old concretizer. Currently, it seems to be used only in tests.
2024-11-04filesystem.py: add `max_depth` argument to `find` (#41945)Peter Scheibel3-75/+290
* `find(..., max_depth=...)` can be used to control how many directories at most to descend into below the starting point * `find` now enters every unique (symlinked) directory once at the lowest depth * `find` is now repeatable: it traverses the directory tree in a deterministic order
2024-11-04cc: parse RPATHs when in `ld` modeTodd Gamblin2-21/+85
In the pure `ld` case, we weren't actually parsing `RPATH` arguments separately as we do for `ccld`. Fix this by adding *another* nested case statement for raw `RPATH` parsing. There are now 3 places where we deal with `-rpath` and friends, but I don't see a great way to unify them, as `-Wl,`, `-Xlinker`, and raw `-rpath` arguments are all ever so slightly different. Also, this Fixes ordering of assertions to make `pytest` diffs more intelligible. The meaning of `+` and `-` in diffs changed in `pytest` 6.0 and the "preferred" order for assertions became `assert actual == expected` instead of the other way around. Signed-off-by: Todd Gamblin <tgamblin@llnl.gov>
2024-11-04`cc`: simplify ordered list handlingTodd Gamblin1-114/+65
`cc` divides most paths up into system paths, spack managed paths, and other paths. This gets really repetitive and makes the code hard to read. Simplify the script by adding some functions to do most of the redundant work for us. Signed-off-by: Todd Gamblin <tgamblin@llnl.gov>
2024-11-04Times spec building and timing to public concretizer API (#47310)John Gouwar1-4/+15
This PR has two small contributions: - It adds another phase to the timer for concrectization, "construct_specs", to actually see the time the concretizer spends interpreting the `clingo` output to build the Python object for a concretized spec. - It adds the method `Solver.solve_with_stats` to expose the timers that were already in the concretizer to the public solver API. `Solver.solve` just becomes a special case of `Solver.solve_with_stats` that throws away the timing output (which is what it was already doing). These changes will make it easier to benchmark concretizer performance and provide a more complete picture of the time spent in the concretizer by including the time spent interpreting clingo output.
2024-11-04packaging_guide.rst: explain forward and backward compat before the less ↵Harmen Stoppels1-28/+63
common cases (#47402) The idea is to go from most to least used: backward compat -> forward compat -> pinning on major or major.minor version -> pinning specific, concrete versions. Further, the following ```python # backward compatibility with Python depends_on("python@3.8:") depends_on("python@3.9:", when="@1.2:") depends_on("python@3.10:", when="@1.4:") # forward compatibility with Python depends_on("python@:3.12", when="@:1.10") depends_on("python@:3.13", when="@:1.12") depends_on("python@:3.14") ``` is better than disjoint when ranges causing repetition of the rules on dependencies, and requiring frequent editing of existing lines after new releases are done: ```python depends_on("python@3.8:3.12", when="@:1.1") depends_on("python@3.9:3.12", when="@1.2:1.3") depends_on("python@3.10:3.12", when="@1.4:1.10") depends_on("python@3.10:3.13", when="@1.11:1.12") depends_on("python@3.10:3.14", when="@1.13:")
2024-11-03Specs: propagated variants affect `==` equality (#47376)Massimiliano Culpo3-15/+42
This PR changes the semantic of == for spec so that: hdf5++mpi == hdf5+mpi won't hold true anymore. It also changes the constrain semantic, so that a non-propagating variant always override a propagating variant. This means: (hdf5++mpi).constrain(hdf5+mpi) -> hdf5+mpi Before we had a very weird semantic, that was supposed to be tested by unit-tests: (libelf++debug).constrain(libelf+debug+foo) -> libelf++debug++foo This semantic has been dropped, as it was never really tested due to the == bug.
2024-11-02Remove ignored config:install_missing_compilers from unit tests (#47357)Tamara Dahlgren1-18/+16
2024-11-02Rework the schema for reusing environments (#47364)Massimiliano Culpo3-22/+13
Currently, the schema reads: from: - type: environment: path_or_name but this can't be extended easily to other types, e.g. to buildcaches, without duplicating the extension keys. Use instead: from: - type: environment path: path_or_name
2024-11-01build(deps): bump python-levenshtein in /lib/spack/docs (#47372)dependabot[bot]1-1/+1
Bumps [python-levenshtein](https://github.com/rapidfuzz/python-Levenshtein) from 0.26.0 to 0.26.1. - [Release notes](https://github.com/rapidfuzz/python-Levenshtein/releases) - [Changelog](https://github.com/rapidfuzz/python-Levenshtein/blob/main/HISTORY.md) - [Commits](https://github.com/rapidfuzz/python-Levenshtein/compare/v0.26.0...v0.26.1) --- updated-dependencies: - dependency-name: python-levenshtein dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-11-01parse_specs: unify specs based on concretizer:unify (#44843)Greg Becker9-125/+237
Currently, the `concretizer:unify:` config option only affects environments. With this PR, it now affects any group of specs given to a command using the `parse_specs(*, concretize=True)` interface. - [x] implementation in `parse_specs` - [x] tests - [x] ensure all commands that accept multiple specs and concretize use `parse_specs` interface --------- Co-authored-by: Todd Gamblin <tgamblin@llnl.gov> Signed-off-by: Todd Gamblin <tgamblin@llnl.gov>
2024-11-01Ci generate on change (#47318)kwryankrattiger2-27/+109
* don't concretize in CI if changed packages are not in stacks Signed-off-by: Todd Gamblin <tgamblin@llnl.gov> * Generate noop job when no specs to rebuild due to untouched pruning * Add test to verify skipping generate creates a noop job * Changed debug for early exit --------- Signed-off-by: Todd Gamblin <tgamblin@llnl.gov> Co-authored-by: Todd Gamblin <tgamblin@llnl.gov>
2024-11-01Fix pickle round-trip of specs propagating variants (#47351)Massimiliano Culpo3-14/+50
This changes `Spec` serialization to include information about propagation for abstract specs. This was previously not included in the JSON representation for abstract specs, and couldn't be stored. Now, there is a separate `propagate` dictionary alongside the `parameters` dictionary. This isn't beautiful, but when we bump the spec version for Spack `v0.24`, we can clean up this and other aspects of the schema.
2024-11-01build(deps): bump docutils from 0.20.1 to 0.21.2 in /lib/spack/docs (#45592)dependabot[bot]1-1/+1
Bumps [docutils](https://docutils.sourceforge.io) from 0.20.1 to 0.21.2. --- updated-dependencies: - dependency-name: docutils dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-10-31database.py: remove process unsafe update_explicit (#47358)Harmen Stoppels3-24/+7
Fixes an issue reported where `spack env depfile` + `make -j` would non-deterministically refuse to mark all environment roots explicit. `update_explicit` had the pattern ```python rec = self._data[key] with self.write_transaction(): rec.explicit = explicit ``` but `write_transaction` may reinitialize `self._data`, meaning that mutating `rec` won't mutate `self._data`, and the changes won't be persisted. Instead, use `mark` which has a correct implementation. Also avoids the essentially incorrect early return in `update_explicit` which is a pattern I don't think belongs in database.py: it branches on possibly stale data to realize there is nothing to change, but in reality it requires a write transaction to know that for a fact, but that would defeat the purpose. So, leave this optimization to the call site.
2024-10-31Concretize reuse: reuse specs from environment (#45139)kwryankrattiger7-13/+279
The already concrete specs in an environment are now among the reusable specs for the concretizer. This includes concrete specs from all include_concrete environments. In addition to this change to the default reuse, `environment` is added as a reuse type for the concretizer config. This allows users to specify: spack: concretizer: # Reuse from this environment (including included concrete) but not elsewhere reuse: from: - type: environment # or reuse from only my_env included environment reuse: from: - type: environment: my_env # or reuse from everywhere reuse: true If reuse is specified from a specific environment, only specs from that environment will be reused. If the reused environment is not specified via include_concrete, the concrete specs will be retried at concretization time to be reused. Signed-off-by: Ryan Krattiger <ryan.krattiger@kitware.com> Co-authored-by: Gregory Becker <becker33@llnl.gov>
2024-10-31Docs: remove reference to pyspack (#47346)Adam J. Stewart1-4/+0
2024-10-30hooks: run in clear, fixed order (#47329)Harmen Stoppels2-32/+25
Currently the order in which hooks are run is arbitrary. This can be fixed by sorted(list_modules(...)) but I think it is much more clear to just have a static list. Hooks are not extensible other than modifying Spack code, which means it's unlikely people maintain custom hooks since they'd have to fork Spack. And if they fork Spack, they might as well add an entry to the list when they're continuously rebasing.
2024-10-30types: remove singleton union in globals (#47282)Harmen Stoppels4-29/+14
2024-10-30add std_pip_args global to the audit list (#47320)Harmen Stoppels1-1/+1
2024-10-30Spec.__str__: use full hash (#47322)Harmen Stoppels1-1/+1
The idea is that `spack -e env add ./concrete-spec.json` would list the full hash in the specs, so that (a) it's not ambiguous and (b) it could in principle results in constant time lookup instead of linear time substring match in large build caches.
2024-10-30Spec.dependencies: allow to filter on virtuals (#47284)Massimiliano Culpo3-49/+96
Signed-off-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
2024-10-30Fix malformed RST link in documentation (#47309)Alex Hedges1-1/+1
2024-10-29llnl.util.lang: add classes to help with deprecations (#47279)Massimiliano Culpo2-0/+92
* Add a descriptor to have a class level constant This descriptor helps intercept places where we set a value on instances. It does not really behave like "const" in C-like languages, but is the simplest implementation that might still be useful. * Add a descriptor to deprecate properties/attributes of an object This descriptor is used as a base class. Derived classes may implement a factory to return an adaptor to the attribute being deprecated. The descriptor can either warn, or raise an error, when usage of the deprecated attribute is intercepted. --------- Co-authored-by: Harmen Stoppels <me@harmenstoppels.nl>
2024-10-29bootstrap: do not consider source when metadata file missing (#47278)Harmen Stoppels1-3/+6
2024-10-29std_meson_args: deprecate (#47259)Harmen Stoppels1-1/+1
2024-10-29builder.py: builder_cls should be associated to spack.pkg module (#47269)Harmen Stoppels2-5/+14
2024-10-29directives_meta.py: use startswith to test module part of spack.pkg (#47270)Harmen Stoppels1-1/+2