Hi Matyas,
for me, the add_extension works also for extensions with several source files - just list them in the sources argument, e.g.: sources=['src1.c', 'src2.c'] - check the setup.py files in sfepy/fem/extmods or sfepy/terms/extmods. But it's true I do not compile fortran... You mean f2py_options do not work, right?
I think you know about [1], where supported arguments of each command are shown. So it what you are trying to do should work, try asking the numpy guys?
r.
[1] http://docs.scipy.org/doc/numpy/reference/distutils.html
On 08/29/2012 02:38 PM, Matyáš Novák wrote:
Hi, I wrote an extension for sfepy, that requires compiling and linking additional fortran sources (invoked by cython). I found out, that these libraries can be easily added using distutils config.add_library() function, but there is the problem. The --fcompiler command doesn't propagate to the stage where the libraries are compiled, so the default (and in my case wrong) compiler is used. (If I try compile the files using add_extension method, they are compiled by desired compiler, but I need combine more sources in one extension so I think that I can't use add_extension).
Is there any way how to force python to use the right compiler, or at least hardcode the compiler in the setup.py?
Thanks a lot for suggestions, Matyas
My setup.py: def configuration(parent_package='', top_path=None): import os.path as op from numpy.distutils.misc_util import Configuration from sfepy import Config
site_config = Config() auto_dir = op.dirname(__file__) auto_name = op.split(auto_dir)[-1] config = Configuration(auto_name, parent_package, top_path) flags= site_config.compile_flags() flags.append('-I'+os.path.dirname(__file__)) config.add_library('xc_default', ['default/dft.c'], extra_compile_args=flags, f2py_options = '--fcompiler=gnu95', extra_link_args=site_config.link_flags() ) config.add_library('xc_vackar', ['vackar/vscxc.f90'], extra_compile_args=flags, f2py_options = {'fcompiler' : 'gnu95'}, extra_link_args=site_config.link_flags()