Add include and lib dirs from libpq --cppflags, --ldflags

They seem the right thing to fix MacOS build woes.

Inspired to #935, might close #1200.
This commit is contained in:
Daniele Varrazzo 2021-05-26 14:29:56 +01:00
parent d116b80c5f
commit 52cd94442c
3 changed files with 12 additions and 4 deletions

2
NEWS
View File

@ -12,6 +12,8 @@ What's new in psycopg 2.9
- Connection exceptions with sqlstate ``08XXX`` reclassified as
`~psycopg2.OperationalError` (a subclass of the previously used
`~psycopg2.DatabaseError`) (:ticket:`#1148`).
- Include library dirs required from libpq to work around MacOS build problems
(:ticket:`#1200`).
What's new in psycopg 2.8.7

View File

@ -35,10 +35,6 @@ mkdir -p "$DISTDIR"
# Install required python packages
pip install -U pip wheel delocate
# Allow to find the libraries needed.
export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"
# Replace the package name
gsed -i "s/^setup(name=\"psycopg2\"/setup(name=\"${PACKAGE_NAME}\"/" \
"${PRJDIR}/setup.py"

View File

@ -376,6 +376,16 @@ For further information please check the 'doc/src/install.rst' file (also at
self.library_dirs.append(pg_config_helper.query("libdir"))
self.include_dirs.append(pg_config_helper.query("includedir"))
self.include_dirs.append(pg_config_helper.query("includedir-server"))
# add includedirs from cppflags, libdirs from ldflags
for token in pg_config_helper.query("ldflags").split():
if token.startswith("-L"):
self.library_dirs.append(token[2:])
for token in pg_config_helper.query("cppflags").split():
if token.startswith("-I"):
self.include_dirs.append(token[2:])
pgversion = pg_config_helper.query("version").split()[1]
verre = re.compile(