Python C Extension in package - not working?
Question: I'm working on packaging my python C extension and I'm running into trouble
here:

    
    
    .
    |-- c_ext/
    |   |-- __init__.py
    |-- c_src/
    setup.py
    

With this setup.py

    
    
    from distutils.core import setup, Extension
    
    setup( name = "Utilities",
           version = '1.0',
           description = ('Various utils'),
           packages = ["utils"],
           ext_modules = [Extension("utils.c_ext", ['c_src/c_extmodule.c'])]
           )
    

I can build without problems but after installing I can't import my module, I
just get an ImportError.

I'm sure it's something trivial, so what am I missing?

Thanks in Advance!


Answer: Do you have a function in your module with the following signature:

    
    
    PyMODINIT_FUNC initc_ext(void);
    

When you import a C extension it calls the function init where is the exact
name of the extension. (Note that the convention is for C extensions to be
named something like _foo and you get a function like init_foo)

The exact error would also help diagnose this better.

