diff -Nru setuptools-66.1.1/debian/changelog setuptools-66.1.1/debian/changelog --- setuptools-66.1.1/debian/changelog 2023-01-27 07:49:44.000000000 +0100 +++ setuptools-66.1.1/debian/changelog 2023-10-25 12:01:45.000000000 +0200 @@ -1,3 +1,9 @@ +setuptools (66.1.1-1ubuntu0.1) lunar; urgency=medium + + * Make pkg_resources more forgiving of non-compliant versions (LP: #2008430) + + -- Benjamin Drung Wed, 25 Oct 2023 12:01:45 +0200 + setuptools (66.1.1-1) unstable; urgency=medium * New upstream version. diff -Nru setuptools-66.1.1/debian/patches/Make-pkg_resources-more-forgiving-of-non-compliant-versio.patch setuptools-66.1.1/debian/patches/Make-pkg_resources-more-forgiving-of-non-compliant-versio.patch --- setuptools-66.1.1/debian/patches/Make-pkg_resources-more-forgiving-of-non-compliant-versio.patch 1970-01-01 01:00:00.000000000 +0100 +++ setuptools-66.1.1/debian/patches/Make-pkg_resources-more-forgiving-of-non-compliant-versio.patch 2023-10-25 12:01:45.000000000 +0200 @@ -0,0 +1,105 @@ +From: Anderson Bravalheri +Date: Mon, 27 Feb 2023 20:00:27 +0000 +Subject: Make pkg_resources more forgiving of non-compliant versions + +Bug-Ubuntu: https://launchpad.net/bugs/2008430 +Origin: upstream, https://github.com/pypa/setuptools/pull/3839 +--- + pkg_resources/__init__.py | 63 ++++++++++++++++++++++++++++++++++++++++++++++- + 1 file changed, 62 insertions(+), 1 deletion(-) + +diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py +index 0ae951b..2a9f29b 100644 +--- a/pkg_resources/__init__.py ++++ b/pkg_resources/__init__.py +@@ -112,6 +112,9 @@ _namespace_handlers = None + _namespace_packages = None + + ++_PEP440_FALLBACK = re.compile(r"^v?(?P(?:[0-9]+!)?[0-9]+(?:\.[0-9]+)*)", re.I) ++ ++ + class PEP440Warning(RuntimeWarning): + """ + Used when there is an issue with a version or specifier not complying with +@@ -1389,6 +1392,38 @@ def safe_version(version): + return re.sub('[^A-Za-z0-9.]+', '-', version) + + ++def _forgiving_version(version): ++ """Fallback when ``safe_version`` is not safe enough ++ >>> parse_version(_forgiving_version('0.23ubuntu1')) ++ ++ >>> parse_version(_forgiving_version('0.23-')) ++ ++ >>> parse_version(_forgiving_version('0.-_')) ++ ++ >>> parse_version(_forgiving_version('42.+?1')) ++ ++ >>> parse_version(_forgiving_version('hello world')) ++ ++ """ ++ version = version.replace(' ', '.') ++ match = _PEP440_FALLBACK.search(version) ++ if match: ++ safe = match["safe"] ++ rest = version[len(safe):] ++ else: ++ safe = "0" ++ rest = version ++ local = f"sanitized.{_safe_segment(rest)}".strip(".") ++ return f"{safe}.dev0+{local}" ++ ++ ++def _safe_segment(segment): ++ """Convert an arbitrary string into a safe segment""" ++ segment = re.sub('[^A-Za-z0-9.]+', '-', segment) ++ segment = re.sub('-[^A-Za-z0-9]+', '-', segment) ++ return re.sub(r'\.[^A-Za-z0-9]+', '.', segment).strip(".-") ++ ++ + def safe_extra(extra): + """Convert an arbitrary string to a standard 'extra' name + +@@ -2628,7 +2663,7 @@ class Distribution: + @property + def hashcmp(self): + return ( +- self.parsed_version, ++ self._forgiving_parsed_version, + self.precedence, + self.key, + self.location, +@@ -2686,6 +2721,32 @@ class Distribution: + + return self._parsed_version + ++ @property ++ def _forgiving_parsed_version(self): ++ try: ++ return self.parsed_version ++ except packaging.version.InvalidVersion as ex: ++ self._parsed_version = parse_version(_forgiving_version(self.version)) ++ ++ notes = "\n".join(getattr(ex, "__notes__", [])) # PEP 678 ++ msg = f"""!!\n\n ++ ************************************************************************* ++ {str(ex)}\n{notes} ++ ++ This is a long overdue deprecation. ++ For the time being, `pkg_resources` will use `{self._parsed_version}` ++ as a replacement to avoid breaking existing environments, ++ but no future compatibility is guaranteed. ++ ++ If you maintain package {self.project_name} you should implement ++ the relevant changes to adequate the project to PEP 440 immediately. ++ ************************************************************************* ++ \n\n!! ++ """ ++ warnings.warn(msg, DeprecationWarning) ++ ++ return self._parsed_version ++ + @property + def version(self): + try: diff -Nru setuptools-66.1.1/debian/patches/series setuptools-66.1.1/debian/patches/series --- setuptools-66.1.1/debian/patches/series 2022-09-14 16:54:08.000000000 +0200 +++ setuptools-66.1.1/debian/patches/series 2023-10-25 12:01:45.000000000 +0200 @@ -14,3 +14,4 @@ sphinx-theme.diff no-sphinx-custom-icons.diff no-sphinx-hoverxref.diff +Make-pkg_resources-more-forgiving-of-non-compliant-versio.patch