Building a python module and linking it against a MacOSX framework

前端 未结 5 1697
没有蜡笔的小新
没有蜡笔的小新 2021-02-19 05:46

I\'m trying to build a Python extension on MacOSX 10.6 and to link it against several frameworks (i386 only). I made a setup.py file, using distutils and the Extension object.

5条回答
  •  逝去的感伤
    2021-02-19 06:31

    This has nothing to do with the undefined dynamic_lookup but all with distutils. It appends the extra_link_flags to the link flags it chooses for python building. Instead it should prepend it because the -framework listings must come before the objects that use them on the cmdline (AFAIK this is due how gcc gathers symbols for linking). A quick fix that I personally use is building with

        LDFLAGS="-framework Carbon" python setup.py build_ext --inplace
    

    or whatever frameworks you need. LDFLAGS is prepended to distutils own flags. Note that your package will not be pip installable. A proper fix can only come from distutils - imho they should support frameworks like they support libraries.

    Alternatively, you can also add

    import os
    os.environ['LDFLAGS'] = '-framework Carbon'
    

    in your setup.py. Your package should then be pip installable.

提交回复
热议问题