Skip to content

Commit

Permalink
Merge pull request #2119 from conda-forge/fix-lint-rattler
Browse files Browse the repository at this point in the history
  • Loading branch information
beckermr authored Nov 7, 2024
2 parents 973c922 + 7bbc7c9 commit d8bf133
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 1 deletion.
1 change: 1 addition & 0 deletions conda_smithy/lint_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,7 @@ def run_conda_forge_specific(
test_reqs,
outputs_section,
noarch_value,
recipe_version,
hints,
)

Expand Down
13 changes: 12 additions & 1 deletion conda_smithy/linter/hints.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,25 @@ def hint_pip_no_build_backend(host_or_build_section, package_name, hints):


def hint_noarch_python_use_python_min(
host_reqs, run_reqs, test_reqs, outputs_section, noarch_value, hints
host_reqs,
run_reqs,
test_reqs,
outputs_section,
noarch_value,
recipe_version,
hints,
):
if noarch_value == "python" and not outputs_section:
for section_name, syntax, reqs in [
("host", "python {{ python_min }}.*", host_reqs),
("run", "python >={{ python_min }}", run_reqs),
("test.requires", "python ={{ python_min }}", test_reqs),
]:
if recipe_version == 1:
syntax = syntax.replace(
"{{ python_min }}", "${{ python_min }}"
)

for req in reqs:
if (
req.strip().split()[0] == "python"
Expand Down
23 changes: 23 additions & 0 deletions news/2119-fix-lint-noarch-python-v1.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* <news item>

**Changed:**

* <news item>

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* Fixed ``noarch: python`` hint for v1 recipes. (#2119)

**Security:**

* <news item>
88 changes: 88 additions & 0 deletions tests/test_lint_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -3190,5 +3190,93 @@ def test_hint_noarch_python_use_python_min(
)


@pytest.mark.parametrize(
"meta_str,expected_hints",
[
(
textwrap.dedent(
"""
package:
name: python
requirements:
run:
- python
"""
),
[],
),
(
textwrap.dedent(
"""
package:
name: python
build:
noarch: python
requirements:
run:
- python
"""
),
[
"python ${{ python_min }}.*",
"python >=${{ python_min }}",
"python =${{ python_min }}",
],
),
(
textwrap.dedent(
"""
package:
name: python
build:
noarch: python
requirements:
host:
- python ${{ python_min }}.*
run:
- python >=${{ python_min }}
tests:
- requirements:
run:
- python =${{ python_min }}
"""
),
[],
),
],
)
def test_hint_noarch_python_use_python_min_v1(
meta_str,
expected_hints,
):
meta = get_yaml().load(meta_str)
lints = []
hints = []
linter.run_conda_forge_specific(
meta,
None,
lints,
hints,
recipe_version=1,
)

# make sure we have the expected hints
if expected_hints:
for expected_hint in expected_hints:
assert any(expected_hint in hint for hint in hints), hints
else:
assert all(
"noarch: python recipes should almost always follow the syntax in"
not in hint
for hint in hints
)


if __name__ == "__main__":
unittest.main()

0 comments on commit d8bf133

Please sign in to comment.