Building a python module and linking it against a MacOSX framework

前端 未结 5 1700
没有蜡笔的小新
没有蜡笔的小新 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:25

    Although long after the dust has settled, having the same question myself I dug around a little bit and found this:

    /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/sysconfig.py

       if 'ARCHFLAGS' in os.environ:
                    archflags = os.environ['ARCHFLAGS']
                else:
                    archflags = '-arch i386 -arch ppc -arch x86_64'
                _config_vars['ARCHFLAGS'] = archflags
                if archflags.strip() != '':
                    _config_vars['CFLAGS'] = _config_vars['CFLAGS'] + ' ' + archflags
                    _config_vars['LDFLAGS'] = _config_vars['LDFLAGS'] + ' ' + archflags
    

    I'm coming at the problem from a different angle - on 10.6 distutils is trying to build C extensions and as complains because there's no PPC portion in the 10.6 SDK.

    However,

     export ARCHFLAGS="-arch i386 -arch x86_64"
     python setup.py build
    

    Worked like a charm.

提交回复
热议问题