Improve regexp of get__version__()

Rewrite the regular expression so that version numbers are correctly
extracted from a string such as '3.2.dev'. The regexp that we were
using returned '3.2.', whose trailing period caused str_to_version()
to raise ValueError (invalid literal for int() with base 10: '').
Thanks to Felipe Gallego for reporting this.
Add Felipe Gallego