You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ctypes.util.find_library() doesn't find OS X .bundle or .so libraries #47032
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee='https://github.com/ronaldoussoren'closed_at=<Date2008-05-21.20:38:15.026>created_at=<Date2008-05-07.16:47:14.446>labels= ['easy', 'invalid', 'type-bug', 'library']
title="ctypes.util.find_library() doesn't find OS X .bundle or .so libraries"updated_at=<Date2008-05-21.20:38:15.025>user='https://bugs.python.org/janssen'
On OS X, dynamically loadable libraries come in several flavors:
.bundle (or, often, .so) a standard dynamically loadable module; .dylib,
a dynamically loadable module that is also a library that can be linked
against like a .a file; .framework, a collection of modules similar to a
Python package. find_library() currently looks for .dylib and
.framework libraries, but not for .bundle or .so libraries.
Bundles aren't shared libraries, but plugin code. It should be
possible to load bundles, but I don't agree that find_library should try
to locate them, specially given this bit in the documentation:
[quote]
The purpose of the find_library function is to locate a library in a way
similar to what the compiler does (on platforms with several versions of
a shared library the most recent should be loaded), while the ctypes
library loaders act like when a program is run, and call the runtime
loader directly.
[/quote]
There is no prescribed suffix for bundles. Python uses .so and some
other packages use .bundle, but that's just a convention that a specific
software product chooses.
Thanks, Ronald. Sounds like this bug could be closed then.
Bill, if you want a library search function with different semantics,
I suggest you open a feature request, describe the sematics that
should be used and (ideally) provide a patch.
janssen commented on May 21, 2008
janssenmannequin
MannequinAuthor
More actions
I thought you might say that :-). No, I'm good with this resolution. If I
provide a patch, it will be for the LD_LIBRARY_PATH problem.
Though -- I think there's an interesting question about what the purpose of
"find_library()" actually is, as opposed to what it's current implementation
is. I disagree with Ronald's strict reading of the documentation. I think
it should emulate the behavior of the dynamic linker, not the C compiler.
That is, it should look for the libraries as "ld.so" (or its platform
equivalent) would, because the purpose of finding them is to load them with
CDLL. This behavior is different from what the compiler does.
I also think find_library() should just be moved into the ctypes library,
not dangling off by itself in the otherwise unused util sub-module.
Thanks, Ronald. Sounds like this bug could be closed then.
Bill, if you want a library search function with different semantics,
I suggest you open a feature request, describe the sematics that
should be used and (ideally) provide a patch.
Bill, even if find_library were to emulate the runtime linker it shouldn't
find objects of type MH_BUNDLE.
Those are not shared libraries, but explicitly meant to be used as code
resources for plugins. find_library should not return bz2.so when your
working directory happens to be ${sys.prefix}/lib/python*/lib-dynload and
you call find_library('bz2').
Activity
janssen commentedon May 7, 2008
On OS X, dynamically loadable libraries come in several flavors:
.bundle (or, often, .so) a standard dynamically loadable module; .dylib,
a dynamically loadable module that is also a library that can be linked
against like a .a file; .framework, a collection of modules similar to a
Python package. find_library() currently looks for .dylib and
.framework libraries, but not for .bundle or .so libraries.
theller commentedon May 21, 2008
The OS X find_library code was not written by me, the code was ripped
from Bob Ippolitos macholib.
Can some OS X expert please look into this?
Shamelessly assigning to Ronald - feel free to unassign if you have no time.
ronaldoussoren commentedon May 21, 2008
At first glance the current behaviour is correct:
possible to load bundles, but I don't agree that find_library should try
to locate them, specially given this bit in the documentation:
[quote]
The purpose of the find_library function is to locate a library in a way
similar to what the compiler does (on platforms with several versions of
a shared library the most recent should be loaded), while the ctypes
library loaders act like when a program is run, and call the runtime
loader directly.
[/quote]
other packages use .bundle, but that's just a convention that a specific
software product chooses.
theller commentedon May 21, 2008
Thanks, Ronald. Sounds like this bug could be closed then.
Bill, if you want a library search function with different semantics,
I suggest you open a feature request, describe the sematics that
should be used and (ideally) provide a patch.
janssen commentedon May 21, 2008
I thought you might say that :-). No, I'm good with this resolution. If I
provide a patch, it will be for the LD_LIBRARY_PATH problem.
Though -- I think there's an interesting question about what the purpose of
"find_library()" actually is, as opposed to what it's current implementation
is. I disagree with Ronald's strict reading of the documentation. I think
it should emulate the behavior of the dynamic linker, not the C compiler.
That is, it should look for the libraries as "ld.so" (or its platform
equivalent) would, because the purpose of finding them is to load them with
CDLL. This behavior is different from what the compiler does.
I also think find_library() should just be moved into the ctypes library,
not dangling off by itself in the otherwise unused util sub-module.
Bill
On Wed, May 21, 2008 at 11:39 AM, Thomas Heller <report@bugs.python.org>
wrote:
ronaldoussoren commentedon May 21, 2008
Bill, even if find_library were to emulate the runtime linker it shouldn't
find objects of type MH_BUNDLE.
Those are not shared libraries, but explicitly meant to be used as code
resources for plugins. find_library should not return bz2.so when your
working directory happens to be ${sys.prefix}/lib/python*/lib-dynload and
you call find_library('bz2').
BTW. What is your usecase?