From 90aa8f34a1cdd174de678d9f76113278bc2488e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Wed, 11 May 2022 00:39:35 +0200 Subject: [PATCH] fixup! Adhere to PEP 685 when evaluating markers with extras --- packaging/markers.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packaging/markers.py b/packaging/markers.py index 1d61adaff..03d8cdefc 100644 --- a/packaging/markers.py +++ b/packaging/markers.py @@ -5,7 +5,6 @@ import operator import os import platform -import re import sys from typing import Any, Callable, Dict, List, Optional, Tuple, Union @@ -22,6 +21,7 @@ ) from .specifiers import InvalidSpecifier, Specifier +from .utils import canonicalize_name __all__ = [ "InvalidMarker", @@ -223,8 +223,10 @@ def _get_env(environment: Dict[str, str], name: str) -> str: def _normalize(*values: str, key: str) -> Tuple[str, ...]: # PEP 685 – Comparison of extra names for optional distribution dependencies # https://peps.python.org/pep-0685/ + # > When comparing extra names, tools MUST normalize the names being + # > compared using the semantics outlined in PEP 503 for names if key == "extra": - return tuple(re.sub(r"[-_.]+", "-", v).lower() for v in values) + return tuple(canonicalize_name(v) for v in values) # other environment markes don't have such standards return values