|
| 1 | +# -*- coding: utf-8 -*- |
1 | 2 | # ############# version ##################
|
2 | 3 | from pkg_resources import get_distribution, DistributionNotFound
|
3 | 4 | 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 |
4 | 13 | try:
|
5 |
| - _dist = get_distribution('ethereum') |
| 14 | + _dist = get_distribution('pyethapp') |
6 | 15 | # Normalize case for Windows systems
|
7 | 16 | dist_loc = os.path.normcase(_dist.location)
|
8 | 17 | 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')): |
10 | 19 | # not installed, but there is another version that *is*
|
11 | 20 | raise DistributionNotFound
|
12 |
| -except DistributionNotFound: |
13 |
| - __version__ = 'Please install this project with setup.py' |
14 |
| -else: |
15 | 21 | __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 | + |
16 | 38 | # ########### endversion ##################
|
17 | 39 |
|
18 | 40 | '''from ethereum import utils
|
|
0 commit comments