code: def get_version():
      
      # Grab the first assignment to __version__
      version = None
      init_py = os.path.join(os.path.dirname(__file__),
                             'asv', '__init__.py')
      with open(init_py, 'r') as f:
          source = f.read()
      tree = ast.parse(source)
      for statement in tree.body:
          if (isinstance(statement, ast.Assign) and
              len(statement.targets) == 1 and
              statement.targets[0].id == '__version__'):
              version = statement.value.s
              break
  
      if not version:
          raise RuntimeError("Failed to parse version from {}".format(init_py))
  
      if 'dev' in version and not version.endswith('.dev'):
          raise RuntimeError("Dev version string in {} doesn't end in .dev".format(
              init_py))
  
      return version
docs: Parse current version number from __init__.py