Commit graph

4441 commits

Author SHA1 Message Date
Todd Gamblin
49ac3471cf concretizer: consolidate handling of virtuals into spec_clauses 2021-01-04 14:51:10 -08:00
Todd Gamblin
fa411e7c07 concretizer: make _condtion_id_counter an iterator 2021-01-04 14:51:10 -08:00
Todd Gamblin
3cc89726ee concretizer: more detailed section headers in concretize.lp 2021-01-04 14:51:10 -08:00
Massimiliano Culpo
cfd0ff52d1
ci: fix issue with latest sphinx (#20661) 2021-01-04 22:10:49 +01:00
Todd Gamblin
16ce207481
bugfix: infinite loop when building a set from incomplete specs (#20649)
This code in `SpecBuilder.build_specs()` introduced in #20203, can loop
seemingly interminably for very large specs:

```python
set([spec.root for spec in self._specs.values()])
```

It's deceptive, because it seems like there must be an issue with
`spec.root`, but that works fine. It's building the set afterwards that
takes forever, at least on `r-rminer`. Currently if you try running
`spack solve r-rminer`, it loops infinitely and spins up your fan.

The issue (I think) is that the spec is not yet complete when this is
run, and something is going wrong when constructing and comparing so many
values produced by `_cmp_key()`. We can investigate the efficiency of
`_cmp_key()` separately, but for now, the fix is:

```python
roots = [spec.root for spec in self._specs.values()]
roots = dict((id(r), r) for r in roots)
```

We know the specs in `self._specs` are distinct (they just came out of
the solver), so we can just use their `id()` to unique them here. This
gets rid of the infinite loop.
2021-01-04 10:28:16 +01:00
Todd Gamblin
a8ccb8e116 copyrights: update all files with license headers for 2021
- [x] add `concretize.lp`, `spack.yaml`, etc. to licensed files
- [x] update all licensed files to say 2013-2021 using
      `spack license update-copyright-year`
- [x] appease mypy with some additions to package.py that needed
      for oneapi.py
2021-01-02 12:12:00 -08:00
Todd Gamblin
78f39bdfee commands: add spack license update-copyright-year
This adds a new subcommand to `spack license` that automatically updates
the copyright year in files that should have a license header.

- [x] add `spack license update-copyright-year` command
- [x] add test
2021-01-02 12:12:00 -08:00
Adam J. Stewart
0d95fd6d52
extends: add type kwarg (#20045)
* extends: add type kwarg

* Flake8 fix
2020-12-30 11:09:58 -06:00
Massimiliano Culpo
eca1dd8738 concretizer: generate facts for externals
Generate only facts for external specs. Substitute the
use of already grounded rules with non-grounded rules
in concretize.lp
2020-12-29 23:51:20 -08:00
Adam J. Stewart
05f8e08067
PythonPackage: add pypi attribute to infer homepage/url/list_url (#17587) 2020-12-29 09:03:08 +01:00
Massimiliano Culpo
60f4621a73
archspec: fixed a typo in the vendored library (#20584) 2020-12-28 12:09:02 -06:00
Omri Mor
cfbe3aa056
Remove more variables from build environment (#20156)
GCC looks for included files based on several env vars.
Remove C_INCLUDE_PATH, CPLUS_INCLUDE_PATH, and OBJC_INCLUDE_PATH
from the build environment to ensure it's clean and prevent
accidental clobbering.
2020-12-24 16:48:53 -06:00
Greg Becker
6947951aaf
bugfix: do not write empty default dicts/lists in envs (#20526)
Environment yaml files should not have default values written to them.

To accomplish this, we change the validator to not add the default values to yaml. We rely on the code to set defaults for all values (and use defaulting getters like dict.get(key, default)).

Includes regression test.
2020-12-23 20:29:38 -08:00
Massimiliano Culpo
91e86f9d0d concretizer: remove vestigial code and comment 2020-12-23 16:40:47 -08:00
Todd Gamblin
1571d6240b style: ensure that all packages pass spack style -a
- fix trailing whitespace and other issues uncovered by better flake8
  checking.

- fix extra whitespace printed by `spack style` command
2020-12-23 16:17:54 -08:00
Robert Cohn
0bb18d8a38
Add Intel oneAPI packages (#20411)
This creates a set of packages which all use the same script to install
components of Intel oneAPI. This includes:

* An inheritable IntelOneApiPackage which knows how to invoke the
  installation script based on which components are requested
* For components which include headers/libraries, an inheritable
  IntelOneApiLibraryPackage is provided to locate them
* Individual packages for DAL, DNN, TBB, etc.
* A package for the Intel oneAPI compilers (icx/ifx). This also includes
  icc/ifortran but these are not currently detected in this PR
2020-12-23 15:39:40 -08:00
Tom Scogland
857749a9ba
add mypy to style checks; rename spack flake8 to spack style (#20384)
I lost my mind a bit after getting the completion stuff working and
decided to get Mypy working for spack as well. This adds a 
`.mypy.ini` that checks all of the spack and llnl modules, though
not yet packages, and fixes all of the identified missing types and
type issues for the spack library.

In addition to these changes, this includes:

* rename `spack flake8` to `spack style`

Aliases flake8 to style, and just runs flake8 as before, but with
a warning.  The style command runs both `flake8` and `mypy`,
in sequence. Added --no-<tool> options to turn off one or the
other, they are on by default.  Fixed two issues caught by the tools.

* stub typing module for python2.x

We don't support typing in Spack for python 2.x. To allow 2.x to
support `import typing` and `from typing import ...` without a
try/except dance to support old versions, this adds a stub module
*just* for python 2.x.  Doing it this way means we can only reliably
use all type hints in python3.7+, and mypi.ini has been updated to
reflect that.

* add non-default black check to spack style

This is a first step to requiring black.  It doesn't enforce it by
default, but it will check it if requested.  Currently enforcing the
line length of 79 since that's what flake8 requires, but it's a bit odd
for a black formatted project to be quite that narrow.  All settings are
in the style command since spack has no pyproject.toml and I don't
want to add one until more discussion happens. Also re-format
`style.py` since it no longer passed the black style check
with the new length.

* use style check in github action

Update the style and docs action to use `spack style`, adding in mypy
and black to the action even if it isn't running black right now.
2020-12-22 21:39:10 -08:00
Todd Gamblin
5f2a821183
concretizer: refactor conditional rules to be less repetitious (#20507)
We have to repeat all the spec attributes in a number of places in
`concretize.lp`, and Spack has a fair number of spec attributes. If we
instead add some rules up front that establish equivalencies like this:

```
    node(Package) :- attr("node", Package).
    attr("node", Package) :- node(Package).

    version(Package, Version) :- attr("version", Package, Version).
    attr("version", Package, Version) :- version(Package, Version).
```

We can rewrite most of the repetitive conditions with `attr` and repeat
only for each arity (there are only 3 arities for spec attributes so far)
as opposed to each spec attribute. This makes the logic easier to read
and the rules easier to follow.

Co-authored-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
2020-12-22 19:49:36 +01:00
Tom Scogland
c1e4f3e131
Refactor flake8 handling and tool compatibility (#20376)
This PR does three related things to try to improve developer tooling quality of life:

1. Adds new options to `.flake8` so it applies the rules of both `.flake8` and `.flake_package` based on paths in the repository.
2. Adds a re-factoring of the `spack flake8` logic into a flake8 plugin so using flake8 directly, or through editor or language server integration, only reports errors that `spack flake8` would.
3. Allows star import of `spack.pkgkit` in packages, since this is now the thing that needs to be imported for completion to work correctly in package files, it's nice to be able to do that.

I'm sorely tempted to sed over the whole repository and put `from spack.pkgkit import *` in every package, but at least being allowed to do it on a per-package basis helps.

As an example of what the result of this is:

```
~/Workspace/Projects/spack/spack develop* ⇣
❯ flake8 --format=pylint ./var/spack/repos/builtin/packages/kripke/package.py
./var/spack/repos/builtin/packages/kripke/package.py:6: [F403] 'from spack.pkgkit import *' used; unable to detect undefined names
./var/spack/repos/builtin/packages/kripke/package.py:25: [E501] line too long (88 > 79 characters)

~/Workspace/Projects/spack/spack refactor-flake8*
1 ❯ flake8 --format=spack ./var/spack/repos/builtin/packages/kripke/package.py

~/Workspace/Projects/spack/spack refactor-flake8*
❯ flake8 ./var/spack/repos/builtin/packages/kripke/package.py
```

* qa/flake8: update .flake8, spack formatter plugin

Adds:
* Modern flake8 settings for per-path/glob error ignores, allows
  packages to use the same `.flake8` as the rest of spack
* A spack formatter plugin to flake8 that implements the behavior of
  `spack flake8` for direct invocations.  Makes integration with
  developer tooling nicer, linting with flake8 reports only errors that
  `spack flake8` would report.  Using pyls and pyls-flake8, or any other
  non-format-dependent flake8 integration, now works with spack's rules.

* qa/flake8: allow star import of spack.pkgkit

To get working completion of directives and spack components it's
necessary to import the contents of spack.pkgkit.  At the moment doing
this makes flake8 displeased.  For now, allow spack.pkgkit and spack
both, next step is to ban spack * and require spack.pkgkit *.

* first cut at refactoring spack flake8

This version still copies all of the files to be checked as befire, and
some other things that probably aren't necessary, but it relies on the
spack formatter plugin to implement the ignore logic.

* keep flake8 from rejecting itself

* remove separate packages flake8 config

* fix failures from too many files

I ran into this in the PR converting pkgkit to std.  The solution in
that branch does not work in all cases as it turns out, and all the
workarounds I tried to use generated configs to get a single invocation
of flake8 with a filename optoion to work failed.  It's an astonishingly
frustrating config option.

Regardless, this removes all temporary file creation from the command
and relies on the plugin instead.  To work around the huge number of
files in spack and still allow the command to control what gets checked,
it scans files in batches of 100.  This is a completely arbitrary number
but was chosen to be safely under common line-length limits.  One
side-effect of this is that every 100 files the command will produce
output, rather than only at the end, which doesn't seem like a terrible
thing.
2020-12-22 09:28:46 -08:00
Massimiliano Culpo
cde6ffe369 concretizer: optimize loop on compiler version
Similar to the optimization on platform
2020-12-22 00:02:54 -08:00
Massimiliano Culpo
635c6c29fa concretizer: optimized loop on node platforms
We can speed-up the computation by avoiding a
double loop in a cardinality constraint and
enforcing the rule instead as an integrity
constraint.
2020-12-22 00:02:54 -08:00
Massimiliano Culpo
19fba3ae06 concretizer: fix failing unit tests 2020-12-20 07:00:46 -08:00
Massimiliano Culpo
72569a0198 concretizer: emit facts for integrity constraints 2020-12-20 07:00:46 -08:00
Massimiliano Culpo
e644255770 concretizer: emit facts for constraints on imposed dependencies 2020-12-20 07:00:46 -08:00
Massimiliano Culpo
d8dc4b141e concretizer: avoid redundant grounding on dependency types 2020-12-20 07:00:46 -08:00
Todd Gamblin
bb78a73ed3 concretizer: move conditional dependency logic into concretize.lp
Continuing to convert everything in `asp.py` into facts, make the
generation of ground rules for conditional dependencies use facts, and
move the semantics into `concretize.lp`.

This is probably the most complex logic in Spack, as dependencies can be
conditional on anything, and we need conditional ASP rules to accumulate
and map all the dependency conditions to spec attributes.

The logic looks complicated, but essentially it accumulates any
constraints associated with particular conditions into a fact associated
with the condition by id. Then, if *any* condition id's fact is True, we
trigger the dependency.

This simplifies the way `declared_dependency()` works -- the dependency
is now declared regardless of whether it is conditional, and the
conditions are handled by `dependency_condition()` facts.
2020-12-20 07:00:46 -08:00
Todd Gamblin
d7fe2d5678 concretizer: spec_clauses should traverse dependencies
There are currently no places where we do not want to traverse
dependencies in `spec_clauses()`, so simplify the logic by consolidating
`spec_traverse_clauses()` with `spec_clauses()`.
2020-12-20 07:00:46 -08:00
Todd Gamblin
87a9e1c951 concretizer: pull _develop_specs_from_env out of main setup loop 2020-12-20 07:00:46 -08:00
Todd Gamblin
950fb0948b concretizer: add #defined statements to avoid warnings.
`version_satisfies/2` and `node_compiler_version_satisfies/3` are
generated but need `#defined` directives to avoid " info: atom does not
occur in any rule head:" warnings.
2020-12-20 07:00:46 -08:00
Massimiliano Culpo
4901728c5b
asp: memoize the list of all target_specs to speed-up setup phase (#20473)
* asp: memoize the list of all target_specs to speed-up setup phase

* asp: memoize using a cache per solver object
2020-12-19 07:07:22 -08:00
Scott Wittenburg
594512bdb3
ci: fixes for compiler bootstrapping (#17563)
This PR addresses a number of issues related to compiler bootstrapping.

Specifically:
1. Collect compilers to be bootstrapped while queueing in installer
Compiler tasks currently have an incomplete list in their task.dependents,
making those packages fail to install as they think they have not all their
dependencies installed. This PR collects the dependents and sets them on
compiler tasks.

2. allow boostrapped compilers to back off target
Bootstrapped compilers may be built with a compiler that doesn't support
the target used by the rest of the spec.  Allow them to build with less
aggressive target optimization settings.

3. Support for target ranges
Backing off the target necessitates computing target ranges, so make Spack
handle those properly.  Notably, this adds an intersection method for target
ranges and fixes the way ranges are satisfied and constrained on Spec objects.

This PR also:
- adds testing
- improves concretizer handling of target ranges

Co-authored-by: Harmen Stoppels <harmenstoppels@gmail.com>
Co-authored-by: Gregory Becker <becker33@llnl.gov>
Co-authored-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
2020-12-18 02:05:06 -08:00
psakievich
093a247b25
View location resolve environment variables (#20420) 2020-12-17 10:25:08 -08:00
Tamara Dahlgren
b7d9e269ef
docs: add single node concurrent build example (#20416) 2020-12-17 17:23:55 +01:00
Massimiliano Culpo
76f1548fe2
unit-tests: ensure that installed packages can be reused (#20307)
refers #20292

Added a unit test that ensures we can reuse installed
packages even if in the repository variants have been
removed or added.
2020-12-17 00:31:59 -08:00
Adam J. Stewart
826cd07cf7
PythonPackage: add import module smoke tests (#20023) 2020-12-16 15:15:03 -08:00
Greg Becker
3840c0ac45
docs: fix spack install debug arg order (#20428) 2020-12-16 13:57:08 -08:00
Adam J. Stewart
20752db103
Docs: add more Command Reference links to spack test (#20413) 2020-12-16 12:08:32 -08:00
Tamara Dahlgren
cb01981628
docs: fix spack command for unit-test pytest help (#20415) 2020-12-16 10:13:22 -08:00
Greg Becker
352dc0624c
Fix comparisons for abstract specs (#20341)
bug only relevant for python3
2020-12-15 14:44:58 -08:00
Todd Gamblin
b6089ac691
concretizer: don't use one_of_iff for range constraints (#20383)
Currently, version range constraints, compiler version range constraints,
and target range constraints are implemented by generating ground rules
from `asp.py`, via `one_of_iff()`.  The rules look like this:

```
version_satisfies("python", "2.6:") :- 1 { version("python", "2.4"); ... } 1.
1 { version("python", "2.4"); ... } 1. :- version_satisfies("python", "2.6:").
```

So, `version_satisfies(Package, Constraint)` is true if and only if the
package is assigned a version that satisfies the constraint. We
precompute the set of known versions that satisfy the constraint, and
generate the rule in `SpackSolverSetup`.

We shouldn't need to generate already-ground rules for this. Rather, we
should leave it to the grounder to do the grounding, and generate facts
so that the constraint semantics can be defined in `concretize.lp`.

We can replace rules like the ones above with facts like this:

```
version_satisfies("python", "2.6:", "2.4")
```

And ground them in `concretize.lp` with rules like this:

```
1 { version(Package, Version) : version_satisfies(Package, Constraint, Version) } 1
  :- version_satisfies(Package, Constraint).
version_satisfies(Package, Constraint)
  :- version(Package, Version), version_satisfies(Package, Constraint, Version).
```

The top rule is the same as before. It makes conditional dependencies and
other places where version constraints are used work properly. Note that
we do not need the cardinality constraint for the second rule -- we
already have rules saying there can be only one version assigned to a
package, so we can just infer from `version/2` `version_satisfies/3`.
This form is also safe for grounding -- If we used the original form we'd
have unsafe variables like `Constraint` and `Package` -- the original
form only really worked when specified as ground to begin with.

- [x] use facts instead of generating rules for package version constraints
- [x] use facts instead of generating rules for compiler version constraints
- [x] use facts instead of generating rules for target range constraints
- [x] remove `one_of_iff()` and `iff()` as they're no longer needed
2020-12-15 11:58:58 -08:00
Tamara Dahlgren
21f30e3074
Bugfix/docs: correct and expand smoke test documentation (#20278) 2020-12-15 08:38:00 -08:00
Tamara Dahlgren
d67ca265a3
outputs: restore default output of fetch/build/total times (#20394) 2020-12-15 01:46:30 -08:00
Massimiliano Culpo
e7f4c2b49e
package sanity: ensure all variant defaults are allowed values (#20373) 2020-12-15 10:22:15 +01:00
Todd Gamblin
495e8cfb8e
concretizer: remove clingo command-line driver (#20362)
I was keeping the old `clingo` driver code around in case we had to run
using the command line tool instad of through the Python interface.

So far, the command line is faster than running through Python, but I'm
working on fixing that.  I found that if I do this:

```python
control = clingo.Control()
control.load("concretize.lp")
control.load("hdf5.lp")       # code from spack solve --show asp hdf5
control.load("display.lp")

control.ground([("base", [])])
control.solve(...)
```

It's just as fast as the command line tool. So we can always generate the
code and load it manually if we need to -- we don't need two drivers for
clingo. Given that the python interface is also the only way to get unsat
cores, I think we pretty much have to use it.

So, I'm removing the old command line driver and other unused code. We
can dig it up again from the history if it is needed.
2020-12-14 09:35:53 +01:00
Ben Cowan
cf37e9276d
Debugging support: fix compiler wrapper log on Mac OS (#20333)
This fixes a logging error observed on macOS 11.0.1 (Big Sur).
When performing a Spack install in debugging mode (e.g.
`spack -d install py-scipy`) Spack is supposed to write a log of
compiler wrapper command line invocations to the current working
directory.

Due to a regression error introduced by #18205, these files were
no-longer generated, and Spack was printing errors such as
"No such file or directory: None/." This is because the log file
directory gets set from `spack.main.spack_working_dir`, but that
variable is not set in the spawned process.

This PR ensures that the working directory (at the time of the
"spack install" invocation) is persisted to the subprocess.
2020-12-11 15:54:11 -08:00
Tamara Dahlgren
59628cd9e8
Tests: enable re-use of post-install tests in smoke tests (#20298) 2020-12-10 10:35:27 -08:00
Adam J. Stewart
3f5f80956e
Command Reference: add link to spack test docs (#20054) 2020-12-08 09:26:03 -08:00
Andrew W Elble
a90026fb89
concretizer: try hard to obtain all needed variant_possible_value()'s (#20102)
Track all the variant values mentioned when emitting constraints, validate them
and emit a fact that allows them as possible values.

This modification ensures that open-ended variants (variants accepting any string 
or any integer) are projected to the finite set of values that are relevant for this 
concretization.
2020-12-08 15:46:52 +01:00
Harmen Stoppels
50f8332d95
Compiler wrapper linting (#20249)
* Fix duplicate entries in case
* make sure the arg is not interpreted as two items in a list
* use -n over ! -z
2020-12-07 18:58:19 -08:00
Massimiliano Culpo
98c2627132 bugfix: work around issue handling packages not in any repo 2020-12-07 17:18:33 -08:00