diff --git a/grayskull/config.py b/grayskull/config.py index c3a961c17..5ca41c92a 100644 --- a/grayskull/config.py +++ b/grayskull/config.py @@ -19,6 +19,7 @@ class Configuration: PyVer(3, 9), PyVer(3, 10), PyVer(3, 11), + PyVer(3, 12), ] ) py_cf_supported: List[PyVer] = field( @@ -29,6 +30,7 @@ class Configuration: PyVer(3, 9), PyVer(3, 10), PyVer(3, 11), + PyVer(3, 12), ] ) is_strict_cf: bool = False diff --git a/grayskull/strategy/pypi.py b/grayskull/strategy/pypi.py index b49f97db8..2e9a40ff1 100644 --- a/grayskull/strategy/pypi.py +++ b/grayskull/strategy/pypi.py @@ -1,3 +1,4 @@ +import itertools import json import logging import os @@ -530,6 +531,25 @@ def update_recipe(recipe: Recipe, config: Configuration, all_sections: List[str] output["build"]["noarch"] = "python" +def check_noarch_python_for_new_deps( + host_req: List, run_req: List, config: Configuration +): + if not config.is_arch: + return + for dep in itertools.chain(host_req, run_req): + dep = dep.strip() + only_name = re.split(r"[~^<>=!#\s+]+", dep)[0].strip() + if ( + "# [" in dep + or dep.startswith("<{") + or only_name in config.pkg_need_c_compiler + or only_name in config.pkg_need_cxx_compiler + ): + config.is_arch = True + return + config.is_arch = False + + def extract_requirements(metadata: dict, config, recipe) -> Dict[str, List[str]]: """Extract the requirements for `build`, `host` and `run`""" name = metadata["name"] @@ -575,6 +595,7 @@ def extract_requirements(metadata: dict, config, recipe) -> Dict[str, List[str]] if config.is_strict_cf: host_req = remove_selectors_pkgs_if_needed(host_req) run_req = remove_selectors_pkgs_if_needed(run_req) + check_noarch_python_for_new_deps(host_req, run_req, config) result = {} if build_req: result = { diff --git a/tests/test_pypi.py b/tests/test_pypi.py index b1e9bae93..d717fb741 100644 --- a/tests/test_pypi.py +++ b/tests/test_pypi.py @@ -32,6 +32,7 @@ ) from grayskull.strategy.pypi import ( PypiStrategy, + check_noarch_python_for_new_deps, compose_test_section, extract_optional_requirements, extract_requirements, @@ -1356,3 +1357,15 @@ def test_metadata_pypi_none_value(mock_get_data): ) def test_remove_all_inner_none(param, result): assert remove_all_inner_nones(param) == result + + +def test_check_noarch_python_for_new_deps(): + config = Configuration( + is_strict_cf=True, name="abcd", version="0.1.0", is_arch=True + ) + check_noarch_python_for_new_deps( + ["python >=3.6", "pip"], + ["dataclasses >=3.6", "python >=3.6"], + config, + ) + assert config.is_arch is False