[Distutils] c extensions: how to rebuild and test quickly
Phillip J. Eby
pje at telecommunity.com
Thu Feb 15 01:04:02 CET 2007
At 01:30 AM 2/15/2007 +0200, Paul Pogonyshev wrote:
>Distutils create dynamic library for a C extension in `build/...'
>directory. This makes it impossible to run program without
>installing it, which I find very important for developing. Ideally,
>process should look like this:
> edit Python code -> test (uninstalled);
> edit C code -> ./setup.by build -> test (uninstalled).
>This is all possible if I create a symbolic link from build
>directory to the sources. Then extension module can be imported
>normally and everything is like it was with all code limited to
>Is it possible in some standard (and preferably portable) way with
>distutils? Is it already done?
As someone else has mentioned, build_ext --inplace will do the trick.
However, I find it a bit awkward to use, as you have to manually rebuild
when testing different Python versions (and/or platforms: I sometimes use
both Cygwin and Windows Python, for example).
So, setuptools' "test" and "develop" commands (as well as its own version
of "build_ext --inplace") do the build in the build/ subdirectory, but then
*copy* the files to the source directory. Because each build directory has
its own platform-specific files, this automatically uses the right files
for the Python version you're running the "test" command with.
It's still not perfect, but it can be a nice improvement over plain
"build_ext -i" usage.
More information about the Distutils-SIG