Skip to content
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
Copy Markdown
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