diff options
author | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2020-03-23 13:07:20 -0400 |
---|---|---|
committer | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2020-03-23 13:07:20 -0400 |
commit | f168ac9ac958a60e3c8fd656649939061f617501 (patch) | |
tree | d464a1940b8403872ba3654e3b73e176beb620c7 /setup.py | |
parent | da3e51194c649b29b98f23c1af1b50c8578cdd5c (diff) | |
download | b4-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.py | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -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', |