diff -Nru python-debian-0.1.36ubuntu1/debian/changelog python-debian-0.1.36ubuntu1.1/debian/changelog --- python-debian-0.1.36ubuntu1/debian/changelog 2020-04-08 07:17:21.000000000 +0200 +++ python-debian-0.1.36ubuntu1.1/debian/changelog 2023-04-25 20:39:33.000000000 +0200 @@ -1,3 +1,9 @@ +python-debian (0.1.36ubuntu1.1) focal; urgency=medium + + * Make Python version PEP440 compliant (LP: #1991606) + + -- Benjamin Drung Tue, 25 Apr 2023 20:39:33 +0200 + python-debian (0.1.36ubuntu1) focal; urgency=medium * lib/debian/doc-debtags: Change shebang to python3. diff -Nru python-debian-0.1.36ubuntu1/debian/make_pep440_compliant python-debian-0.1.36ubuntu1.1/debian/make_pep440_compliant --- python-debian-0.1.36ubuntu1/debian/make_pep440_compliant 1970-01-01 01:00:00.000000000 +0100 +++ python-debian-0.1.36ubuntu1.1/debian/make_pep440_compliant 2023-04-25 20:39:26.000000000 +0200 @@ -0,0 +1,24 @@ +#!/usr/bin/python3 + +import re +import sys + + +def make_pep440_compliant(version: str) -> str: + """Convert the version into a PEP440 compliant version.""" + public_version_re = re.compile( + r"^([0-9][0-9.]*(?:(?:a|b|rc|.post|.dev)[0-9]+)*)\+?" + ) + _, public, local = public_version_re.split(version, maxsplit=1) + if not local: + return version + sanitized_local = re.sub("[+~]+", ".", local).strip(".") + pep440_version = f"{public}+{sanitized_local}" + assert re.match( + "^[a-zA-Z0-9.]+$", sanitized_local + ), f"'{pep440_version}' not PEP440 compliant" + return pep440_version + + +if __name__ == "__main__": + print(make_pep440_compliant(sys.argv[1])) diff -Nru python-debian-0.1.36ubuntu1/debian/rules python-debian-0.1.36ubuntu1.1/debian/rules --- python-debian-0.1.36ubuntu1/debian/rules 2020-04-08 07:17:21.000000000 +0200 +++ python-debian-0.1.36ubuntu1.1/debian/rules 2023-04-25 20:39:26.000000000 +0200 @@ -13,7 +13,7 @@ dh $@ --with python2,python3 --buildsystem pybuild %.py: %.py.in debian/changelog - sed -e 's/__CHANGELOG_VERSION__/$(DEB_VERSION)/' < $< > $@ + sed -e 's/__CHANGELOG_VERSION__/$(shell debian/make_pep440_compliant "$(DEB_VERSION)")/' < $< > $@ override_dh_auto_build: lib/debian/_version.py dh_auto_build