code: def get_version(version_tuple):
      
      if version_tuple[3] == FINAL and version_tuple[4] != 0:
          raise Exception(
              'Project version number misconfigured:\n'
              '   version may not be final and have segment number.')
  
      if version_tuple[3] not in (DEV, FINAL) and version_tuple[4] == 0:
          raise Exception(
              'Project version number misconfigured:\n'
              '   version must have segment number.')
  
      if version_tuple[3] == DEV:
          segment_num = get_git_changeset()
      else:
          segment_num = str(abs(version_tuple[4]))
  
      # X.X.X
      sem_ver = ".".join([
          str(abs(int(number)))
          for number in version_tuple[:3]
      ])
  
      if version_tuple[3] != FINAL:
          if version_tuple[3] in (ALPHA, BETA, RC):
              sem_ver = "%s%s%s" % (sem_ver, version_tuple[3], segment_num)
          elif version_tuple[3] in (DEV, POST):
              sem_ver = "%s%s%s%s" % (
                  sem_ver, SEPARATOR, version_tuple[3], segment_num)
          else:
              raise Exception(
                  'Project version number misconfigured:\n'
                  '   Unrecognized release type')
  
      return sem_ver
docs: Convert 4-tuple into a PEP 440 compliant string.