version.py 795 B

123456789101112131415161718192021222324252627
  1. # Copyright (c) OpenMMLab. All rights reserved.
  2. __version__ = '3.0.0'
  3. short_version = __version__
  4. def parse_version_info(version_str):
  5. """Parse a version string into a tuple.
  6. Args:
  7. version_str (str): The version string.
  8. Returns:
  9. tuple[int | str]: The version info, e.g., "1.3.0" is parsed into
  10. (1, 3, 0), and "2.0.0rc1" is parsed into (2, 0, 0, 'rc1').
  11. """
  12. version_info = []
  13. for x in version_str.split('.'):
  14. if x.isdigit():
  15. version_info.append(int(x))
  16. elif x.find('rc') != -1:
  17. patch_version = x.split('rc')
  18. version_info.append(int(patch_version[0]))
  19. version_info.append(f'rc{patch_version[1]}')
  20. return tuple(version_info)
  21. version_info = parse_version_info(__version__)