Skip to content

Commit

Permalink
Fix dropping upper bound constrain for requires python (#400)
Browse files Browse the repository at this point in the history
* Fix dropping upper bound constrain for requires python

* Add support for python 3.11
  • Loading branch information
marcelotrevisani authored Oct 11, 2022
1 parent 1614275 commit b0101c9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 2 additions & 0 deletions grayskull/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Configuration:
PyVer(3, 8),
PyVer(3, 9),
PyVer(3, 10),
PyVer(3, 11),
]
)
py_cf_supported: List[PyVer] = field(
Expand All @@ -27,6 +28,7 @@ class Configuration:
PyVer(3, 8),
PyVer(3, 9),
PyVer(3, 10),
PyVer(3, 11),
]
)
is_strict_cf: bool = False
Expand Down
7 changes: 5 additions & 2 deletions grayskull/strategy/py_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,12 @@ def get_name_version_from_requires_dist(string_parse: str) -> Tuple[str, str]:


def generic_py_ver_to(
metadata: dict, config, is_selector: bool = False
metadata: dict, config: Configuration, is_selector: bool = False
) -> Optional[str]: # sourcery no-metrics
"""Generic function which abstract the parse of the requires_python
present in the PyPi metadata. Basically it can generate the selectors
for Python or the constrained version if it is a `noarch: python` python package"""
# TODO: Refactor the entire function to use LooseVersion instead of custom PyVer
if not metadata.get("requires_python"):
return None
req_python = re.findall(
Expand All @@ -158,7 +159,9 @@ def generic_py_ver_to(
return None

py_ver_enabled = config.get_py_version_available(req_python)
small_py3_version = config.get_oldest_py3_version(list(py_ver_enabled.keys()))
small_py3_version = config.get_oldest_py3_version(
[k for k, v in py_ver_enabled.items() if v]
)
all_py = list(py_ver_enabled.values())
if all(all_py):
return None
Expand Down
10 changes: 10 additions & 0 deletions tests/test_py_base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from grayskull.__main__ import create_python_recipe
from grayskull.config import Configuration
from grayskull.strategy.py_base import (
clean_deps_for_conda_forge,
ensure_pep440,
generic_py_ver_to,
update_requirements_with_pin,
)
from grayskull.utils import PyVer
Expand Down Expand Up @@ -42,3 +44,11 @@ def test_clean_deps_for_conda_forge_remove_py_selector():
assert clean_deps_for_conda_forge(
["dulwich >=0.19.3 # [py>=35]"], PyVer(3, 6)
) == ["dulwich >=0.19.3"]


def test_python_requires_upper_bound():
py_ver = generic_py_ver_to(
{"requires_python": ">=3.7,<=3.10"},
Configuration(name="algviz", is_strict_cf=False),
)
assert py_ver == ">=3.7,<3.11"

0 comments on commit b0101c9

Please sign in to comment.