Skip to content

Commit

Permalink
Make mypy -V show git commit hash more often (#2394)
Browse files Browse the repository at this point in the history
  • Loading branch information
gvanrossum authored Nov 3, 2016
1 parent c954fa3 commit 42bb085
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
10 changes: 10 additions & 0 deletions mypy/version.py
Original file line number Diff line number Diff line change
@@ -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
15 changes: 1 addition & 14 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=)
Expand Down Expand Up @@ -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, ())
Expand Down

0 comments on commit 42bb085

Please sign in to comment.