From: Daniele Varrazzo Date: Tue, 29 Jun 2021 03:53:30 +0000 (+0100) Subject: Add libpq dir to link options X-Git-Tag: 3.0.dev0~4^2~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7033a6936eee61fdf6f61f7f58f4c6b619506339;p=thirdparty%2Fpsycopg.git Add libpq dir to link options --- diff --git a/psycopg_c/setup.py b/psycopg_c/setup.py index 446efed3e..ffe8163d1 100644 --- a/psycopg_c/setup.py +++ b/psycopg_c/setup.py @@ -28,6 +28,16 @@ with open("psycopg_c/version.py") as f: version = m.group(1) +def get_config(what: str) -> str: + try: + out = sp.run(["pg_config", f"--{what}"], stdout=sp.PIPE, check=True) + except Exception as e: + log.error("cannot build C module: %s", e) + raise + else: + return out.stdout.strip().decode("utf8") + + class psycopg_build_ext(build_ext): def finalize_options(self) -> None: self._setup_ext_build() @@ -41,18 +51,12 @@ class psycopg_build_ext(build_ext): if os.path.exists("psycopg_c/_psycopg.pyx"): from Cython.Build import cythonize - # Add the include dir for the libpq. - try: - out = sp.run( - ["pg_config", "--includedir"], stdout=sp.PIPE, check=True - ) - except Exception as e: - log.error("cannot build C module: %s", e) - raise - - includedir = out.stdout.strip().decode("utf8") + # Add include and lib dir for the libpq. + includedir = get_config("includedir") + libdir = get_config("libdir") for ext in self.distribution.ext_modules: ext.include_dirs.append(includedir) + ext.library_dirs.append(libdir) if cythonize is not None: for ext in self.distribution.ext_modules: