From 1c57209144ee0385b0199f3da98fe31def3daca0 Mon Sep 17 00:00:00 2001 From: Michael Haas Date: Tue, 18 Jun 2019 16:51:33 +0200 Subject: [PATCH] Take libdir from pg_config --ldflags On OS X with OpenSSL installed via brew, `-lssl` is not found during the linker stage. This can be remedied by correctly taking into account the build-time settings for PostgreSQL. Since the format is incompatible, this commit introduces some string parsing to retrieve the directories referenced in the linker call. --- setup.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/setup.py b/setup.py index c1f319a8..c4c5b958 100644 --- a/setup.py +++ b/setup.py @@ -409,6 +409,11 @@ For further information please check the 'doc/src/install.rst' file (also at try: self.library_dirs.append(pg_config_helper.query("libdir")) + # Parse LD_FLAGS: turn "-L/foo -L/bar -Wxyz" into ["/foo", "/bar"] + ld_flags = pg_config_helper.query("ldflags") + ld_flags = filter(lambda x: x.startswith('-L'), ld_flags.split(' ')) + ld_flags = map(lambda x: x[2:], ld_flags) + self.library_dirs.extend(ld_flags) self.include_dirs.append(pg_config_helper.query("includedir")) self.include_dirs.append(pg_config_helper.query("includedir-server")) pgversion = pg_config_helper.query("version").split()[1]