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

Bug/fix 412 not adding noarch python with strict cf #496

Merged
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
2 changes: 2 additions & 0 deletions grayskull/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class Configuration:
PyVer(3, 9),
PyVer(3, 10),
PyVer(3, 11),
PyVer(3, 12),
]
)
py_cf_supported: List[PyVer] = field(
Expand All @@ -29,6 +30,7 @@ class Configuration:
PyVer(3, 9),
PyVer(3, 10),
PyVer(3, 11),
PyVer(3, 12),
]
)
is_strict_cf: bool = False
Expand Down
21 changes: 21 additions & 0 deletions grayskull/strategy/pypi.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import itertools
import json
import logging
import os
Expand Down Expand Up @@ -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"]
Expand Down Expand Up @@ -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 = {
Expand Down
13 changes: 13 additions & 0 deletions tests/test_pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
)
from grayskull.strategy.pypi import (
PypiStrategy,
check_noarch_python_for_new_deps,
compose_test_section,
extract_optional_requirements,
extract_requirements,
Expand Down Expand Up @@ -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
Loading