diff --git a/setup.py b/setup.py index 7c5c9ae..666a9d2 100644 --- a/setup.py +++ b/setup.py @@ -9,20 +9,20 @@ import subprocess from os import path # Get version from Git tags. -try: - version = subprocess.check_output(['git', 'describe', '--tags']).decode('utf-8').strip() -except Exception as e: - print('ERROR: Failed to get version from "git describe --tags": %s: %s' % (type(e).__name__, e)) +with open('VERSION', encoding='utf-8') as f: + version = f.read().strip() - with open('VERSION') as f: - fallback_version = f.read().strip() - print('Using fallback version of %r.' % fallback_version) - version = fallback_version +try: + real_version = subprocess.check_output(['git', 'describe', '--tags']).decode('utf-8').strip() +except Exception as e: + print('ERROR: Failed to get Git version from "git describe --tags": %s: %s' % (type(e).__name__, e)) + real_version = version + '-dirty' # Write the version to disk. with open('__init__.py', 'w') as f: f.write('# Automatically generated by setup.py\n') f.write('__version__ = %r\n' % version) + f.write('real_version = %r\n' % real_version) curdir = path.abspath(path.dirname(__file__))