Skip to content

Commit

Permalink
Set RPATH in LDFLAGS at ./autogen and ./configure time
Browse files Browse the repository at this point in the history
* Set RPATH to support both local and cibuildwheel wheel builds.
* Set LDFLAGS for to be written into the Makefiles generated by both
  the calls to ./autogen.sh and ./configure.
  • Loading branch information
matthewfeickert committed Feb 21, 2024
1 parent 641f2ac commit 50d6336
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,16 @@ def build_extensions(self):
cwd=FASTJET,
)

# RPATH is set for shared libraries in the following locations:
# * fastjet/
# * fastjet/_fastjet_core/lib/
# * fastjet/_fastjet_core/lib/python*/site-packages/
_rpath = "'$$ORIGIN/_fastjet_core/lib:$$ORIGIN:$$ORIGIN/../..'"
env = os.environ.copy()
env["PYTHON"] = sys.executable
env["PYTHON_INCLUDE"] = f'-I{sysconfig.get_path("include")}'
env["CXXFLAGS"] = "-O3 -Bstatic -lgmp -Bdynamic -std=c++17"
env["LDFLAGS"] = env.get("LDFLAGS", "") + f" -Wl,-rpath,{_rpath}"
env["ORIGIN"] = "$ORIGIN" # if evaluated, it will still be '$ORIGIN'

args = [
Expand All @@ -82,7 +88,7 @@ def build_extensions(self):
f"--with-cgaldir={cgal_dir}",
"--enable-swig",
"--enable-pyext",
"LDFLAGS=-Wl,-rpath,$ORIGIN/_fastjet_core/lib:$ORIGIN",
f'LDFLAGS={env["LDFLAGS"]}',
]

try:
Expand All @@ -98,6 +104,7 @@ def build_extensions(self):

env = os.environ.copy()
env["CXX"] = env.get("CXX", "g++")
env["LDFLAGS"] = env.get("LDFLAGS", "") + f" -Wl,-rpath,{_rpath}"
env["ORIGIN"] = "$ORIGIN" # if evaluated, it will still be '$ORIGIN'
subprocess.run(["make", "-j"], cwd=FASTJET, env=env, check=True)
subprocess.run(["make", "install"], cwd=FASTJET, env=env, check=True)
Expand All @@ -108,6 +115,7 @@ def build_extensions(self):
f"--fastjet-config={FASTJET}/fastjet-config",
f'CXX={env["CXX"]}',
"CXXFLAGS=-O3 -Bstatic -Bdynamic -std=c++17",
f'LDFLAGS={env["LDFLAGS"]}',
],
cwd=FASTJET_CONTRIB,
env=env,
Expand Down

0 comments on commit 50d6336

Please sign in to comment.