Skip to content

Commit 1c5d75d

Browse files
committed
chore: drop Postgres version parsing in setup.py
The macro is in the include files, no idea why parsing it from pg_config was needed.
1 parent 895b48d commit 1c5d75d

File tree

1 file changed

+2
-29
lines changed

1 file changed

+2
-29
lines changed

setup.py

+2-29
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929

3030
import os
3131
import sys
32-
import re
3332
import subprocess
3433
from setuptools import setup, Extension
3534
from distutils.command.build_ext import build_ext
@@ -381,34 +380,8 @@ def finalize_options(self):
381380
if token.startswith("-I"):
382381
self.include_dirs.append(token[2:])
383382

384-
pgversion = pg_config_helper.query("version").split()[1]
385-
386-
verre = re.compile(
387-
r"(\d+)(?:\.(\d+))?(?:(?:\.(\d+))|(devel|(?:alpha|beta|rc)\d+))?")
388-
m = verre.match(pgversion)
389-
if m:
390-
pgmajor, pgminor, pgpatch = m.group(1, 2, 3)
391-
# Postgres >= 10 doesn't have pgminor anymore.
392-
pgmajor = int(pgmajor)
393-
if pgmajor >= 10:
394-
pgminor, pgpatch = None, pgminor
395-
if pgminor is None or not pgminor.isdigit():
396-
pgminor = 0
397-
if pgpatch is None or not pgpatch.isdigit():
398-
pgpatch = 0
399-
pgminor = int(pgminor)
400-
pgpatch = int(pgpatch)
401-
else:
402-
sys.stderr.write(
403-
f"Error: could not determine PostgreSQL version from "
404-
f"'{pgversion}'")
405-
sys.exit(1)
406-
407-
define_macros.append(("PG_VERSION_NUM", "%d%02d%02d" %
408-
(pgmajor, pgminor, pgpatch)))
409-
410-
# enable lo64 if libpq >= 9.3 and Python 64 bits
411-
if (pgmajor, pgminor) >= (9, 3) and is_py_64():
383+
# enable lo64 if Python 64 bits
384+
if is_py_64():
412385
define_macros.append(("HAVE_LO64", "1"))
413386

414387
# Inject the flag in the version string already packed up

0 commit comments

Comments
 (0)