Hi, I have a regular setup script for an extension module using core.setup. Currently I have to manually run a make script to build the C object files, and then link them using the Python setup script. I would like to include the make file into the setup script, and I have been looking at how to tweak distutils, but I am quite in over my head here... My problem is that the C source files are compiled several times into different object depending on the preprocessor options, and thus I cannot simply include the source files into the "sources" list in the Extension module, e.g., as glpk = Extension('glpk', libraries = ['glpk'], include_dirs = [ GLPK_INC_DIR ], library_dirs = [ GLPK_LIB_DIR ], sources = ['C/glpk.c'] ) extmods += [glpk]; I need the setup script to build the module like this: gcc -Ddef1 -c foo.c -o foo_def1.o gcc -Ddef2 -c foo.c -o foo_def2.o gcc foo_def1.o foo_def2.o -o myext_module.o Is there currently a (relatively simple) way to include something like that into a distutils setup script, or is it easier to keep running a separate make file to build the different object files before linking? - Joachim
At 11:07 AM 9/8/2005 -0700, Joachim Dahl wrote:
I need the setup script to build the module like this: gcc -Ddef1 -c foo.c -o foo_def1.o gcc -Ddef2 -c foo.c -o foo_def2.o gcc foo_def1.o foo_def2.o -o myext_module.o
Is there currently a (relatively simple) way to include something like that into a distutils setup script, or is it easier to keep running a separate make file to build the different object files before linking?
ZODB does this by making a short 'foo_def1.c' that looks like: #define def1 #include "foo.c" and repeating. So, if you don't mind doing that to get your various foo_def*.o files, then you're good to go, without a makefile.
participants (2)
-
Joachim Dahl
-
Phillip J. Eby