code_junkie

Standard way to embed version into python package

Nov 13th, 2011
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. import foo
  2. print foo.version
  3.  
  4. __version__ = "$Revision: 63990 $"
  5. # $Source$
  6.  
  7. __version_info__ = ('1', '2', '3')
  8. __version__ = '.'.join(__version_info__)
  9.  
  10. __version__ = "3.6.5"
  11.  
  12. import re
  13. VERSIONFILE="myniftyapp/_version.py"
  14. verstrline = open(VERSIONFILE, "rt").read()
  15. VSRE = r"^__version__ = ['"]([^'"]*)['"]"
  16. mo = re.search(VSRE, verstrline, re.M)
  17. if mo:
  18. verstr = mo.group(1)
  19. else:
  20. raise RuntimeError("Unable to find version string in %s." % (VERSIONFILE,))
  21.  
  22. from _version import __version__
  23.  
  24. >>> django.VERSION
  25. (1, 1, 0, 'final', 0)
  26.  
  27. __version__ = '1.2.3'
  28. __version_info__ = tuple([ int(num) for num in __version__.split('.')])
Add Comment
Please, Sign In to add comment