Skip to content

Commit

Permalink
fix: Update RPATH and fully guard ORIGIN parameter expansion (#277)
Browse files Browse the repository at this point in the history
* fix: Use single '$' for ORIGIN parameter expansion

* Use of '$$' for the parameter expansion of ORIGIN results in
  a failure to properly resolve $ORIGIN and for LDFLAGS to be set
  improperly. Use '$ORIGIN' instead.

* Set RPATH in LDFLAGS at ./autogen and ./configure time

* 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 authored Feb 22, 2024
1 parent 19e0109 commit 0791aa9
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

1 comment on commit 0791aa9

@matthewfeickert
Copy link
Member Author

@matthewfeickert matthewfeickert commented on 0791aa9 Feb 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commit message here is wrong. Please see the PR body in PR #277 for what was actually done.

Please sign in to comment.