Changeset 874


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.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.x/setup.py

    r860 r874  
    4545import os
    4646import platform
     47import re
    4748import warnings
    4849try:
     
    7879def pg_version():
    7980    """Return the PostgreSQL version as a tuple of integers."""
    80     parts = []
    81     for part in pg_config('version').split()[-1].split('.'):
    82         if part.isdigit():
    83             part = int(part)
    84         parts.append(part)
    85     return tuple(parts or [8, 3])
     81    match = re.search(r'(\d+)\.(\d+)', pg_config('version'))
     82    if match:
     83        return tuple(map(int, match.groups()))
     84    return (8, 3)
    8685
    8786
  • 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.