[Pythonmac-SIG] What are "METH_CLASS" and "METH_STATIC"?
Bob Ippolito
bob at redivi.com
Mon Jan 31 22:15:46 CET 2005
On Jan 31, 2005, at 15:53, Opstad, Dave wrote:
> I've had good luck building C-language extensions for my Python work,
> at
> least up until now. I've got a C file which #includes Carbon.h as well
> as
> the canonical Python.h. Attempting to use distutils to build it fails
> with
> the error message:
>
> ld:
> build/temp.darwin-7.7.0-Power_Macintosh-2.3/MacUtils/macutilsmodule.o
> illegal reference to symbol: _FSPathMakeRef defined in indirectly
> referenced
> dynamic library
> /System/Library/Frameworks/CoreServices.framework/Versions/A/
> Frameworks/Carb
> onCore.framework/Versions/A/CarbonCore
>
> when executing this line:
>
> gcc -Wl,-F. -bundle -framework Python
> build/temp.darwin-7.7.0-Power_Macintosh-2.3/MacUtils/macutilsmodule.o
> -o
> build/lib.darwin-7.7.0-Power_Macintosh-2.3/macutilsbackend.so
>
> So I tried recompiling/linking by using the same line but adding
> "-framework
> Carbon" and the .so built with no complaints. However, once I
> installed it
> and tried to import it, I got this from Python:
Yeah, but you should probably -framework CoreServices instead, as that
will link in only what it needs, rather than all of Carbon.
> ValueError: module functions cannot set METH_CLASS or METH_STATIC
>
> What does this mean? I searched the mail.python.org list and saw a
> post back
> in April, 2004 from someone else who saw this exact same line, but
> nobody
> every replied to that message.
It think that it means that you're adding a method to a module
dictionary and you shouldn't do that.. functions should be on the
module dictionary. Without some source, I wouldn't really be able to
say.
> More generally, I'd like to know the answer to this: How do I specify
> changes to the gcc lines that distutils runs when it builds? Is there
> a way
> (short of modifying distutils themselves) to specify optional and/or
> additional arguments to these commands?
from distutils.core import Extension, setup
setup(name="LaunchServices", version="0.2",
ext_modules=[
Extension('_Launch', ['_Launchmodule.c'],
extra_link_args=['-framework', 'ApplicationServices'])
],
py_modules=['LaunchServices.Launch',
'LaunchServices.LaunchServices'],
package_dir={'LaunchServices':'../../../Lib/plat-mac/Carbon'}
)
-bob
More information about the Pythonmac-SIG
mailing list