Skip to content

Commit

Permalink
Match constrains and readded them after processing
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelotrevisani committed Oct 19, 2023
1 parent 971fa45 commit 9c7284a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions grayskull/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,17 @@ def rm_duplicated_deps(all_requirements: Union[list, set, None]) -> Optional[lis
# as it should be added.
# (This is order-preserving since dicts are ordered by first insertion.)
new_reqs: dict[str, str] = {}
re_split = re.compile(r"\s+|>|=|<|~|!|#")
re_split = re.compile(r"\s+(|>|=|<|~|!|#)+")
for dep in all_requirements:
if dep.strip().startswith(("{{", "<{")):
new_reqs[dep] = dep
continue
dep_name, *constrains = re_split.split(dep.strip())
dep_name = dep_name.strip()
constrains = [
c.strip() for c in constrains if c.strip() not in {"*", "*.*", "*.*.*"}
c.strip()
for c in constrains
if c.strip() not in {"=*", "==*", "*", "*.*", "*.*.*"}
]
canonicalized = dep_name.replace("_", "-").lower()
constrains.insert(0, dep_name)
Expand Down Expand Up @@ -167,7 +169,7 @@ def format_dependencies(all_dependencies: List, name: str) -> List:
for req in all_dependencies:
match_req = re_deps.match(req)
deps_name = req
if deps_name.replace("-", "_") == name.replace("-", "_"):
if name is not None and deps_name.replace("-", "_") == name.replace("-", "_"):
continue
if match_req:
match_req = match_req.groups()
Expand Down

0 comments on commit 9c7284a

Please sign in to comment.