Description: Backport uses of ‘semver’ library to custom wrapper class.
 .
 The ‘semver’ library has breaking API changes in version “3.0”, which is what
 ‘changelog-chug’ depends on. But currently in Debian (bug#NNN), no later than
 version “2.10” is available.
 .
 We patch the ‘changelog-chug’ source to use a back-ported custom wrapper class
 ‘VersionInfoWithV3Parse’, to allow it to work while Debian still has the
 obsolete ‘semver’ version.
Author: Ben Finney <bignose@debian.org>
Bug-Debian: https://bugs.debian.org/1081140
Last-Update: 2024-10-26

diff --git old/pyproject.toml new/pyproject.toml
--- old/pyproject.toml
+++ new/pyproject.toml
@@ -34,7 +34,7 @@ dependencies = [

     # Semantic Versioning implementation.
     # Documentation: <URL:https://python-semver.readthedocs.io/>.
-    "semver >= 3.0.0",
+    "semver >= 2.10.0",
 
     # Python Documentation Utilities.
     # Documentation: <URL:https://docutils.sourceforge.io/docs/>.
@@ -154,7 +154,7 @@ requires = [
 
     # Semantic Versioning implementation.
     # Documentation: <URL:https://python-semver.readthedocs.io/>.
-    "semver >= 3.0.0",
+    "semver >= 2.10.0",
 
     # Python Documentation Utilities.
     # Documentation: <URL:https://docutils.sourceforge.io/docs/>.
diff --git old/src/chug/model.py new/src/chug/model.py
--- old/src/chug/model.py
+++ new/src/chug/model.py
@@ -12,7 +12,7 @@ import datetime
 import re
 import textwrap
 
-import semver
+from .semver_parse_backport import VersionInfoWithV3Parse
 
 
 class VersionInvalidError(ValueError):
@@ -107,7 +107,8 @@ class ChangeLogEntry:
             return None
 
         try:
-            __ = semver.Version.parse(value, optional_minor_and_patch=True)
+            __ = VersionInfoWithV3Parse.parse(
+                value, optional_minor_and_patch=True)
         except (TypeError, ValueError) as exc:
             raise VersionInvalidError(value) from exc
 
diff --git old/src/chug/parsers/core.py new/src/chug/parsers/core.py
--- old/src/chug/parsers/core.py
+++ new/src/chug/parsers/core.py
@@ -10,9 +10,8 @@
 import collections
 import re
 
-import semver
-
 from ..model import rfc822_person_regex
+from ..semver_parse_backport import VersionInfoWithV3Parse
 
 
 class InvalidFormatError(ValueError):
@@ -139,15 +138,15 @@ class VersionFormatInvalidError(ValueError):
 
 
 def get_version_from_version_text(version_text):
-    """ Get the `semver.Version` representation of `version_text`
+    """ Get the `semver.VersionInfo` representation of `version_text`
 
         :param version_text:
-        :return: A `semver.Version` instance representing the version.
+        :return: A `semver.VersionInfo` instance representing the version.
         :raises VersionFormatInvalidError: If `version_text` does not parse as
             a Semantic Version value.
         """
     try:
-        version = semver.Version.parse(
+        version = VersionInfoWithV3Parse.parse(
             version_text, optional_minor_and_patch=True)
     except ValueError as exc:
         raise VersionFormatInvalidError(version_text) from exc
diff --git old/test/chug/test_parsers.py new/test/test_parsers.py
--- old/test/chug/test_parsers.py
+++ new/test/chug/test_parsers.py
@@ -10,7 +10,6 @@
 import re
 import textwrap
 
-import semver
 import testscenarios
 import testtools
 
@@ -20,6 +19,7 @@ from chug.parsers.core import (
     VersionFormatInvalidError,
 )
 import chug.parsers.core
+from chug.semver_parse_backport import VersionInfoWithV3Parse
 
 from .. import (
     make_expected_error_context,
@@ -300,37 +300,37 @@ class get_version_from_version_text_TestCase(
         ('major-only', {
             'test_args': ["1"],
             'test_kwargs': {},
-            'expected_result': semver.Version.parse(
+            'expected_result': VersionInfoWithV3Parse.parse(
                 "1", optional_minor_and_patch=True),
         }),
         ('major-and-minor-only', {
             'test_args': ["1.5"],
             'test_kwargs': {},
-            'expected_result': semver.Version.parse(
+            'expected_result': VersionInfoWithV3Parse.parse(
                 "1.5", optional_minor_and_patch=True),
         }),
         ('major-minor-patch', {
             'test_args': ["1.5.3"],
             'test_kwargs': {},
-            'expected_result': semver.Version.parse(
+            'expected_result': VersionInfoWithV3Parse.parse(
                 "1.5.3", optional_minor_and_patch=True),
         }),
         ('major-minor-patch-prerelease', {
             'test_args': ["1.5.3-beta2"],
             'test_kwargs': {},
-            'expected_result': semver.Version.parse(
+            'expected_result': VersionInfoWithV3Parse.parse(
                 "1.5.3-beta2", optional_minor_and_patch=True),
         }),
         ('major-minor-patch-build', {
             'test_args': ["1.5.3+d3adb33f"],
             'test_kwargs': {},
-            'expected_result': semver.Version.parse(
+            'expected_result': VersionInfoWithV3Parse.parse(
                 "1.5.3+d3adb33f", optional_minor_and_patch=True),
         }),
         ('major-minor-build', {
             'test_args': ["1.5+d3adb33f"],
             'test_kwargs': {},
-            'expected_result': semver.Version.parse(
+            'expected_result': VersionInfoWithV3Parse.parse(
                 "1.5+d3adb33f", optional_minor_and_patch=True),
         }),
     ]
diff --git old/test/test_parsers_rest.py new/test/test_parsers_rest.py
--- old/test/chug/test_parsers_rest.py
+++ new/test/chug/test_parsers_rest.py
@@ -14,12 +14,12 @@ import unittest.mock
 import docutils.core
 import docutils.nodes
 import docutils.utils
-import semver
 import testscenarios
 import testtools
 
 import chug.model
 import chug.parsers.rest
+from chug.semver_parse_backport import VersionInfoWithV3Parse
 
 from .. import make_expected_error_context
 
@@ -2105,7 +2105,7 @@ def make_rest_document_test_scenarios():
     for (__, scenario) in scenarios:
         if 'expected_versions_text' in scenario:
             scenario['expected_versions'] = [
-                semver.Version.parse(
+                VersionInfoWithV3Parse.parse(
                     version_text, optional_minor_and_patch=True)
                 for version_text in scenario['expected_versions_text']
             ]


Local variables:
coding: utf-8
mode: diff
time-stamp-format: "%:y-%02m-%02d"
time-stamp-start: "^Last-Update:[ 	]+"
time-stamp-end: "$"
time-stamp-line-limit: 20
End:
vim: fileencoding=utf-8 filetype=diff :
