mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-01-31 01:14:09 +03:00
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.
This commit is contained in:
parent
a8765121d9
commit
f4282c6d87
|
@ -27,6 +27,7 @@
|
|||
#ifndef PSYCOPG_H
|
||||
#define PSYCOPG_H 1
|
||||
|
||||
#include <pg_config.h>
|
||||
#if PG_VERSION_NUM < 90100
|
||||
#error "Psycopg requires PostgreSQL client library (libpq) >= 9.1"
|
||||
#endif
|
||||
|
|
31
setup.py
31
setup.py
|
@ -29,7 +29,6 @@ for coroutine libraries.
|
|||
|
||||
import os
|
||||
import sys
|
||||
import re
|
||||
import subprocess
|
||||
from setuptools import setup, Extension
|
||||
from distutils.command.build_ext import build_ext
|
||||
|
@ -382,34 +381,8 @@ For further information please check the 'doc/src/install.rst' file (also at
|
|||
if token.startswith("-I"):
|
||||
self.include_dirs.append(token[2:])
|
||||
|
||||
pgversion = pg_config_helper.query("version").split()[1]
|
||||
|
||||
verre = re.compile(
|
||||
r"(\d+)(?:\.(\d+))?(?:(?:\.(\d+))|(devel|(?:alpha|beta|rc)\d+))?")
|
||||
m = verre.match(pgversion)
|
||||
if m:
|
||||
pgmajor, pgminor, pgpatch = m.group(1, 2, 3)
|
||||
# Postgres >= 10 doesn't have pgminor anymore.
|
||||
pgmajor = int(pgmajor)
|
||||
if pgmajor >= 10:
|
||||
pgminor, pgpatch = None, pgminor
|
||||
if pgminor is None or not pgminor.isdigit():
|
||||
pgminor = 0
|
||||
if pgpatch is None or not pgpatch.isdigit():
|
||||
pgpatch = 0
|
||||
pgminor = int(pgminor)
|
||||
pgpatch = int(pgpatch)
|
||||
else:
|
||||
sys.stderr.write(
|
||||
f"Error: could not determine PostgreSQL version from "
|
||||
f"'{pgversion}'")
|
||||
sys.exit(1)
|
||||
|
||||
define_macros.append(("PG_VERSION_NUM", "%d%02d%02d" %
|
||||
(pgmajor, pgminor, pgpatch)))
|
||||
|
||||
# enable lo64 if libpq >= 9.3 and Python 64 bits
|
||||
if (pgmajor, pgminor) >= (9, 3) and is_py_64():
|
||||
# enable lo64 if Python 64 bits
|
||||
if is_py_64():
|
||||
define_macros.append(("HAVE_LO64", "1"))
|
||||
|
||||
# Inject the flag in the version string already packed up
|
||||
|
|
Loading…
Reference in New Issue
Block a user