[Numpy-discussion] distutils -- compiling extension twice, two sets of compiler settings

Lisandro Dalcin dalcinl@gmail....
Tue Jul 28 21:44:19 CDT 2009


Would two brand new .cpp files abusing of #include do the trick?

For example, for '_CCG_dmodule':

//file: CCG_dmodule.cxx
#define USE_DOUBLE 1
#include "CCG_caller.cpp"
#include "ccg_funct.cpp"
#include "ccg.cpp"
#include "CCG_d_wrap.cxx"

Then you can use:

ext_ccg_d = Extension('_CCG_dmodule',
  ['Priithon_25_C/ccg/CCG_dmodule.cxx'],
  depends=[ <add here the sources #include'd in CCG_dmodule.cxx>]


An similarly for '_CCG_smodule', you got the idea...

I know, this is a vile workaround, but trust me... you do not want to
learn to hack distutils internals :-)...


On Tue, Jul 28, 2009 at 9:15 AM, Sebastian Haase<seb.haase@gmail.com> wrote:
> Hi,
>
> maybe someone here could help me by using distutils:
> my problem is that I have some C++ files that I need to get compiled twice,
> first to make a "singleFloat"-module using  gcc -DUSE_DOUBLE=0
> and then
> to make the "doubleFloat"-module using  gcc -DUSE_DOUBLE=1.
>
> Apparently distutils recognises (like "make") that the object files
> are already there and skips the gcc for the second run.
> My setup.py so far is something like this:
> ext_ccg_s = Extension('_CCG_smodule', [
>        'Priithon_25_C/ccg/CCG_caller.cpp',
>        'Priithon_25_C/ccg/ccg_funct.cpp',
>        'Priithon_25_C/ccg/ccg.cpp',
>        'Priithon_25_C/ccg/CCG_s_wrap.cxx',
>        ],
>                      define_macros=[('USE_DOUBLE', '0'),],
> )
> ext_ccg_d = Extension('_CCG_dmodule', [
>        'Priithon_25_C/ccg/CCG_caller.cpp',
>        'Priithon_25_C/ccg/ccg_funct.cpp',
>        'Priithon_25_C/ccg/ccg.cpp',
>        'Priithon_25_C/ccg/CCG_d_wrap.cxx',
>        ],
>                      define_macros=[('USE_DOUBLE', '1'),],
> )
> setup(...
>      ext_package='Priithon_bin',
>      ext_modules=[ext_ccg_s, ext_ccg_d],
>     )
>
> Thanks for any help,
>
> --
> Sebastian Haase
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>



-- 
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594


More information about the NumPy-Discussion mailing list