from pkg_resources import get_distribution, DistributionNotFound
import os.path
try:
    _dist = get_distribution('devp2p')
    # Normalize case for Windows systems
    dist_loc = os.path.normcase(_dist.location)
    here = os.path.normcase(__file__)
    if not here.startswith(os.path.join(dist_loc, 'devp2p')):
        # not installed, but there is another version that *is*
        raise DistributionNotFound
except DistributionNotFound:
    __version__ = 'dirty'
else:
    __version__ = _dist.version
# ########### endversion ##################

from pkg_resources import get_distribution, DistributionNotFound
import os.path
import subprocess
import re


GIT_DESCRIBE_RE = re.compile('^(?P<version>v\d+\.\d+\.\d+)-(?P<git>\d+-g[a-fA-F0-9]+(?:-dirty)?)$')


__version__ = None
try:
    _dist = get_distribution('pyethapp')
    # Normalize case for Windows systems
    dist_loc = os.path.normcase(_dist.location)
    here = os.path.normcase(__file__)
    if not here.startswith(os.path.join(dist_loc, 'pyethapp')):
        # not installed, but there is another version that *is*
        raise DistributionNotFound
    __version__ = _dist.version
except DistributionNotFound:
    pass

if not __version__:
    try:
        rev = subprocess.check_output(['git', 'describe', '--tags', '--dirty'],
                                      stderr=subprocess.STDOUT)
        match = GIT_DESCRIBE_RE.match(rev)
        if match:
            __version__ = "{}+git-{}".format(match.group("version"), match.group("git"))
    except:
        pass

if not __version__:
    __version__ = 'undefined'

# ########### endversion ##################

Use version extraction code from pyethapp / pyethereum
Use version extraction code from pyethapp / pyethereum
  from pkg_resources import get_distribution, DistributionNotFound
  import os.path
+ import subprocess
+ import re
+ 
+ 
+ GIT_DESCRIBE_RE = re.compile('^(?P<version>v\d+\.\d+\.\d+)-(?P<git>\d+-g[a-fA-F0-9]+(?:-dirty)?)$')
+ 
+ 
+ __version__ = None
  try:
-     _dist = get_distribution('devp2p')
+     _dist = get_distribution('pyethapp')
      # Normalize case for Windows systems
      dist_loc = os.path.normcase(_dist.location)
      here = os.path.normcase(__file__)
-     if not here.startswith(os.path.join(dist_loc, 'devp2p')):
+     if not here.startswith(os.path.join(dist_loc, 'pyethapp')):
          # not installed, but there is another version that *is*
          raise DistributionNotFound
+     __version__ = _dist.version
  except DistributionNotFound:
+     pass
+ 
+ if not __version__:
+     try:
+         rev = subprocess.check_output(['git', 'describe', '--tags', '--dirty'],
+                                       stderr=subprocess.STDOUT)
+         match = GIT_DESCRIBE_RE.match(rev)
+         if match:
+             __version__ = "{}+git-{}".format(match.group("version"), match.group("git"))
+     except:
+         pass
+ 
+ if not __version__:
-     __version__ = 'dirty'
+     __version__ = 'undefined'
+ 
- else:
-     __version__ = _dist.version
  # ########### endversion ##################
  
Use version extraction code from pyethapp / pyethereum
## Code Before:
from pkg_resources import get_distribution, DistributionNotFound
import os.path
try:
    _dist = get_distribution('devp2p')
    # Normalize case for Windows systems
    dist_loc = os.path.normcase(_dist.location)
    here = os.path.normcase(__file__)
    if not here.startswith(os.path.join(dist_loc, 'devp2p')):
        # not installed, but there is another version that *is*
        raise DistributionNotFound
except DistributionNotFound:
    __version__ = 'dirty'
else:
    __version__ = _dist.version
# ########### endversion ##################

## Instruction:
Use version extraction code from pyethapp / pyethereum
## Code After:
from pkg_resources import get_distribution, DistributionNotFound
import os.path
import subprocess
import re


GIT_DESCRIBE_RE = re.compile('^(?P<version>v\d+\.\d+\.\d+)-(?P<git>\d+-g[a-fA-F0-9]+(?:-dirty)?)$')


__version__ = None
try:
    _dist = get_distribution('pyethapp')
    # Normalize case for Windows systems
    dist_loc = os.path.normcase(_dist.location)
    here = os.path.normcase(__file__)
    if not here.startswith(os.path.join(dist_loc, 'pyethapp')):
        # not installed, but there is another version that *is*
        raise DistributionNotFound
    __version__ = _dist.version
except DistributionNotFound:
    pass

if not __version__:
    try:
        rev = subprocess.check_output(['git', 'describe', '--tags', '--dirty'],
                                      stderr=subprocess.STDOUT)
        match = GIT_DESCRIBE_RE.match(rev)
        if match:
            __version__ = "{}+git-{}".format(match.group("version"), match.group("git"))
    except:
        pass

if not __version__:
    __version__ = 'undefined'

# ########### endversion ##################
