3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-24 03:29:28 +01:00

setup: unconditionally write __init__.py; mark builds with unretrievable version as -dirty

Ref #259.
This commit is contained in:
James Lu 2016-07-03 00:39:10 -07:00
parent a9a6c22044
commit 7c5b87f4d2

View File

@ -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__))