C extensions without using shared libraries

Ignacio Vazquez-Abrams ignacio at openservices.net
Wed Sep 5 03:02:07 EDT 2001


On 5 Sep 2001, Rolo Tomasi wrote:

> >Or, you could write a C program and embed the Python interpreter in it. That
> >way the C program can create modules on its own and then the Python scripts
> >can import the modules and then use them.
> >
>
> Is there is a way to import a C-based extension that's not a shared library?
> The only thing that I see getting imported are builtin modules, python-code modules
> and external language (C, C++, etc.) shared library modules.  I don't have the
> option of using shared libraries, and my extension needs to be written in C
> because of the API it's using.

Take a look at:

  http://python.sourceforge.net/devel-docs/ext/extending-with-embedding.html

Basically, you use Py_InitModule() to create a module with a given name, and
then your Python scripts can import that name and use the module.

-- 
Ignacio Vazquez-Abrams  <ignacio at openservices.net>






More information about the Python-list mailing list