summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorKonstantin Ryabitsev <konstantin@linuxfoundation.org>2020-03-23 13:07:20 -0400
committerKonstantin Ryabitsev <konstantin@linuxfoundation.org>2020-03-23 13:07:20 -0400
commitf168ac9ac958a60e3c8fd656649939061f617501 (patch)
treed464a1940b8403872ba3654e3b73e176beb620c7 /setup.py
parentda3e51194c649b29b98f23c1af1b50c8578cdd5c (diff)
downloadb4-f168ac9ac958a60e3c8fd656649939061f617501.tar.gz
Use a better single-sourced version setup
Fun read: https://packaging.python.org/guides/single-sourcing-package-version/ Anyway, I hated this way the least. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/setup.py b/setup.py
index 5b37505..ed24367 100644
--- a/setup.py
+++ b/setup.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
import os
-import b4
+import re
from setuptools import setup
# Utility function to read the README file.
@@ -14,10 +14,18 @@ def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
+def find_version(source):
+ version_file = read(source)
+ version_match = re.search(r"^__VERSION__ = ['\"]([^'\"]*)['\"]", version_file, re.M)
+ if version_match:
+ return version_match.group(1)
+ raise RuntimeError("Unable to find version string.")
+
+
NAME = 'b4'
setup(
- version=b4.VERSION,
+ version=find_version('b4/__init__.py'),
url='https://git.kernel.org/pub/scm/utils/b4/b4.git',
name=NAME,
description='A tool to work with public-inbox and patch archives',