This is an archival dump of old wiki content --- see for current material

ExtGen - Python Extension module Generator

Author:: Pearu Peterson < >


ExtGen is a pure Python package that provides a high-level tool for constructing and building Python extension modules.

Warning: ExtGen is a very new project and is not ready for production use. But if you like the idea of ExtGen then help in any form (feedback, bug reports, feature requests, patches, etc) is welcome.

Hello example

>>> from numpy.f2py.lib.extgen import *
>>> f = PyCFunction('say', PyCArgument('word', output_intent='return'))
>>> m = PyCModule('foo', f)
>>> foo =
>>> print foo.__doc__
This module "foo" is generated with ExtGen from NumPy version ...

  say(word) -> (word)
>>> foo.say('Hello')
>>> print m.generate() # this will print the extension module source that ExtGen generated, useful for debugging


For more examples and documentation, see the documentation strings of the component classes such as PyCModule, PyCFunction, etc.

Getting and installing ExtGen

Get and install NumPy from SVN. ExtGen is currently a subpackage of numpy.f2py.lib package.

SciPy: ExtGen (last edited 2015-10-24 17:48:26 by anonymous)