mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-13 08:01:09 +00:00
fix: Use PEP440 compliant version in setup.py
Versions like `0.176ubuntu20.04.1` in Ubuntu are clearly not compliant with https://peps.python.org/pep-0440/. With setuptools 66, the versions of all packages visible in the Python environment *must* obey PEP440. Bug: https://launchpad.net/bugs/1991606 Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
This commit is contained in:
parent
0d94b5e747
commit
3bdb827516
15
setup.py
15
setup.py
@ -5,6 +5,19 @@ import glob
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
# look/set what version we have
|
# look/set what version we have
|
||||||
changelog = "debian/changelog"
|
changelog = "debian/changelog"
|
||||||
if os.path.exists(changelog):
|
if os.path.exists(changelog):
|
||||||
@ -67,7 +80,7 @@ data_files = [
|
|||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
setup(
|
setup(
|
||||||
name='ubuntu-dev-tools',
|
name='ubuntu-dev-tools',
|
||||||
version=version,
|
version=make_pep440_compliant(version),
|
||||||
scripts=scripts,
|
scripts=scripts,
|
||||||
packages=[
|
packages=[
|
||||||
'ubuntutools',
|
'ubuntutools',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user