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

fix: use syntax for noarch: python min version that does not break conda-build #2122

Merged
merged 3 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading