Skip to content

Commit 59f63f8

Browse files
Lutz Grossclaude
andcommitted
Bake <prefix>/lib/esys as RPATH into every shared lib and extension
Previously the .so/.dylib files escript installed under lib/esys/ had no RPATH/RUNPATH at all, so users had to set LD_LIBRARY_PATH (or go through run-escript) for bare `import esys.escript` to work -- fine for MPI-launched runs but a poor experience for the single-process non-MPI builds that conda-forge ships, and the conda-build inspector complained about every cross-library NEEDED entry it couldn't resolve. Append `-Wl,-rpath,<prefix>/lib/esys` to SHLINKFLAGS and LINKFLAGS unconditionally on Unix. conda-build picks up the absolute build prefix in the binary's RUNPATH and rewrites it to $ORIGIN-relative at install time, so end users on linux/osx can `import esys.escript` straight from a base conda env. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 7198aa8 commit 59f63f8

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

SConstruct

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,17 @@ if env['IS_OSX']:
614614
elif not env['IS_WINDOWS']:
615615
env.AppendUnique(SHLIBSONAMEFLAGS = ["-Wl,-soname=$_SHLIBSONAME" ] )
616616

617+
if not env['IS_WINDOWS']:
618+
# Bake the install location of escript's shared libs as an absolute
619+
# RPATH into every binary we link, so the .so/.dylib files find their
620+
# siblings and the Python extensions find them too, without users
621+
# having to set LD_LIBRARY_PATH or DYLD_LIBRARY_PATH. conda-build's
622+
# post-processing rewrites the absolute prefix to a relative
623+
# $ORIGIN / @loader_path expression at install time.
624+
_libesys = os.path.join(env['prefix'], 'lib', 'esys')
625+
env.AppendUnique(SHLINKFLAGS = ["-Wl,-rpath," + _libesys])
626+
env.AppendUnique(LINKFLAGS = ["-Wl,-rpath," + _libesys])
627+
617628
if env['build_trilinos'] != 'never':
618629
if not os.path.isdir(env['trilinos_build']): # create a build folder if the user deleted it
619630
os.mkdir(env['trilinos_build'])

0 commit comments

Comments
 (0)