summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorJonathan Lange <jml@canonical.com>2012-02-01 18:46:25 +0000
committerJonathan Lange <jml@canonical.com>2012-02-01 18:46:25 +0000
commitc4924ff01abc2805a137c27de7ea18747abdcd04 (patch)
treeebacc12013ef6084014ebbddbb73f86a5c00f24c /setup.py
parent6033d5b90991de13604f7de3ed6e42581b01d2c2 (diff)
parent29021cef8d10e194c1229b73c5388502b8c8aa74 (diff)
downloadsubunit-git-c4924ff01abc2805a137c27de7ea18747abdcd04.tar.gz
Merge trunk
Diffstat (limited to 'setup.py')
-rwxr-xr-xsetup.py27
1 files changed, 15 insertions, 12 deletions
diff --git a/setup.py b/setup.py
index 2038d04..a78eb99 100755
--- a/setup.py
+++ b/setup.py
@@ -9,23 +9,26 @@ except ImportError:
else:
extra = {
'install_requires': [
- 'testtools>=0.9.6',
+ 'testtools>=0.9.11',
]
}
-try:
+
+def _get_version_from_file(filename, start_of_line, split_marker):
+ """Extract version from file, giving last matching value or None"""
+ try:
+ return [x for x in open(filename)
+ if x.startswith(start_of_line)][-1].split(split_marker)[1].strip()
+ except (IOError, IndexError):
+ return None
+
+
+VERSION = (
# Assume we are in a distribution, which has PKG-INFO
- version_lines = [x for x in open('PKG-INFO').readlines()
- if x.startswith('Version:')]
- version_line = version_lines and version_lines[-1] or 'VERSION = 0.0'
- VERSION = version_line.split(':')[1].strip()
-
-except IOError:
+ _get_version_from_file('PKG-INFO', 'Version:', ':')
# Must be a development checkout, so use the Makefile
- version_lines = [x for x in open('Makefile').readlines()
- if x.startswith('VERSION')]
- version_line = version_lines and version_lines[-1] or 'VERSION = 0.0'
- VERSION = version_line.split('=')[1].strip()
+ or _get_version_from_file('Makefile', 'VERSION', '=')
+ or "0.0")
setup(