From 5fef7b0e48ad3c652fcbc0d4e75588bc2d03320d Mon Sep 17 00:00:00 2001 From: Michael Sarahan Date: Fri, 5 Jan 2024 15:52:23 -0600 Subject: [PATCH] fix handling of comments generated from PEP725 matching --- grayskull/strategy/py_base.py | 13 ++++++++----- grayskull/strategy/py_toml.py | 8 ++++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/grayskull/strategy/py_base.py b/grayskull/strategy/py_base.py index a9a9f6de8..a4b108242 100644 --- a/grayskull/strategy/py_base.py +++ b/grayskull/strategy/py_base.py @@ -546,10 +546,12 @@ def clean_list_pkg(pkg, list_pkgs): return [p for p in list_pkgs if pkg != p.strip().split(" ", 1)[0]] for pkg in requirements["host"]: - pkg_name = RE_DEPS_NAME.match(pkg).group(0) - if pkg_name in PIN_PKG_COMPILER.keys(): - requirements["run"] = clean_list_pkg(pkg_name, requirements["run"]) - requirements["run"].append(PIN_PKG_COMPILER[pkg_name]) + pkg_name_match = RE_DEPS_NAME.match(pkg) + if pkg_name_match: + pkg_name = pkg_name_match.group(0) + if pkg_name in PIN_PKG_COMPILER.keys(): + requirements["run"] = clean_list_pkg(pkg_name, requirements["run"]) + requirements["run"].append(PIN_PKG_COMPILER[pkg_name]) def discover_license(metadata: dict) -> List[ShortLicense]: @@ -826,7 +828,8 @@ def split_deps(deps: str) -> List[str]: def ensure_pep440(pkg: str) -> str: if not pkg: return pkg - if pkg.strip().startswith("<{") or pkg.strip().startswith("{{"): + pkg = pkg.strip() + if any([pkg.startswith(pattern) for pattern in ("#", "<{", "{{")]): return pkg split_pkg = pkg.strip().split(" ") if len(split_pkg) <= 1: diff --git a/grayskull/strategy/py_toml.py b/grayskull/strategy/py_toml.py index 188484313..4438ce301 100644 --- a/grayskull/strategy/py_toml.py +++ b/grayskull/strategy/py_toml.py @@ -256,10 +256,10 @@ def get_pep725_mapping(purl: str): # taken from package_mapping = { - "virtual:compiler/c": '{{ compiler("c") }}', - "virtual:compiler/cpp": '{{ compiler("cxx") }}', - "virtual:compiler/fortran": '{{ compiler("fortran") }}', - "virtual:compiler/rust": '{{ compiler("rust") }}', + "virtual:compiler/c": "{{ compiler('c') }}", + "virtual:compiler/cpp": "{{ compiler('cxx') }}", + "virtual:compiler/fortran": "{{ compiler('fortran') }}", + "virtual:compiler/rust": "{{ compiler('rust') }}", "virtual:interface/blas": "{{ blas }}", } return (