This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: ctypes.util.find_library() doesn't find OS X .bundle or .so libraries
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.0, Python 2.6, Python 2.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: ronaldoussoren Nosy List: janssen, ronaldoussoren, theller
Priority: normal Keywords: easy

Created on 2008-05-07 16:47 by janssen, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
unnamed janssen, 2008-05-21 20:03
Messages (6)
msg66362 - (view) Author: Bill Janssen (janssen) * (Python committer) Date: 2008-05-07 16:47
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.
msg67162 - (view) Author: Thomas Heller (theller) * (Python committer) Date: 2008-05-21 17:30
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.
msg67165 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2008-05-21 18:15
At first glance the current behaviour is correct:

1) 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]

2) 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.
msg67166 - (view) Author: Thomas Heller (theller) * (Python committer) Date: 2008-05-21 18:38
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.
msg67172 - (view) Author: Bill Janssen (janssen) * (Python committer) Date: 2008-05-21 20:03
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:

>
> Thomas Heller <theller@ctypes.org> added the comment:
>
> 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.
>
> __________________________________
> Tracker <report@bugs.python.org>
> <http://bugs.python.org/issue2783>
> __________________________________
>
msg67173 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2008-05-21 20:13
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?
History
Date User Action Args
2022-04-11 14:56:34adminsetgithub: 47032
2008-05-21 20:38:15benjamin.petersonsetstatus: open -> closed
2008-05-21 20:13:24ronaldoussorensetresolution: not a bug
messages: + msg67173
2008-05-21 20:04:03janssensetfiles: + unnamed
messages: + msg67172
2008-05-21 18:38:57thellersetmessages: + msg67166
2008-05-21 18:15:41ronaldoussorensetmessages: + msg67165
2008-05-21 17:30:02thellersetassignee: theller -> ronaldoussoren
messages: + msg67162
nosy: + ronaldoussoren
2008-05-07 16:47:14janssencreate