code: def get_version():
      
      d = os.path.dirname(__file__)
      # get release number from VERSION
      with open(os.path.join(d, 'VERSION')) as f:
          vre = re.compile('.Version: (.+)$', re.M)
          version = vre.search(f.read()).group(1)
  
      if os.path.isdir(os.path.join(d, '.git')):
          # Get the version using "git describe".
          cmd = 'git describe --tags'
          try:
              git_version = check_output(cmd.split()).decode().strip()[1:]
          except CalledProcessError:
              print('Unable to get version number from git tags\n'
                    'Setting to x.x')
              git_version = 'x.x'
  
          # PEP440 compatibility
          if '-' in git_version:
              git_revision = check_output(['git', 'rev-parse', 'HEAD'])
              git_revision = git_revision.strip().decode('ascii')
              # add post0 if the version is released
              # otherwise add dev0 if the version is not yet released
              if ISRELEASED:
                  version += '.post0+' + git_revision[:7]
              else:
                  version += '.dev0+' + git_revision[:7]
  
      return version
docs: Get version from git and VERSION file.
  
      In the case where the version is not tagged in git, this function appends
      .post0+commit if the version has been released and .dev0+commit if the
      version has not yet been released.
  
      Derived from: https://github.com/Changaco/version.py