Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.

Commit 9382dfb

Browse files
committed
Add version gathering logic from pyehtapp / hydrachain
1 parent a1d5647 commit 9382dfb

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

ethereum/__init__.py

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,40 @@
1+
# -*- coding: utf-8 -*-
12
# ############# version ##################
23
from pkg_resources import get_distribution, DistributionNotFound
34
import os.path
5+
import subprocess
6+
import re
7+
8+
9+
GIT_DESCRIBE_RE = re.compile('^(?P<version>v\d+\.\d+\.\d+)-(?P<git>\d+-g[a-fA-F0-9]+(?:-dirty)?)$')
10+
11+
12+
__version__ = None
413
try:
5-
_dist = get_distribution('ethereum')
14+
_dist = get_distribution('pyethapp')
615
# Normalize case for Windows systems
716
dist_loc = os.path.normcase(_dist.location)
817
here = os.path.normcase(__file__)
9-
if not here.startswith(os.path.join(dist_loc, 'ethereum')):
18+
if not here.startswith(os.path.join(dist_loc, 'pyethapp')):
1019
# not installed, but there is another version that *is*
1120
raise DistributionNotFound
12-
except DistributionNotFound:
13-
__version__ = 'Please install this project with setup.py'
14-
else:
1521
__version__ = _dist.version
22+
except DistributionNotFound:
23+
pass
24+
25+
if not __version__:
26+
try:
27+
rev = subprocess.check_output(['git', 'describe', '--tags', '--dirty'],
28+
stderr=subprocess.STDOUT)
29+
match = GIT_DESCRIBE_RE.match(rev)
30+
if match:
31+
__version__ = "{}+git-{}".format(match.group("version"), match.group("git"))
32+
except:
33+
pass
34+
35+
if not __version__:
36+
__version__ = 'undefined'
37+
1638
# ########### endversion ##################
1739

1840
'''from ethereum import utils

0 commit comments

Comments
 (0)