[Distutils] Specifying a dependency for rebuilding an extension?

Rene Liebscher R.Liebscher@gmx.de
Mon Dec 11 03:58:00 2000


Mike Fletcher wrote:
> 
> I've just noticed that with PyOpenGL, changing a source file that's included
> by the "declared" source file for an extension doesn't cause the
> recompilation of the extension.
> 
> i.e.
>         _openglmodule.c
>         _opengl_nummodule.c # includes _openglmodule.c
> 
> The extension only declares _opengl_nummodule.c as a source file.  Is there
> some way to declare that the "rule" for the extension should trigger if the
> given file has changed?

AFAIK there is no way to do so.
But I think it would be easy to add it to distutils.

First we need to extend the Extension class to hold the names
of files on which the extension depends.
(This would mean included c-files, header-files ...)

It could look like this:
Extension(
	sources=["foo.c"], 
	depends_on=["config.h","bar.c"], 
	...
)
or for Mike's example
Extension(
	sources=["_opengl_nummodule.c"], 
	depends_on=["_openglmodule.c"], 
	...
)

Then we had to extend build_ext so it checks these files too.

And if it finds it has to rebuild the extension module
(because these additional dependencies),
build_ext had to set the force flag to the compiler before
calling compile() with it.


Kind regards
Rene Liebscher