version.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
  2. # For details: https://bitbucket.org/ned/coveragepy/src/default/NOTICE.txt
  3. """The version and URL for coverage.py"""
  4. # This file is exec'ed in setup.py, don't import anything!
  5. # Same semantics as sys.version_info.
  6. version_info = (4, 2, 0, 'final', 0)
  7. def _make_version(major, minor, micro, releaselevel, serial):
  8. """Create a readable version string from version_info tuple components."""
  9. assert releaselevel in ['alpha', 'beta', 'candidate', 'final']
  10. version = "%d.%d" % (major, minor)
  11. if micro:
  12. version += ".%d" % (micro,)
  13. if releaselevel != 'final':
  14. short = {'alpha': 'a', 'beta': 'b', 'candidate': 'rc'}[releaselevel]
  15. version += "%s%d" % (short, serial)
  16. return version
  17. def _make_url(major, minor, micro, releaselevel, serial):
  18. """Make the URL people should start at for this version of coverage.py."""
  19. url = "https://coverage.readthedocs.io"
  20. if releaselevel != 'final':
  21. # For pre-releases, use a version-specific URL.
  22. url += "/en/coverage-" + _make_version(major, minor, micro, releaselevel, serial)
  23. return url
  24. __version__ = _make_version(*version_info)
  25. __url__ = _make_url(*version_info)