Skip to content

Add syntactic sugar for "strong preferences" and "conflicts"#41832

Merged
tgamblin merged 10 commits intospack:developfrom
alalazo:features/prefer-and-conflict
Jan 22, 2024
Merged

Add syntactic sugar for "strong preferences" and "conflicts"#41832
tgamblin merged 10 commits intospack:developfrom
alalazo:features/prefer-and-conflict

Conversation

@alalazo
Copy link
Copy Markdown
Member

@alalazo alalazo commented Dec 22, 2023

Currently requirements allow to express "strong preferences" and "conflicts" from configuration using a convoluted syntax:

packages:
  zlib-ng:
    require:
    # conflict on %clang
    - one_of: ["%clang", "@:"]
    # Strong preference for +shared
    - any_of: ["+shared", "@:"]

This PR adds syntactic sugar so that the same can be written as:

packages:
  zlib-ng:
    conflict:
    - "%clang"
    prefer:
    - "+shared"

Preferences written in this way are "stronger" that the ones documented at:

@spackbot-app spackbot-app bot added core PR affects Spack core functionality documentation Improvements or additions to documentation gitlab Issues related to gitlab integration tests General test capability(ies) labels Dec 22, 2023
@alalazo alalazo force-pushed the features/prefer-and-conflict branch from b674e9d to 04e89e9 Compare January 9, 2024 09:37
@haampie
Copy link
Copy Markdown
Member

haampie commented Jan 10, 2024

I'm generally fine with this change, we discussed:

  1. packages:pkg:prefer(s)/conflict(s)/require(s): it's unfortunate that this is not consistent with directives, but require already exists a while, and the requires directive too. I think it's too much to deprecate require and replace it with requires just for consistency.
  2. The syntax allows for future extension to:
    prefer:
    - spec: @1
    - when: %gcc
    dunno if this is going to be necessary in practice (at least for conflicts("x", when="y") is equivalent to conflicts("x y"), so no need).

@alalazo alalazo force-pushed the features/prefer-and-conflict branch from 04e89e9 to dd8e90d Compare January 16, 2024 14:26
@tgamblin tgamblin added this to the v0.22.0 milestone Jan 18, 2024
tgamblin
tgamblin previously approved these changes Jan 18, 2024
@tgamblin
Copy link
Copy Markdown
Member

gitlab pipeline looks to be failing

@alalazo
Copy link
Copy Markdown
Member Author

alalazo commented Jan 19, 2024

Failure seems unrelated:
Screenshot from 2024-01-19 09-01-10

I'll try re-triggering the pipeline

EDIT: possibly the issue fixed here #40045

@alalazo
Copy link
Copy Markdown
Member Author

alalazo commented Jan 19, 2024

@spackbot run pipeline

@spackbot-app
Copy link
Copy Markdown

spackbot-app bot commented Jan 19, 2024

I've started that pipeline for you!

With requirements, we can already express strong preferences
and conflicts, but the syntax to do it is not as clean as it
should be.

This PR adds syntactic sugar to express strong preferences
and conflicts in packages.yaml files.
@alalazo alalazo force-pushed the features/prefer-and-conflict branch from c575b83 to 90c5907 Compare January 19, 2024 18:14
@alalazo alalazo requested a review from tgamblin January 19, 2024 19:25
@tgamblin tgamblin merged commit 6681346 into spack:develop Jan 22, 2024
@alalazo alalazo deleted the features/prefer-and-conflict branch January 22, 2024 21:50
RikkiButler20 pushed a commit to RikkiButler20/spack that referenced this pull request Jan 25, 2024
…1832)

Currently requirements allow to express "strong preferences" and "conflicts" from
configuration using a convoluted syntax:
```yaml
packages:
  zlib-ng:
    require:
    # conflict on %clang
    - one_of: ["%clang", "@:"]
    # Strong preference for +shared
    - any_of: ["+shared", "@:"]
```
This PR adds syntactic sugar so that the same can be written as:
```yaml
packages:
  zlib-ng:
    conflict:
    - "%clang"
    prefer:
    - "+shared"
```
Preferences written in this way are "stronger" that the ones documented at:
- https://spack.readthedocs.io/en/latest/packages_yaml.html#package-preferences
RikkiButler20 pushed a commit to RikkiButler20/spack that referenced this pull request Jan 31, 2024
…1832)

Currently requirements allow to express "strong preferences" and "conflicts" from
configuration using a convoluted syntax:
```yaml
packages:
  zlib-ng:
    require:
    # conflict on %clang
    - one_of: ["%clang", "@:"]
    # Strong preference for +shared
    - any_of: ["+shared", "@:"]
```
This PR adds syntactic sugar so that the same can be written as:
```yaml
packages:
  zlib-ng:
    conflict:
    - "%clang"
    prefer:
    - "+shared"
```
Preferences written in this way are "stronger" that the ones documented at:
- https://spack.readthedocs.io/en/latest/packages_yaml.html#package-preferences
kwryankrattiger pushed a commit to kwryankrattiger/spack that referenced this pull request Jul 9, 2024
…1832)

Currently requirements allow to express "strong preferences" and "conflicts" from
configuration using a convoluted syntax:
```yaml
packages:
  zlib-ng:
    require:
    # conflict on %clang
    - one_of: ["%clang", "@:"]
    # Strong preference for +shared
    - any_of: ["+shared", "@:"]
```
This PR adds syntactic sugar so that the same can be written as:
```yaml
packages:
  zlib-ng:
    conflict:
    - "%clang"
    prefer:
    - "+shared"
```
Preferences written in this way are "stronger" that the ones documented at:
- https://spack.readthedocs.io/en/latest/packages_yaml.html#package-preferences
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core PR affects Spack core functionality documentation Improvements or additions to documentation gitlab Issues related to gitlab integration tests General test capability(ies)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants