From 97dc87599f95ae359c1d396f02aba131b5cc85de Mon Sep 17 00:00:00 2001 From: Matthew Feickert Date: Sun, 15 Sep 2024 13:23:34 -0500 Subject: [PATCH] In further bad hacks, the LDFLAGs need to be fully overridden --- setup.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index dff3da54..3ba39176 100644 --- a/setup.py +++ b/setup.py @@ -102,19 +102,27 @@ def build_extensions(self): if sys.platform == "darwin": if "CXXFLAGS" not in os.environ: os.environ["CXXFLAGS"] = "" - if "LDFLAGS" not in os.environ: - os.environ["LDFLAGS"] = "" - os.environ["CXXFLAGS"] = os.environ["CXXFLAGS"] + " -I/opt/homebrew/include" - os.environ["LDFLAGS"] = os.environ["LDFLAGS"] + " -L/opt/homebrew/lib" + os.environ["CXXFLAGS"] = ( + os.environ["CXXFLAGS"] + " -I/opt/homebrew/include" + ) + # For reasons that are unclear, the LDFLAGS need to be fully + # overridden. It is insufficient to just prepend the Homebrew + # library path to the existing LDFLAGS. + os.environ["LDFLAGS"] = "-L/opt/homebrew/lib" + # Pick up a Conda environment if it is active if "CONDA_PREFIX" in os.environ and os.environ["CONDA_PREFIX"]: if "CXXFLAGS" not in os.environ: os.environ["CXXFLAGS"] = "" if "LDFLAGS" not in os.environ: os.environ["LDFLAGS"] = "" - os.environ["CXXFLAGS"] = os.environ["CXXFLAGS"] + f" -I{os.environ['CONDA_PREFIX']}/include" - os.environ["LDFLAGS"] = os.environ["LDFLAGS"] + f" -L{os.environ['CONDA_PREFIX']}/lib" + os.environ["CXXFLAGS"] = ( + os.environ["CXXFLAGS"] + f" -I{os.environ['CONDA_PREFIX']}/include" + ) + os.environ["LDFLAGS"] = ( + os.environ["LDFLAGS"] + f" -L{os.environ['CONDA_PREFIX']}/lib" + ) env = os.environ.copy() env["CXX"] = env.get("CXX", "g++")