summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>2021-05-26 14:29:56 +0100
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>2021-05-26 17:28:14 +0100
commit52cd94442c8e971d8604192acf53a7e5ba1433ed (patch)
treef27373dd15e1deda075c61b90aabf46386ca19b5
parentd116b80c5f369c73aab09376ee503ddeb5e2d5be (diff)
downloadpsycopg2-52cd94442c8e971d8604192acf53a7e5ba1433ed.tar.gz
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.
-rw-r--r--NEWS2
-rwxr-xr-xscripts/build/build_macos.sh4
-rw-r--r--setup.py10
3 files changed, 12 insertions, 4 deletions
diff --git a/NEWS b/NEWS
index e2c7a62..1782c78 100644
--- a/NEWS
+++ b/NEWS
@@ -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
diff --git a/scripts/build/build_macos.sh b/scripts/build/build_macos.sh
index 8678609..4841ee7 100755
--- a/scripts/build/build_macos.sh
+++ b/scripts/build/build_macos.sh
@@ -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"
diff --git a/setup.py b/setup.py
index a563fd1..2cdb7c2 100644
--- a/setup.py
+++ b/setup.py
@@ -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(