Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate run_constrained specs #5359

Merged
merged 2 commits into from
Jun 3, 2024

Conversation

jaimergp
Copy link
Contributor

@jaimergp jaimergp commented May 24, 2024

Description

Closes #5047

conda-build allows to include run_constrained items in the recipe content. These are sometimes not checked because they only affect the solver if the constrained name happens to be present in the test environment. As a result, faulty lines might get sneak all the way into the final repodata.json.

When the rules finally kick in, you get a solver error. One current example comes in the willow recipe, which constrains pillow-heif.

That line is not a valid MatchSpec:

>>> from conda.models.match_spec import MatchSpec
>>> MatchSpec("pillow-heif >=0.10.0,<1.0.0<py312|>=0.13.0,<1.0.0>=py312")
Traceback (most recent call last):
  File "/Users/jrodriguez/.local/anaconda/lib/python3.9/site-packages/conda/models/version.py", line 43, in __call__
    return cls._cache_[arg]
KeyError: '>=0.10.0,<1.0.0<py312|>=0.13.0,<1.0.0>=py312'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/jrodriguez/.local/anaconda/lib/python3.9/site-packages/conda/models/version.py", line 43, in __call__
    return cls._cache_[arg]
KeyError: '<1.0.0<py312'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/jrodriguez/.local/anaconda/lib/python3.9/site-packages/conda/models/version.py", line 43, in __call__
    return cls._cache_[arg]
KeyError: '1.0.0<py312'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/jrodriguez/.local/anaconda/lib/python3.9/site-packages/conda/models/match_spec.py", line 54, in __call__
    return super().__call__(**parsed)
  File "/Users/jrodriguez/.local/anaconda/lib/python3.9/site-packages/conda/models/match_spec.py", line 177, in __init__
    self._match_components = self._build_components(**kwargs)
  File "/Users/jrodriguez/.local/anaconda/lib/python3.9/site-packages/conda/models/match_spec.py", line 412, in _build_components
    return frozendict(_make_component(key, value) for key, value in kwargs.items())
  File "/Users/jrodriguez/.local/anaconda/lib/python3.9/site-packages/conda/_vendor/frozendict/__init__.py", line 21, in __init__
    self._dict = self.dict_cls(*args, **kwargs)
  File "/Users/jrodriguez/.local/anaconda/lib/python3.9/site-packages/conda/models/match_spec.py", line 412, in <genexpr>
    return frozendict(_make_component(key, value) for key, value in kwargs.items())
  File "/Users/jrodriguez/.local/anaconda/lib/python3.9/site-packages/conda/models/match_spec.py", line 426, in _make_component
    matcher = _implementors[field_name](value)
  File "/Users/jrodriguez/.local/anaconda/lib/python3.9/site-packages/conda/models/version.py", line 45, in __call__
    val = cls._cache_[arg] = super().__call__(arg)
  File "/Users/jrodriguez/.local/anaconda/lib/python3.9/site-packages/conda/models/version.py", line 522, in __init__
    vspec_str, matcher, is_exact = self.get_matcher(vspec)
  File "/Users/jrodriguez/.local/anaconda/lib/python3.9/site-packages/conda/models/version.py", line 532, in get_matcher
    tup = tuple(VersionSpec(s) for s in vspec_tree[1:])
  File "/Users/jrodriguez/.local/anaconda/lib/python3.9/site-packages/conda/models/version.py", line 532, in <genexpr>
    tup = tuple(VersionSpec(s) for s in vspec_tree[1:])
  File "/Users/jrodriguez/.local/anaconda/lib/python3.9/site-packages/conda/models/version.py", line 48, in __call__
    return super().__call__(arg)
  File "/Users/jrodriguez/.local/anaconda/lib/python3.9/site-packages/conda/models/version.py", line 522, in __init__
    vspec_str, matcher, is_exact = self.get_matcher(vspec)
  File "/Users/jrodriguez/.local/anaconda/lib/python3.9/site-packages/conda/models/version.py", line 532, in get_matcher
    tup = tuple(VersionSpec(s) for s in vspec_tree[1:])
  File "/Users/jrodriguez/.local/anaconda/lib/python3.9/site-packages/conda/models/version.py", line 532, in <genexpr>
    tup = tuple(VersionSpec(s) for s in vspec_tree[1:])
  File "/Users/jrodriguez/.local/anaconda/lib/python3.9/site-packages/conda/models/version.py", line 45, in __call__
    val = cls._cache_[arg] = super().__call__(arg)
  File "/Users/jrodriguez/.local/anaconda/lib/python3.9/site-packages/conda/models/version.py", line 522, in __init__
    vspec_str, matcher, is_exact = self.get_matcher(vspec)
  File "/Users/jrodriguez/.local/anaconda/lib/python3.9/site-packages/conda/models/version.py", line 576, in get_matcher
    self.matcher_vo = VersionOrder(vo_str)
  File "/Users/jrodriguez/.local/anaconda/lib/python3.9/site-packages/conda/models/version.py", line 45, in __call__
    val = cls._cache_[arg] = super().__call__(arg)
  File "/Users/jrodriguez/.local/anaconda/lib/python3.9/site-packages/conda/models/version.py", line 171, in __init__
    raise InvalidVersionSpec(vstr, "invalid character(s)")
conda.exceptions.InvalidVersionSpec: Invalid version '1.0.0<py312': invalid character(s)

This PR adds a check for all run_constrained item to make sure they don't ever reach a final package without getting it addressed.

Checklist - did you ...

  • Add a file to the news directory (using the template) for the next release's release notes?
  • Add / update necessary tests?
  • Add / update outdated documentation?

@conda-bot conda-bot added the cla-signed [bot] added once the contributor has signed the CLA label May 24, 2024
@jaimergp jaimergp linked an issue May 24, 2024 that may be closed by this pull request
Copy link

codspeed-hq bot commented May 24, 2024

CodSpeed Performance Report

Merging #5359 will not alter performance

Comparing jaimergp:validate-run-constrained (50c4393) with main (d9edc57)

Summary

✅ 3 untouched benchmarks

@jaimergp jaimergp marked this pull request as ready for review May 25, 2024 09:25
@jaimergp jaimergp requested a review from a team as a code owner May 25, 2024 09:25
Copy link
Contributor

@travishathaway travishathaway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 Looks good.

@wolfv
Copy link
Contributor

wolfv commented Jun 1, 2024

Looks good!

@jaimergp jaimergp merged commit 01b47f4 into conda:main Jun 3, 2024
28 checks passed
@beeankha beeankha mentioned this pull request Jul 16, 2024
55 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed [bot] added once the contributor has signed the CLA
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

conda-build should check if runtime dependencies are valid matchspecs
4 participants