summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2015-06-11 17:14:35 +0200
committerJulian Andres Klode <jak@debian.org>2015-06-11 19:52:21 +0200
commit165c3e534716c7f300a6419e2f0ccc331f63c0c9 (patch)
tree5c2f7b9f9609dd0aa257f1feb7830b44fd39cd72 /setup.py
parentf9fc74f216ebc613370b1b24a3e8ce935847b06c (diff)
downloadpython-apt-165c3e534716c7f300a6419e2f0ccc331f63c0c9.tar.gz
setup.py: Translate version number from Debian to PEP0440
Such a idiocy. LP: #1445949
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/setup.py b/setup.py
index f9d56386..b67443fd 100644
--- a/setup.py
+++ b/setup.py
@@ -24,6 +24,24 @@ try:
except ImportError:
print('W: [python%s] Sphinx import error.' % sys.version[:3])
+
+def get_version():
+ """Get a PEP 0440 compatible version string"""
+ version = os.environ.get('DEBVER')
+ version = version.replace("~alpha", ".a")
+ version = version.replace("~beta", ".b")
+ version = version.replace("~rc", ".rc")
+ version = version.replace("~exp", ".dev")
+ version = version.replace("ubuntu", "+ubuntu")
+ version = version.replace("tanglu", "+tanglu")
+ version = version.split("build")[0]
+
+ if "~" in version:
+ raise ValueError("Invalid version")
+
+ return version
+
+
# The apt_pkg module.
files = ['apt_pkgmodule.cc', 'acquire.cc', 'cache.cc', 'cdrom.cc',
'configuration.cc', 'depcache.cc', 'generic.cc', 'hashes.cc',
@@ -64,7 +82,7 @@ for key, value in cfg_vars.items():
setup(name="python-apt",
description="Python bindings for APT",
- version=os.environ.get('DEBVER'),
+ version=get_version(),
author="APT Development Team",
author_email="deity@lists.debian.org",
ext_modules=[apt_pkg, apt_inst],