How to use to compile a C extension rather than to install it

Gerhard Häring gerhard.haering at
Mon Feb 17 13:08:35 CET 2003

Xiao-Qin Xia <xx758 at> wrote:
> Hi, there,
> I am trying to write a C extension for my python scripts, to use distutils 
> offered by Python to write a is quite convient, however it seems 
> the alway installs the C extension to site-package, while I want 
> keep the c extension in the same original directory with my python scripts. 
> Anybody can tell me how to do this?

Are you doing 'install' rather than 'build'? Try this instead:

$ python build

this will build the C extension in a directory buid/lib-$platform$pythonversion

For testing, I either have a shell open in that directory or add it to

If you want the extension to be built in the same directory as, use:

$ python build --build-lib=.

But I don't like that, as it clutters up my source directory.

Gerhard Häring
OPUS GmbH München
Tel.: +49 89 - 889 49 7 - 32

More information about the Python-list mailing list