From 4fb1db1d1a14efb954a029f01cdf4033b46e30db Mon Sep 17 00:00:00 2001 From: beckermr Date: Thu, 7 Nov 2024 04:48:04 -0600 Subject: [PATCH 1/3] fix: use syntax for `noarch: python` min version that does not break conda-build --- conda_smithy/linter/hints.py | 27 ++++++++++++++++++++------- tests/test_lint_recipe.py | 31 +++++++++++++------------------ 2 files changed, 33 insertions(+), 25 deletions(-) diff --git a/conda_smithy/linter/hints.py b/conda_smithy/linter/hints.py index 90d9ecf5a..a2c217904 100644 --- a/conda_smithy/linter/hints.py +++ b/conda_smithy/linter/hints.py @@ -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( @@ -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) diff --git a/tests/test_lint_recipe.py b/tests/test_lint_recipe.py index 2e74d1e6c..178c7ab6e 100644 --- a/tests/test_lint_recipe.py +++ b/tests/test_lint_recipe.py @@ -3033,9 +3033,8 @@ def test_hint_pip_no_build_backend( """ ), [ - "python {{ python_min }}.*", + "python {{ python_min }}", "python >={{ python_min }}", - "python ={{ python_min }}", ], ), ( @@ -3053,9 +3052,8 @@ def test_hint_pip_no_build_backend( """ ), [ - "python {{ python_min }}.*", + "python {{ python_min }}", "python >={{ python_min }}", - "python ={{ python_min }}", ], ), ( @@ -3073,9 +3071,8 @@ def test_hint_pip_no_build_backend( """ ), [ - "python {{ python_min }}.*", + "python {{ python_min }}", "python >={{ python_min }}", - "python ={{ python_min }}", ], ), ( @@ -3093,8 +3090,7 @@ def test_hint_pip_no_build_backend( """ ), [ - "python {{ python_min }}.*", - "python ={{ python_min }}", + "python {{ python_min }}", ], ), ( @@ -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 }}", ], ), ( @@ -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 }} """ ), [], @@ -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 }}"], @@ -3221,9 +3217,8 @@ def test_hint_noarch_python_use_python_min( """ ), [ - "python ${{ python_min }}.*", + "python ${{ python_min }}", "python >=${{ python_min }}", - "python =${{ python_min }}", ], ), ( @@ -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 }} """ ), [], From c318825878b9cb59db702407b5d2db8aed69527a Mon Sep 17 00:00:00 2001 From: "Matthew R. Becker" Date: Thu, 7 Nov 2024 05:13:24 -0600 Subject: [PATCH 2/3] doc: add news --- news/2119-fix-lint-noarch-python-v1.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/news/2119-fix-lint-noarch-python-v1.rst b/news/2119-fix-lint-noarch-python-v1.rst index 1b0ce1dd9..a83f48cfc 100644 --- a/news/2119-fix-lint-noarch-python-v1.rst +++ b/news/2119-fix-lint-noarch-python-v1.rst @@ -17,6 +17,7 @@ **Fixed:** * Fixed ``noarch: python`` hint for v1 recipes. (#2119) +* Fixed ``noarch: python`` syntax to be more compatible. (#2112) **Security:** From 263b623f157d0856e34878f03c02ccb450e7244c Mon Sep 17 00:00:00 2001 From: "Matthew R. Becker" Date: Thu, 7 Nov 2024 05:23:11 -0600 Subject: [PATCH 3/3] doc: fix PR number in news --- news/2119-fix-lint-noarch-python-v1.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/news/2119-fix-lint-noarch-python-v1.rst b/news/2119-fix-lint-noarch-python-v1.rst index a83f48cfc..eb7ecd50c 100644 --- a/news/2119-fix-lint-noarch-python-v1.rst +++ b/news/2119-fix-lint-noarch-python-v1.rst @@ -17,7 +17,7 @@ **Fixed:** * Fixed ``noarch: python`` hint for v1 recipes. (#2119) -* Fixed ``noarch: python`` syntax to be more compatible. (#2112) +* Fixed ``noarch: python`` syntax to be more compatible. (#2122) **Security:**