Skip to content

Commit

Permalink
Add requirements and strong preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
alalazo committed Jun 10, 2024
1 parent 10ae185 commit 8f4f3c6
Showing 1 changed file with 97 additions and 0 deletions.
97 changes: 97 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,103 @@ <h2>How are errors modeled?</h2>
</code></pre>
</section>
</section>
<section>
<section>
<h2>What are requirements and strong preferences?</h2>
</section>
<section>
Enforce constraints from <code>package.py</code> or configuration
</section>
<section>
In a recipe:
<pre><code data-trim data-noescape class="python">
class Hdf5(CMakePackage):

requires("%gcc", msg="This package must be built with GCC")
</code></pre>
From configuration:
<pre><code data-trim data-noescape class="YAML">
packages:
hdf5:
require:
- spec: "%gcc"
message: "This package must be built with GCC"
</code></pre>
</section>
<section>
Setting default requirements
<pre><code data-trim data-noescape class="YAML">
packages:
all:
require:
- "+shared +cuda"
</code></pre>
vs.
<pre><code data-trim data-noescape class="YAML">
packages:
all:
require:
- "+shared"
- "+cuda"
</code></pre>
</section>
<section>
Package specific requirements override defaults
<pre><code data-trim data-noescape class="YAML">
packages:
all:
require:
- 'build_type=Debug'
- '%clang'
cmake:
require:
- '%gcc'
</code></pre>
</section>
<section>
Requirements on virtual packages
<pre><code data-trim data-noescape class="YAML">
packages:
mpi:
require:
- 'mvapich2 %gcc'
mvapich2:
require:
- '~cuda'
</code></pre>
</section>
<section>
Strong preferences
<pre><code data-trim data-noescape class="YAML">
packages:
all:
prefer:
- 'build_type=Release'
- '+cuda'
</code></pre>
==
<pre><code data-trim data-noescape class="YAML">
packages:
all:
require:
- any_of: ['build_type=Release', '@:']
- any_of: ['+cuda', '@:']
</code></pre>
</section>
<section>
<h2>Hands-on</h2>
<pre><code data-trim data-noescape class="bash">
# Add a requirement to configuration,
# try to violate it, check the error message

# Do the same with a strong preference, observe
# spack solve weights

# Enforce virtuals in an environment using
# requirements
</code></pre>
</section>
</section>
</div>
</div>

Expand Down

0 comments on commit 8f4f3c6

Please sign in to comment.