Creating a "package" using C extensions?

Gordon McMillan gmcm at hypernet.com
Sun Dec 9 11:32:14 EST 2001


Courageous wrote:

> 
> So. I've written Python C extensions before. And I've
> written Python packages before, with subdirectories and
> __init__.py files and so forth before. What I'm unclear
> on is the proper way to combine these.
> 
> I can see that if I just used a normal __init__.py and
> then pointed it to C extension dlls, this would probably
> work.
> 
> Is this the approved way of doing this?

Yes.
 
> Is there a way to govern the entire thing entirely from
> C? IOW, is there a __init__.py equivalent for C modules?

You could probably hack something up by butchering the 
module object in some way, but the import code assumes that
extension modules are just plain modules, not packages.

-- Gordon
http://www.mcmillan-inc.com/



More information about the Python-list mailing list