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

ENH: Adding pd.__git_version__ to point to git sha commit (#21295) #21680

Closed
wants to merge 10 commits into from
2 changes: 2 additions & 0 deletions doc/source/whatsnew/v0.24.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ Other Enhancements
- :func:`~DataFrame.to_csv` and :func:`~DataFrame.to_json` now support ``compression='infer'`` to infer compression based on filename (:issue:`15008`)
- :func:`to_timedelta` now supports iso-formated timedelta strings (:issue:`21877`)
- :class:`Series` and :class:`DataFrame` now support :class:`Iterable` in constructor (:issue:`2193`)
- New attribute :attr:`__git_version__` will return git commit sha of current build
Copy link
Contributor

Choose a reason for hiding this comment

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

add the issue ref here

-

.. _whatsnew_0240.api_breaking:

Expand Down
1 change: 1 addition & 0 deletions pandas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
from ._version import get_versions
v = get_versions()
__version__ = v.get('closest-tag', v['version'])
__git_version__ = v.get('full-revisionid')
Copy link
Contributor

Choose a reason for hiding this comment

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

is this what dask does? this will be None in the built version I think

Choose a reason for hiding this comment

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

Is there a way I can create a built version locally and test it out? @jreback

Copy link
Contributor

Choose a reason for hiding this comment

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

python setup.py bdist_wheel, and then install that wheel in a new env.

Choose a reason for hiding this comment

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

Created wheel from above command (https://www.dropbox.com/s/3ieyl07ctcsja9u/pandas-0.24.0.dev0%2B373.g942172546-cp36-cp36m-macosx_10_7_x86_64.whl?dl=0) and it showed git_version correctly

>>> import pandas as pd
>>> pd.__version__
'0.24.0.dev0+373.g942172546'
>>> pd.__git_version__
'9421725461061b55bc84e388d3952957d9b0cd83'

del get_versions, v

# module level doc-string
Expand Down
9 changes: 9 additions & 0 deletions pandas/tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pytest
import os
import collections
import string
from functools import partial

import numpy as np
Expand All @@ -12,6 +13,7 @@
from pandas.core import ops
from pandas.io.common import _get_handle
import pandas.util.testing as tm
import pandas as pd


def test_get_callable_name():
Expand Down Expand Up @@ -165,3 +167,10 @@ def test_compression_warning(compression_only):
check_stacklevel=False):
with f:
df.to_csv(f, compression=compression_only)


def test_git_version():
# GH 21295
git_version = pd.__git_version__
Copy link
Contributor

Choose a reason for hiding this comment

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

This will fail when built (which we test on pandas-ci), as the git_version will be None.

Copy link
Contributor

Choose a reason for hiding this comment

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

does this actually run when pandas is installed after tagging?
iow need to tag (locally) then build a release and install and pd.test()

Copy link
Member

@alimcmaster1 alimcmaster1 Sep 18, 2018

Choose a reason for hiding this comment

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

Looks like it will, I ran:
python setup.py bdist_wheel
and installed that wheel in a fresh virtual env.
pd.__git_version__ then return the git sha of commit

assert len(git_version) == 40
assert all(c in string.hexdigits for c in git_version)