With the latest (develop) version of PyInstaller, I suddenly started having
problems loading a shared library via ctypes, meaning:
my_dll = ctypes.CDLL('thelib.so')
would fail (the exception returned was dlopen failed). After searching
around in the bootloader, I found that the LD_LIBRARY_PATH, in the previous
versions of pyinstaller, was set to the distribution path under all
platforms, now it's not for OSX. I've attached the code that I'm talking
about at the end of this message...
For the time being, I can fix the failing ctypes.CDLL() call by simply
deactivating the "ifdef __APPLE__" part.
I don't quite understand the reason for the change that's specific to OSX,
but I thought that I'd let you know that is breaks importing "foreign"
libraries in frozen code.
I tried to grok the comment there, but it doesn't make sense to me...seems
that if there are duplicate libraries between the dist directory and the
system, the libs in the dist directory should always take precedence.
bootloader/common/pyi_utils.c:
int pyi_utils_set_environment(const ARCHIVE_STATUS *status)
{
int rc = 0;
#ifdef __APPLE__
/* On Mac OS X we do not use environment variables DYLD_LIBRARY_PATH
* or others to tell OS where to look for dynamic libraries.
* There were some issues with this approach. In some cases some
* system libraries were trying to load incompatible libraries from
* the dist directory. For instance this was experienced with macprots
* and PyQt4 applications.
*
* To tell the OS where to look for dynamic libraries we modify
* .so/.dylib files to use relative paths to other dependend
* libraries starting with @executable_path.
*
* For more information see:
* http://blogs.oracle.com/dipol/entry/dynamic_libraries_rpath_and_mac
* http://developer.apple.com/library/mac/#documentation/DeveloperTools/ \
*
Conceptual/DynamicLibraries/100-Articles/DynamicLibraryUsageGuidelines.html
*/
/* For environment variable details see 'man dyld'. */
pyi_unsetenv("DYLD_FRAMEWORK_PATH");
pyi_unsetenv("DYLD_FALLBACK_FRAMEWORK_PATH");
pyi_unsetenv("DYLD_VERSIONED_FRAMEWORK_PATH");
pyi_unsetenv("DYLD_LIBRARY_PATH");
pyi_unsetenv("DYLD_FALLBACK_LIBRARY_PATH");
pyi_unsetenv("DYLD_VERSIONED_LIBRARY_PATH");
pyi_unsetenv("DYLD_ROOT_PATH");
#else
/* Set library path to temppath. This is only for onefile mode.*/
if (status->temppath[0] != PYI_NULLCHAR) {
rc = set_dynamic_library_path(status->temppath);
}
/* Set library path to homepath. This is for default onedir mode.*/
else {
rc = set_dynamic_library_path(status->homepath);
}
#endif
return rc;
}
--
Daniel Hyams
[email protected]
--
You received this message because you are subscribed to the Google Groups
"PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pyinstaller?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.