diff --git a/setup.py b/setup.py index 39da8b8..3a58426 100644 --- a/setup.py +++ b/setup.py @@ -11,14 +11,18 @@ try: except Exception as e: print('ERROR: Failed to get version from "git describe --tags": %s: %s' % (type(e).__name__, e)) from __init__ import __version__ as fallback_version + + # Mark builds with unretrievable version (GitHub tarballs, etc.) as -dirty + if not fallback_version.endswith('-dirty'): + fallback_version += '-dirty' + print('Using fallback version of %r.' % fallback_version) version = fallback_version -else: - # Success. 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) +# 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) curdir = path.abspath(path.dirname(__file__))