code: def getVersionFromArchiveId(git_archive_id='$Format:%ct %d$'):
      
      # mangle the magic string to make sure it is not replaced by git archive
      if not git_archive_id.startswith('$For''mat:'):
          # source was modified by git archive, try to parse the version from
          # the value of git_archive_id
  
          match = re.search(r'tag:\s*v([^,)]+)', git_archive_id)
          if match:
              # archived revision is tagged, use the tag
              return gitDescribeToPep440(match.group(1))
  
          # archived revision is not tagged, use the commit date
          tstamp = git_archive_id.strip().split()[0]
          d = datetime.datetime.utcfromtimestamp(int(tstamp))
          return d.strftime('%Y.%m.%d')
      return None
docs: Extract the tag if a source is from git archive.
  
          When source is exported via `git archive`, the git_archive_id init value is modified
          and placeholders are expanded to the "archived" revision:
  
              %ct: committer date, UNIX timestamp
              %d: ref names, like the --decorate option of git-log
  
          See man gitattributes(5) and git-log(1) (PRETTY FORMATS) for more details.