[Numpy-discussion] compile fortran from python
Hello list, on compiling some F95 code into a library I got following message: Warning: Nonconforming tab character at (1) i figured out it is because setup uses default compiler flags. this is my set-up command python setup.py config_fc --fcompiler=gnu95 install --home=./tbuild I tried to pass -ffree-form flag to the setup using build_info parameter config.add_library('hm1d', sources = ['src/hm1d.f95'], build_info = {'extra_compiler_args':'-ffree-form'}) but is still get the warnings. the setup does not seem to receive these flags or it is ignoring them. Any hints? Cheers Ioan Ferencik PhD student Aalto University School of Science and Technology Faculty Of Civil and Env. Engineering Lahti Center Tel: +358505122707 ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] compile fortran from python
Hi, You can create a setup.py file containing def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration config = Configuration(None,parent_package,top_path) config.add_library('flib', sources = [test.f95]) config.add_extension('ctest', sources = ['ctest.c'], libraries=['flib']) return config if __name__ == "__main__": from numpy.distutils.core import setup setup(configuration=configuration) #eof Running python setup.py config_fc --fcompiler=gnu95 build will build a Fortran library flib.a and link it to an extension module ctest.so. Use build_ext --inplace if ctest.so should end up in current working directory. Is that what you wanted to achieve? HTH, Pearu On 10/09/2010 02:18 PM, Ioan Ferencik wrote: > I would like to compile some Fortran code using python, build a > shared library, and link to it using python. But I get a message > saying the compiler does not recognise the extension of my file. > > this is my command: > > gcc -fPIC -c -shared -fno-underscoring test.f95 -o ./lib/libctest.so.1.0 > > what is the easiest method to achieve this? >I suspect I could create a custom extension and customise the > unixccompiler object or could I just use the compiler object defined > by f2py(fcompiler). > > Cheers > > > Ioan Ferencik > PhD student > Aalto University > School of Science and Technology > Faculty Of Civil and Env. Engineering > Lahti Center > Tel: +358505122707 > > > ___ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org > http://mail.scipy.org/mailman/listinfo/numpy-discussion ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] compile fortran from python
On Sat, Oct 9, 2010 at 8:18 PM, Ioan Ferencik wrote: > I would like to compile some Fortran code using python, build a > shared library, and link to it using python. But I get a message > saying the compiler does not recognise the extension of my file. > > this is my command: > > gcc -fPIC -c -shared -fno-underscoring test.f95 -o ./lib/libctest.so.1.0 I am not sure I understand what you want: do you build some code which does not depend on python, with python solely used as a language to drive the build ? Your command above has a problem because you use gcc to build fortran code - you should use the gfortran compiler instead. cheers, David ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
[Numpy-discussion] compile fortran from python
I would like to compile some Fortran code using python, build a shared library, and link to it using python. But I get a message saying the compiler does not recognise the extension of my file. this is my command: gcc -fPIC -c -shared -fno-underscoring test.f95 -o ./lib/libctest.so.1.0 what is the easiest method to achieve this? I suspect I could create a custom extension and customise the unixccompiler object or could I just use the compiler object defined by f2py(fcompiler). Cheers Ioan Ferencik PhD student Aalto University School of Science and Technology Faculty Of Civil and Env. Engineering Lahti Center Tel: +358505122707 ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion