Fixed version regexp to match "10devel"

Also normalized the result and made sure that if PostgreSQL ever starts
using just integer version numbers (as in "10") everything still works.
This commit is contained in:
Federico Di Gregorio 2017-02-04 14:21:07 +01:00
parent de8b335d80
commit 8b96bcddff

View File

@ -417,10 +417,12 @@ class psycopg_build_ext(build_ext):
pgversion = "7.4.0"
verre = re.compile(
r"(\d+)\.(\d+)(?:(?:\.(\d+))|(devel|(alpha|beta|rc)\d+))")
r"(\d+)(?:\.(\d+))?(?:(?:\.(\d+))|(devel|(?:alpha|beta|rc)\d+))?")
m = verre.match(pgversion)
if m:
pgmajor, pgminor, pgpatch = m.group(1, 2, 3)
if pgminor is None or not pgminor.isdigit():
pgminor = 0
if pgpatch is None or not pgpatch.isdigit():
pgpatch = 0
pgmajor = int(pgmajor)