`text` as hatchling writes it
(text: str, extra: str | None = None)
| 63 | |
| 64 | |
| 65 | def requirement(text: str, extra: str | None = None) -> str: |
| 66 | """`text` as hatchling writes it""" |
| 67 | match = re.fullmatch(r"([\w.-]+) *(\[.*?\])? *([^;]*?) *(?:; *(.*))?", text) |
| 68 | assert match, text |
| 69 | name, extras, bounds, marker = match.groups("") |
| 70 | marker = marker.replace('"', "'") |
| 71 | if extra: |
| 72 | marker = (f"({marker}) and " if marker else "") + f"extra == '{extra}'" |
| 73 | name = re.sub(r"[-_.]+", "-", name).lower() |
| 74 | return name + extras + version_bounds(bounds) + (f"; {marker}" if marker else "") |
| 75 | |
| 76 | |
| 77 | def expected_metadata(pyproject: dict[str, Any], version: str) -> tuple[list[str], str]: |
no test coverage detected