diff --git a/mypy/version.py b/mypy/version.py index 9c836b031cb52..091e99bec7f55 100644 --- a/mypy/version.py +++ b/mypy/version.py @@ -1 +1,11 @@ +import os +from mypy import git + __version__ = '0.4.6-dev' + +mypy_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) +if git.is_git_repo(mypy_dir) and git.have_git(): + __version__ += '-' + git.git_revision(mypy_dir).decode('utf-8') + if git.is_dirty(mypy_dir): + __version__ += '-dirty' +del mypy_dir diff --git a/setup.py b/setup.py index 3733f72800c62..f9c249fb7b984 100644 --- a/setup.py +++ b/setup.py @@ -31,19 +31,6 @@ '''.lstrip() -def cache_version_id(): - """Returns the version id to use for the incremental hash. - - If setup.py is run from a git repo, the git commit hash will be - included if possible. If not, then this function will fall back to - using the default version id from mypy/version.py.""" - if git.is_git_repo('.') and git.have_git(): - return __version__ + '-' + git.git_revision('.').decode('utf-8') - else: - # Default fallback - return __version__ - - def find_data_files(base, globs): """Find all interesting data files, for setup(data_files=) @@ -71,7 +58,7 @@ def pin_version(self): path = os.path.join(self.build_lib, 'mypy') self.mkpath(path) with open(os.path.join(path, 'version.py'), 'w') as stream: - stream.write('__version__ = "{}"\n'.format(cache_version_id())) + stream.write('__version__ = "{}"\n'.format(version)) def run(self): self.execute(self.pin_version, ())