def main(): for fn in os.listdir(LIBVTK): path = join(LIBVTK, fn) if macho.is_macho(path): macho.install_name_change(path, ch_link_libvtk) for fn in os.listdir(BIN): path = join(BIN, fn) if macho.is_macho(path): macho.install_name_change(path, ch_link_bin)
def mk_relative_osx(path, host_prefix, build_prefix, files): assert sys.platform == 'darwin' names = macho.otool(path) s = macho.install_name_change(path, partial(osx_ch_link, host_prefix=host_prefix, build_prefix=build_prefix, files=files), dylibs=names) if names: # Add an rpath to every executable to increase the chances of it # being found. rpath = os.path.join('@loader_path', os.path.relpath(os.path.join(host_prefix, 'lib'), os.path.dirname(path)), '').replace('/./', '/') macho.add_rpath(path, rpath, verbose=True) # 10.7 install_name_tool -delete_rpath causes broken dylibs, I will revisit this ASAP. # .. and remove config.build_prefix/lib which was added in-place of # DYLD_FALLBACK_LIBRARY_PATH since El Capitan's SIP. # macho.delete_rpath(path, config.build_prefix + '/lib', verbose = True) if s: # Skip for stub files, which have to use binary_has_prefix_files to be # made relocatable. assert_relative_osx(path, host_prefix)
def mk_relative_osx(path, prefix, build_prefix=None): ''' if build_prefix is None, the_n this is a standard conda build. The path and all dependencies are in the build_prefix. if package is built in develop mode, build_prefix is specified. Object specified by 'path' needs to relink runtime dependences to libs found in build_prefix/lib/. Also, in develop mode, 'path' is not in 'build_prefix' ''' if build_prefix is None: assert path.startswith(prefix + '/') else: prefix = build_prefix assert sys.platform == 'darwin' and is_obj(path) s = macho.install_name_change(path, partial(osx_ch_link, prefix=prefix)) names = macho.otool(path) if names: # Add an rpath to every executable to increase the chances of it # being found. rpath = os.path.join('@loader_path', os.path.relpath(os.path.join(prefix, 'lib'), os.path.dirname(path)), '').replace('/./', '/') macho.add_rpath(path, rpath, verbose=True) # 10.7 install_name_tool -delete_rpath causes broken dylibs, I will revisit this ASAP. # .. and remove config.build_prefix/lib which was added in-place of # DYLD_FALLBACK_LIBRARY_PATH since El Capitan's SIP. # macho.delete_rpath(path, config.build_prefix + '/lib', verbose = True) if s: # Skip for stub files, which have to use binary_has_prefix_files to be # made relocatable. assert_relative_osx(path, prefix)
def mk_relative_osx(path, prefix, build_prefix=None): ''' if build_prefix is None, the_n this is a standard conda build. The path and all dependencies are in the build_prefix. if package is built in develop mode, build_prefix is specified. Object specified by 'path' needs to relink runtime dependences to libs found in build_prefix/lib/. Also, in develop mode, 'path' is not in 'build_prefix' ''' if build_prefix is None: assert path.startswith(prefix + '/') else: prefix = build_prefix assert sys.platform == 'darwin' and is_obj(path) s = macho.install_name_change(path, partial(osx_ch_link, prefix=prefix)) names = macho.otool(path) if names: # Add an rpath to every executable to increase the chances of it # being found. rpath = join('@loader_path', relpath(join(prefix, 'lib'), dirname(path)), '').replace('/./', '/') macho.add_rpath(path, rpath, verbose=True) # 10.7 install_name_tool -delete_rpath causes broken dylibs, I will revisit this ASAP. # .. and remove config.build_prefix/lib which was added in-place of # DYLD_FALLBACK_LIBRARY_PATH since El Capitan's SIP. # macho.delete_rpath(path, config.build_prefix + '/lib', verbose = True) if s: # Skip for stub files, which have to use binary_has_prefix_files to be # made relocatable. assert_relative_osx(path, prefix)
def mk_relative_osx(path, host_prefix, build_prefix, files, rpaths=('lib',)): assert sys.platform == 'darwin' names = macho.otool(path) s = macho.install_name_change(path, partial(osx_ch_link, host_prefix=host_prefix, build_prefix=build_prefix, files=files), dylibs=names) if names: # Add an rpath to every executable to increase the chances of it # being found. for rpath in rpaths: # Escape hatch for when you really don't want any rpaths added. if rpath == '': continue rpath_new = os.path.join('@loader_path', os.path.relpath(os.path.join(host_prefix, rpath), os.path.dirname(path)), '').replace('/./', '/') macho.add_rpath(path, rpath_new, verbose=True) if s: # Skip for stub files, which have to use binary_has_prefix_files to be # made relocatable. assert_relative_osx(path, host_prefix)
def main(path): dylibs = macho.otool(path) macho.install_name_change(path, None, name_callback, dylibs, verbose=True)