Changeset 874 for trunk/setup.py


Ignore:
Timestamp:
Apr 16, 2016, 3:05:28 AM (3 years ago)
Author:
cito
Message:

Let setup understand Postgres beta versions

Postgres versions such as "PostgreSQL 9.5beta1" were not handled properly,
because the "5beta1" part of the version was not converted to an int.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/setup.py

    r873 r874  
    4646import os
    4747import platform
     48import re
    4849import warnings
    4950try:
     
    7980def pg_version():
    8081    """Return the PostgreSQL version as a tuple of integers."""
    81     parts = []
    82     for part in pg_config('version').split()[-1].split('.'):
    83         if part.isdigit():
    84             part = int(part)
    85         parts.append(part)
    86     return tuple(parts or [9, 0])
     82    match = re.search(r'(\d+)\.(\d+)', pg_config('version'))
     83    if match:
     84        return tuple(map(int, match.groups()))
     85    return (9, 0)
    8786
    8887
Note: See TracChangeset for help on using the changeset viewer.