Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ctypes.util.find_library() doesn't find OS X .bundle or .so libraries #47032

Closed
janssen mannequin opened this issue May 7, 2008 · 6 comments
Closed

ctypes.util.find_library() doesn't find OS X .bundle or .so libraries #47032

janssen mannequin opened this issue May 7, 2008 · 6 comments
Assignees
Labels
easy stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@janssen
Copy link
Mannequin

janssen mannequin commented May 7, 2008

BPO 2783
Nosy @theller, @ronaldoussoren
Files
  • unnamed
  • 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 = <Date 2008-05-21.20:38:15.026>
    created_at = <Date 2008-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 = <Date 2008-05-21.20:38:15.025>
    user = 'https://bugs.python.org/janssen'

    bugs.python.org fields:

    activity = <Date 2008-05-21.20:38:15.025>
    actor = 'benjamin.peterson'
    assignee = 'ronaldoussoren'
    closed = True
    closed_date = <Date 2008-05-21.20:38:15.026>
    closer = 'benjamin.peterson'
    components = ['Library (Lib)']
    creation = <Date 2008-05-07.16:47:14.446>
    creator = 'janssen'
    dependencies = []
    files = ['10394']
    hgrepos = []
    issue_num = 2783
    keywords = ['easy']
    message_count = 6.0
    messages = ['66362', '67162', '67165', '67166', '67172', '67173']
    nosy_count = 3.0
    nosy_names = ['theller', 'ronaldoussoren', 'janssen']
    pr_nums = []
    priority = 'normal'
    resolution = 'not a bug'
    stage = None
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue2783'
    versions = ['Python 2.6', 'Python 2.5', 'Python 3.0']

    @janssen
    Copy link
    Mannequin Author

    janssen mannequin commented 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.

    @janssen janssen mannequin assigned theller May 7, 2008
    @janssen janssen mannequin added stdlib Python modules in the Lib dir easy type-bug An unexpected behavior, bug, or error labels May 7, 2008
    @theller
    Copy link

    theller commented 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.

    @theller theller assigned ronaldoussoren and unassigned theller May 21, 2008
    @ronaldoussoren
    Copy link
    Contributor

    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]

    1. 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.

    @theller
    Copy link

    theller commented 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
    Copy link
    Mannequin Author

    janssen mannequin commented 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:

    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\>


    @ronaldoussoren
    Copy link
    Contributor

    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?

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    easy stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants