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

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

merged 3 commits into from
Nov 3, 2016

Conversation

gvanrossum
Copy link
Member

Previously the git commit hash was only appended to __version__ by setup.py. Now we do this dynamically in mypy/version.py. This means the commit hash is also reported when run directly from the repo (e.g. python3 -m mypy -V from the repo root). It is also used by the cache in this case.

I didn't notice any slowdown. Notice the contents of version.py in distributions is still overwritten by setup.py so a properly installed version should not be executing any git commands at startup.

__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?

@gvanrossum
Copy link
Member Author

We chatted offline, the extra cost is not that much even with a cold cache (I tried sudo purge on OS X followed by running python3 -m mypy -c pass and it was pretty slow both with and without this change). I'm going to merge it.

@gvanrossum gvanrossum merged commit 42bb085 into master Nov 3, 2016
@gvanrossum gvanrossum deleted the gitversion branch November 3, 2016 19:27
@gvanrossum
Copy link
Member Author

Wondering if this went too far. I am now getting warnings when running python3 setup.py about the version:

/Users/guido/v35/lib/python3.5/site-packages/setuptools/dist.py:340: UserWarning: The version specified ('0.4.6-dev-06fd071cfa543a54e31529bffa515bcd32237b40') is an invalid version, this may not work as expected with newer versions of setuptools, pip, and PyPI. Please see PEP 440 for more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants