Skip to content

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

Closed

Description

@janssen
mannequin
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']

    Activity

    1. janssen commented on May 7, 2008

      janssenmannequin
      MannequinAuthor

      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.

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      type-bugAn unexpected behavior, bug, or error
      on May 7, 2008
    3. theller commented on May 21, 2008

      @theller

      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.

    4. ronaldoussoren commented on May 21, 2008

      @ronaldoussoren
      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.
    5. theller commented on May 21, 2008

      @theller

      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.

    6. janssen commented on May 21, 2008

      janssenmannequin
      MannequinAuthor

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


    7. ronaldoussoren commented on May 21, 2008

      @ronaldoussoren
      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?

    8. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Labels

    easystdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions