Repository: conda-incubator/grayskull (python)

Issue:
[BUG] grayskull 1.6.0 fails to add minimum "safe" python on noarch packages
The `humre` is a norach package but fails to specify a minimum python requirement. In the past grayskull, with the `--strict-conda-forge`, used to add the `>=3.6` automatically but that is no longer true:

``` 
grayskull pypi --strict-conda-forge humre
```


Pull request:
Bf 366 missing python constrain
Fixes #366 

Patch:
diff --git a/grayskull/strategy/py_base.py b/grayskull/strategy/py_base.py
index c4fef6f..9975939 100644
--- a/grayskull/strategy/py_base.py
+++ b/grayskull/strategy/py_base.py
@@ -35,14 +35,11 @@ PIN_PKG_COMPILER = {"numpy": "<{ pin_compatible('numpy') }}"}
 
 
 def search_setup_root(path_folder: Union[Path, str]) -> Path:
-    setup_py = list(Path(path_folder).rglob("setup.py"))
-    if setup_py:
+    if setup_py := list(Path(path_folder).rglob("setup.py")):
         return setup_py[0]
-    setup_cfg = list(Path(path_folder).rglob("setup.cfg"))
-    if setup_cfg:
+    if setup_cfg := list(Path(path_folder).rglob("setup.cfg")):
         return setup_cfg[0]
-    pyproject_toml = list(Path(path_folder).rglob("pyproject.toml"))
-    if pyproject_toml:
+    if pyproject_toml := list(Path(path_folder).rglob("pyproject.toml")):
         return pyproject_toml[0]
 
 
@@ -277,7 +274,10 @@ def get_setup_cfg(source_path: str) -> dict:
      files unpacked
     :return: Metadata of setup.cfg
     """
-    from setuptools.config import read_configuration
+    try:
+        from setuptools.config.setupcfg import read_configuration
+    except ImportError:
+        from setuptools.config import read_configuration
 
     log.debug(f"Started setup.cfg from {source_path}")
     print_msg("Recovering metadata from setup.cfg")
@@ -496,7 +496,7 @@ def py_version_to_selector(pypi_metadata: dict, config) -> Optional[str]:
 
 
 def py_version_to_limit_python(pypi_metadata: dict, config=None) -> Optional[str]:
-    config = config or Configuration()
+    config = config or Configuration(pypi_metadata["name"])
     result = generic_py_ver_to(pypi_metadata, is_selector=False, config=config)
     if not result and config.is_strict_cf:
         result = (
diff --git a/grayskull/strategy/pypi.py b/grayskull/strategy/pypi.py
index 26590ce..aedfd24 100644
--- a/grayskull/strategy/pypi.py
+++ b/grayskull/strategy/pypi.py
@@ -490,7 +490,17 @@ def extract_requirements(metadata: dict, config, recipe) -> Dict[str, List[str]]
     setup_requires = metadata.get("setup_requires", [])
     host_req = format_dependencies(setup_requires or [], config.name)
     if not requires_dist and not host_req and not metadata.get("requires_python"):
-        return {"host": ["python", "pip"], "run": ["python"]}
+        if config.is_strict_cf:
+            return {
+                "host": ["python", "pip"],
+                "run": [
+                    f"python"
+                    f" >={config.py_cf_supported[0].major}"
+                    f".{config.py_cf_supported[0].minor}"
+                ],
+            }
+        else:
+            return {"host": ["python", "pip"], "run": ["python"]}
 
     run_req = get_run_req_from_requires_dist(requires_dist, config)
     build_req = [f"<{{ compiler('{c}') }}}}" for c in metadata.get("compilers", [])]


Test patch:
diff --git a/tests/test_pypi.py b/tests/test_pypi.py
index 62944ac..6fd9a9b 100644
--- a/tests/test_pypi.py
+++ b/tests/test_pypi.py
@@ -1281,3 +1281,8 @@ def test_remove_selectors_pkgs_if_needed_with_recipe():
             "tqdm >=4.27",
         }
     )
+
+
+def test_noarch_python_min_constrain():
+    recipe, _ = create_python_recipe("humre", is_strict_cf=True, version="0.1.1")
+    assert recipe["requirements"]["run"] == ["python >=3.6"]