Skip to content

Commit 3a48a8b

Browse files
committed
Add a __revision__ variable to pytest_dependency.py.
1 parent 3deb25f commit 3a48a8b

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
*~
33
.cache/
44
__pycache__/
5+
/.gitrevision
56
/MANIFEST
67
/build/
78
/dist/

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ build:
88
test: build
99
PYTHONPATH=$(BUILDDIR)/lib $(PYTHON) -m pytest tests
1010

11-
sdist: python2_6.patch doc-html
11+
sdist: python2_6.patch .gitrevision doc-html
1212
$(PYTHON) setup.py sdist
1313

1414
doc-html:
@@ -37,9 +37,11 @@ distclean: clean
3737
rm -f python2_6.patch
3838
$(MAKE) -C doc distclean
3939

40+
.gitrevision:
41+
git describe --always --dirty > .gitrevision
4042

4143
python2_6.patch:
4244
git diff `git merge-base master python2_6` python2_6 > $@
4345

4446

45-
.PHONY: build test sdist doc-html doc-pdf doc-dist clean distclean
47+
.PHONY: build test sdist doc-html doc-pdf doc-dist clean distclean .gitrevision

pytest_dependency.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""$DOC"""
22

33
__version__ = "$VERSION"
4+
__revision__ = "$REVISION"
45

56
import pytest
67

setup.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,13 @@ def make_release_tree(self, base_dir, files):
3939
if not self.dry_run:
4040
src = "pytest_dependency.py"
4141
dest = os.path.join(base_dir, src)
42+
gitrevfile = ".gitrevision"
4243
if hasattr(os, 'link') and os.path.exists(dest):
4344
os.unlink(dest)
4445
subst = {'DOC': __doc__, 'VERSION': __version__}
46+
if os.path.exists(gitrevfile):
47+
with open(gitrevfile, "rt") as f:
48+
subst['REVISION'] = f.readline().strip()
4549
_filter_file(src, dest, subst)
4650

4751

0 commit comments

Comments
 (0)