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: soften language for the noarch: python hint, add override note, and fix a bug for v1 #2126

Merged
merged 7 commits into from
Nov 11, 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
24 changes: 14 additions & 10 deletions conda_smithy/linter/hints.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ def hint_pip_no_build_backend(host_or_build_section, package_name, hints):

if not found_backend:
hints.append(
f"No valid build backend found for Python recipe for package `{package_name}` using `pip`. Python recipes using `pip` need to "
f"No valid build backend found for Python recipe for package `{package_name}` using `pip`. "
"Python recipes using `pip` need to "
"explicitly specify a build backend in the `host` section. "
"If your recipe has built with only `pip` in the `host` section in the past, you likely should "
"add `setuptools` to the `host` section of your recipe."
Expand All @@ -250,12 +251,13 @@ def hint_noarch_python_use_python_min(
("run", "python >={{ python_min }}", run_reqs),
("test.requires", "python {{ python_min }}", test_reqs),
]:
test_syntax = syntax.replace("{{ python_min }}", "9999")

if recipe_version == 1:
syntax = syntax.replace(
"{{ python_min }}", "${{ python_min }}"
)
test_syntax = syntax
else:
test_syntax = syntax.replace("{{ python_min }}", "9999")
beckermr marked this conversation as resolved.
Show resolved Hide resolved

for req in reqs:
if (
Expand All @@ -266,21 +268,23 @@ def hint_noarch_python_use_python_min(
break
else:
hint += (
f"For the `{section_name}` section of the recipe, you should almost always use `{syntax}` "
f"for the `python` entry. "
f"\n - For the `{section_name}` section of the recipe, you should usually use `{syntax}` "
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). "
"`noarch: python` recipes should usually follow the syntax in "
beckermr marked this conversation as resolved.
Show resolved Hide resolved
"our [documentation](https://conda-forge.org/docs/maintainer/knowledge_base/#noarch-python) "
"for specifying the Python version."
)
+ 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`."
"\n - If the package requires a newer Python version than the currently supported minimum "
"version on `conda-forge`, you can override the `python_min` variable by adding a "
"Jinja2 `set` statement at the top of your recipe (or using an equivalent `context` "
"variable for v1 recipes)."
)
)
hints.append(hint)
23 changes: 23 additions & 0 deletions news/2126-adjust-noarch-py-hint.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* <news item>

**Changed:**

* Changed the language in the ``noarch: python`` hint to add instructions on override w/ Jinja2/contexts and use softer language. (#2126)

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* Fixed a bug where v1 recipes were not properly linted for `noarch: python` hints. (#2126)

**Security:**

* <news item>
2 changes: 1 addition & 1 deletion tests/test_lint_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -3269,7 +3269,7 @@ def test_hint_noarch_python_use_python_min_v1(
meta_str,
expected_hints,
):
meta = get_yaml().load(render_meta_yaml(meta_str.replace("${{", "{{")))
meta = get_yaml().load(meta_str)
lints = []
hints = []
linter.run_conda_forge_specific(
Expand Down
Loading