Skip to content

Commit 6183b7f

Browse files
committed
use rpath so no LD_LIBRARY_PATH is needed
1 parent 3502307 commit 6183b7f

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

local/scipy_openblas64/__init__.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,23 @@ def get_lib_dir():
4242
return os.path.join(_HERE, "lib")
4343

4444

45-
def get_library():
46-
"""Return the lib name needed for linking
45+
def get_library(fullname=False):
46+
"""Return the lib name needed for linking. If `fullname` then return the
47+
filename of the library, otherwise return the link name.
4748
"""
4849
if sys.platform == "win32":
4950
libs = [x for x in os.listdir(get_lib_dir()) if x.endswith(".lib")]
50-
return os.path.splitext(libs[0])[0]
51+
if fullname:
52+
return libs[0]
53+
else:
54+
return os.path.splitext(libs[0])[0]
5155
else:
5256
libs = [x for x in os.listdir(get_lib_dir()) if x.startswith("libscipy_openblas")]
53-
# remove the leading lib from libscipy_openblas*
54-
return os.path.splitext(libs[0])[0][3:]
57+
if fullname:
58+
return libs[0]
59+
else:
60+
# remove the leading lib from libscipy_openblas*
61+
return os.path.splitext(libs[0])[0][3:]
5562

5663
def get_pkg_config(use_preloading=False):
5764
"""Return a multi-line string that, when saved to a file, can be used with
@@ -69,7 +76,7 @@ def get_pkg_config(use_preloading=False):
6976
if use_preloading:
7077
libs_flags = ""
7178
else:
72-
libs_flags = f"-L${{libdir}} -l{get_library()}"
79+
libs_flags = f"${{libdir}}/{get_library(fullname=True)} -Wl,-rpath,${{libdir}}"
7380
cflags = "-DBLAS_SYMBOL_PREFIX=scipy_ -DBLAS_SYMBOL_SUFFIX=64_ -DHAVE_BLAS_ILP64 -DOPENBLAS_ILP64_NAMING_SCHEME"
7481
return dedent(f"""\
7582
libdir={get_lib_dir()}

tools/build_wheel.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ if [ $(uname) == "Darwin" ]; then
3939
echo otool -D local/scipy_openblas64/lib/$soname
4040
otool -D local/scipy_openblas64/lib/$soname
4141
# issue 153: there is a ".0" in the install_name. Remove it
42-
install_name_tool -id $soname local/scipy_openblas64/lib/$soname
42+
# also add a @rpath
43+
install_name_tool -id @rpath/$soname local/scipy_openblas64/lib/$soname
4344
fi
4445

4546
rm -rf local/scipy_openblas64/lib/pkgconfig

0 commit comments

Comments
 (0)