mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-01 23:08:43 +01:00
dvc: version: use autogenerated file to properly report version
Fixes #620 Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
@@ -23,3 +23,4 @@ innosetup/config.ini
|
||||
|
||||
.coverage
|
||||
|
||||
dvc/version.py
|
||||
|
||||
+29
-4
@@ -5,18 +5,43 @@ Make your data science projects reproducible and shareable.
|
||||
"""
|
||||
import os
|
||||
|
||||
VERSION = '0.9.5'
|
||||
__version__ = '0.9.5'
|
||||
|
||||
PACKAGEPATH = os.path.abspath(os.path.dirname(__file__))
|
||||
HOMEPATH = os.path.dirname(PACKAGEPATH)
|
||||
VERSIONPATH = os.path.join(PACKAGEPATH, 'version.py')
|
||||
|
||||
if os.path.exists(os.path.join(HOMEPATH, 'setup.py')):
|
||||
# dvc is run directly from source without installation or
|
||||
# __version__ is called from setup.py
|
||||
if os.getenv('APPVEYOR_REPO_TAG', '').lower() != 'true' and os.getenv('TRAVIS_TAG', '') == '':
|
||||
# Dynamically update version
|
||||
try:
|
||||
import git
|
||||
repo = git.Repo(os.curdir, search_parent_directories=True)
|
||||
repo = git.Repo(HOMEPATH)
|
||||
sha = repo.head.object.hexsha
|
||||
short_sha = repo.git.rev_parse(sha, short=6)
|
||||
dirty = '.mod' if repo.is_dirty() else ''
|
||||
VERSION = '{}+{}{}'.format(VERSION, short_sha, dirty)
|
||||
__version__ = '{}+{}{}'.format(__version__, short_sha, dirty)
|
||||
|
||||
# Write a helper file, that will be installed with the package
|
||||
# and will provide a true version of the installed dvc
|
||||
with open(VERSIONPATH, 'w+') as fd:
|
||||
fd.write('# AUTOGENERATED by dvc/__init__.py')
|
||||
fd.write('version = "{}"'.format(__version__))
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
# Remove version.py so that it doesn't get into the release
|
||||
if os.path.exists(VERSIONPATH):
|
||||
os.unlink(VERSIONPATH)
|
||||
else:
|
||||
# dvc was installed with pip or something. Hopefully we have our
|
||||
# auto-generated version.py to help us provide a true version
|
||||
try:
|
||||
from dvc.version import version
|
||||
__version__ = version
|
||||
except:
|
||||
pass
|
||||
|
||||
__version__ = VERSION
|
||||
VERSION = __version__
|
||||
|
||||
Reference in New Issue
Block a user