Use for library name.
@@ -60,14 +60,20 @@ class cy_build_ext(build_ext):
ext.library_dirs.append(os.path.join(self.build_lib, "pysam"))
if sys.platform == 'darwin':
+ # The idea is to give shared libraries an install name of the form
+ # `@rpath/<library-name.so>`, and to set the rpath equal to
+ # @loader_path. This will allow Python packages to find the library
+ # in the expected place, while still giving enough flexibility to
+ # external applications to link against the library.
relative_module_path = ext.name.replace(".", os.sep) + get_config_vars()["SO"]
library_path = os.path.join(
- "@loader_path", os.path.basename(relative_module_path)
+ "@rpath", os.path.basename(relative_module_path)
)
if not ext.extra_link_args:
ext.extra_link_args = []
ext.extra_link_args += ['-dynamiclib',
+ '-rpath', '@loader_path',
'-Wl,-headerpad_max_install_names',
'-Wl,-install_name,%s' % library_path,
'-Wl,-x']
