Skip to content

Commit

Permalink
Let setup understand Postgres beta versions
Browse files Browse the repository at this point in the history
Postgres versions such as "PostgreSQL 9.5beta1" were not handled properly,
because the "5beta1" part of the version was not converted to an int.
  • Loading branch information
Cito committed Apr 16, 2016
1 parent cccedf0 commit 9429728
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

import os
import platform
import re
import warnings
try:
from setuptools import setup
Expand Down Expand Up @@ -78,12 +79,10 @@ def pg_config(s):

def pg_version():
"""Return the PostgreSQL version as a tuple of integers."""
parts = []
for part in pg_config('version').split()[-1].split('.'):
if part.isdigit():
part = int(part)
parts.append(part)
return tuple(parts or [9, 0])
match = re.search(r'(\d+)\.(\d+)', pg_config('version'))
if match:
return tuple(map(int, match.groups()))
return (9, 0)


pg_version = pg_version()
Expand Down

0 comments on commit 9429728

Please sign in to comment.