more complicated extension modules may need to supply additional build informationsuch as include directorieslibrariesand preprocessor macros they can also be included in setup pyas followssetup py from distutils core import setupextension setup(name="example"version=" "py_modules ['example py']ext_modules extension("_example"["pyexample ","example "]include_dirs ["/usr/include/ ","/opt/include"]define_macros [('debug', ')('mondo_flag', )]undef_macros ['have_foo','have_not']library_dirs["/usr/lib/ ""/opt/lib"]libraries " ""xt""blah]if you want to install an extension module for general useyou simply type python setup py install further details about this are found in "modulespackagesand distribution in some situationsyou may want to build an extension module manually this almost always requires advanced knowledge of various compiler and linker options the following is an example on linuxlinux gcc - -fpic - /usr/local/include/python example pyexample linux gcc -shared example pyexample - _examplemodule so type conversion from python to the following functions are used by extension modules to convert arguments passed from python to their prototypes are defined by including the python header file int pyarg_parsetuple(pyobject *argschar *format)parses tuple of positional arguments in args into series of variables format is format string containing zero or more of the specifier strings from tables which describe the expected contents of args all the remaining arguments contain the addresses of variables into which the results will be placed the order and types of these arguments must match the specifiers used in format zero is returned if the arguments could not be parsed int pyarg_parsetupleandkeywords(pyobject *argspyobject *kwargschar *formatchar **kwlist)parses both tuple of positional arguments and dictionary of keyword arguments contained in kwargs format has the same meaning as for pyarg_parsetuple(the only difference is that kwlist is null-terminated list of strings containing the names of all the arguments returns on success on error table lists the format codes that are placed in the format argument to convert numbers the argument type column lists the data type that should be passed to the pyarg_parse*(functions for numbersit is always pointer to location where the result should be stored lib fl ff