# By default include library.
+ On Mac OS X set relative paths to dynamic library dependencies of `libname`.
+ Relative paths allow to avoid using environment variable DYLD_LIBRARY_PATH.
+ There are known some issues with DYLD_LIBRARY_PATH. Relative paths is
+ more flexible mechanism.
+ Current location of dependend libraries is derived from the location
+ of the executable (paths start with '@executable_path').
+ from PyInstaller.lib.macholib import util
+ from macholib.MachO import MachO
+ """For system libraries is still used absolute path. It is unchanged."""
+ # Match non system dynamic libraries.
+ if not util.in_system_path(pth):
+ # Use relative path to dependend dynamic libraries bases on
+ # location of the executable.
+ return os.path.join('@executable_path', os.path.basename(pth))
+ # Rewrite mach headers with @executable_path.
+ # Write changes into file.
+ # Write code is based on macholib example.
+ f = open(dll.filename, 'rb+')
+ for header in dll.headers: