The __version__ module is accessible via the sqlobject module.
3
'beta'
(3, 1, 0, 'beta', 2)
None
0
'3.1.0b2'
2
1
See the source for more information.