Specifying a dependency for rebuilding an extension?
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? Is there a better way? Thoughts appreciated, Mike __________________________________ Mike C. Fletcher Designer, VR Plumber http://members.home.com/mcfletch
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
Rene Liebscher wrote:
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. Correct.
But I think it would be easy to add it to distutils. This of course means that it is also easy to add it to the setup-script, since you can override the distutils commands with your own. class my_build_ext(distutils.command.build_ext): ...
setup(... cmdclass = {'build_ext': my_build_ext}, ...)
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"], ... )
IMO better would be to let sources be instances of a SourceFile class, which would depend on other (Source)files. Thomas
participants (3)
-
Mike Fletcher
-
Rene Liebscher
-
Thomas Heller