Skip to content

Commit

Permalink
Merge pull request #2122 from conda-forge/redo-noarch-py
Browse files Browse the repository at this point in the history
fix: use syntax for `noarch: python` min version that does not break conda-build
  • Loading branch information
beckermr authored Nov 7, 2024
2 parents d8bf133 + 263b623 commit 8a8893a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 25 deletions.
27 changes: 20 additions & 7 deletions conda_smithy/linter/hints.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,11 @@ def hint_noarch_python_use_python_min(
hints,
):
if noarch_value == "python" and not outputs_section:
hint = ""
for section_name, syntax, reqs in [
("host", "python {{ python_min }}.*", host_reqs),
("host", "python {{ python_min }}", host_reqs),
("run", "python >={{ python_min }}", run_reqs),
("test.requires", "python ={{ python_min }}", test_reqs),
("test.requires", "python {{ python_min }}", test_reqs),
]:
if recipe_version == 1:
syntax = syntax.replace(
Expand All @@ -262,10 +263,22 @@ def hint_noarch_python_use_python_min(
):
break
else:
hints.append(
f"noarch: python recipes should almost always follow the syntax in "
f"our [documentation](https://conda-forge.org/docs/maintainer/knowledge_base/#noarch-python). "
hint += (
f"For the `{section_name}` section of the recipe, you should almost always use `{syntax}` "
f"for the `python` entry. You may need to override the `python_min` variable if the package "
f"requires a newer Python version than the currently supported minimum version on `conda-forge`."
f"for the `python` entry. "
)

if hint:
hint = (
(
"noarch: python recipes should almost always follow the syntax in "
"our [documentation](https://conda-forge.org/docs/maintainer/knowledge_base/#noarch-python). "
)
+ hint
+ (
"You may need to override the `python_min` variable in the `conda_build_config.yaml`/`variants.yaml` "
"if the package requires a newer Python version than the currently supported minimum "
"version on `conda-forge`."
)
)
hints.append(hint)
1 change: 1 addition & 0 deletions news/2119-fix-lint-noarch-python-v1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
**Fixed:**

* Fixed ``noarch: python`` hint for v1 recipes. (#2119)
* Fixed ``noarch: python`` syntax to be more compatible. (#2122)

**Security:**

Expand Down
31 changes: 13 additions & 18 deletions tests/test_lint_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -3033,9 +3033,8 @@ def test_hint_pip_no_build_backend(
"""
),
[
"python {{ python_min }}.*",
"python {{ python_min }}",
"python >={{ python_min }}",
"python ={{ python_min }}",
],
),
(
Expand All @@ -3053,9 +3052,8 @@ def test_hint_pip_no_build_backend(
"""
),
[
"python {{ python_min }}.*",
"python {{ python_min }}",
"python >={{ python_min }}",
"python ={{ python_min }}",
],
),
(
Expand All @@ -3073,9 +3071,8 @@ def test_hint_pip_no_build_backend(
"""
),
[
"python {{ python_min }}.*",
"python {{ python_min }}",
"python >={{ python_min }}",
"python ={{ python_min }}",
],
),
(
Expand All @@ -3093,8 +3090,7 @@ def test_hint_pip_no_build_backend(
"""
),
[
"python {{ python_min }}.*",
"python ={{ python_min }}",
"python {{ python_min }}",
],
),
(
Expand All @@ -3108,13 +3104,13 @@ def test_hint_pip_no_build_backend(
requirements:
host:
- python {{ python_min }}.*
- python {{ python_min }}
run:
- python >={{ python_min }}
"""
),
[
"python ={{ python_min }}",
"python {{ python_min }}",
],
),
(
Expand All @@ -3128,13 +3124,13 @@ def test_hint_pip_no_build_backend(
requirements:
host:
- python {{ python_min }}.*
- python {{ python_min }}
run:
- python >={{ python_min }}
test:
requires:
- python ={{ python_min }}
- python {{ python_min }}
"""
),
[],
Expand All @@ -3150,13 +3146,13 @@ def test_hint_pip_no_build_backend(
requirements:
host:
- python {{ python_min }}.*
- python {{ python_min }}
run:
- python
test:
requires:
- python ={{ python_min }}
- python {{ python_min }}
"""
),
["python >={{ python_min }}"],
Expand Down Expand Up @@ -3221,9 +3217,8 @@ def test_hint_noarch_python_use_python_min(
"""
),
[
"python ${{ python_min }}.*",
"python ${{ python_min }}",
"python >=${{ python_min }}",
"python =${{ python_min }}",
],
),
(
Expand All @@ -3237,14 +3232,14 @@ def test_hint_noarch_python_use_python_min(
requirements:
host:
- python ${{ python_min }}.*
- python ${{ python_min }}
run:
- python >=${{ python_min }}
tests:
- requirements:
run:
- python =${{ python_min }}
- python ${{ python_min }}
"""
),
[],
Expand Down

0 comments on commit 8a8893a

Please sign in to comment.