Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make mypy -V show git commit hash more often #2394

Merged
merged 3 commits into from
Nov 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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():
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When run from a repo, these seem to add maybe 30 msec to the mypy runtime when there is a warm cache. This looks like up to 6% slowdown, which is not terrible if most users are using a pip-installed version. However, this could be much worse on cold cache. Can you check the effect on mypy runtime when run straight after restart?

__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