Building with a non-standard gfortran
![](https://secure.gravatar.com/avatar/c1ccdb0ce428ac57e8a1d815a281d4d3.jpg?s=120&d=mm&r=g)
Hi Using MacPorts, the gfortran compiler, from gcc-4.2.x, is installed as gfortran-mp-4.2. I have been trying to build scipy with this compiler and found that that numpy I need to build and install with $ python setup.py config_fc --fcompiler gnu95 \ --f77exec /opt/local/bin/gfortran-mp-4.2 \ --f90exec /opt/local/bin/gfortran-mp-4.2 build $ python setup.py install --prefix=${NUMPY_LOCATION} however using the above for scipy fails on the install phase with it being unable to locate a fortran compiler. I therefore need to install scipy with $ python setup.py config_fc --fcompiler gnu95 \ --f77exec /opt/local/bin/gfortran-mp-4.2 \ --f90exec /opt/local/bin/gfortran-mp-4.2 install --prefix=${SCIPY_LOCATION} Is this expected, as I would have expected install to inherit the options that where used during the build phase? Cheers Adam PS: I'm using numpy-1.0.4 and scipy-0.6.0
![](https://secure.gravatar.com/avatar/c1ccdb0ce428ac57e8a1d815a281d4d3.jpg?s=120&d=mm&r=g)
On 20/11/2007, Adam Mercer <ramercer@gmail.com> wrote:
Hi
Using MacPorts, the gfortran compiler, from gcc-4.2.x, is installed as gfortran-mp-4.2. I have been trying to build scipy with this compiler and found that that numpy I need to build and install with
$ python setup.py config_fc --fcompiler gnu95 \ --f77exec /opt/local/bin/gfortran-mp-4.2 \ --f90exec /opt/local/bin/gfortran-mp-4.2 build $ python setup.py install --prefix=${NUMPY_LOCATION}
however using the above for scipy fails on the install phase with it being unable to locate a fortran compiler. I therefore need to install scipy with
$ python setup.py config_fc --fcompiler gnu95 \ --f77exec /opt/local/bin/gfortran-mp-4.2 \ --f90exec /opt/local/bin/gfortran-mp-4.2 install --prefix=${SCIPY_LOCATION}
Is this expected, as I would have expected install to inherit the options that where used during the build phase?
Cheers
Adam
PS: I'm using numpy-1.0.4 and scipy-0.6.0
Anyone?
![](https://secure.gravatar.com/avatar/5c85708f2eed0869671a7d303ca55b85.jpg?s=120&d=mm&r=g)
On Nov 20, 2007, at 09:03 , Adam Mercer wrote:
Hi
Using MacPorts, the gfortran compiler, from gcc-4.2.x, is installed as gfortran-mp-4.2. I have been trying to build scipy with this compiler and found that that numpy I need to build and install with
$ python setup.py config_fc --fcompiler gnu95 \ --f77exec /opt/local/bin/gfortran-mp-4.2 \ --f90exec /opt/local/bin/gfortran-mp-4.2 build $ python setup.py install --prefix=${NUMPY_LOCATION}
however using the above for scipy fails on the install phase with it being unable to locate a fortran compiler. I therefore need to install scipy with
$ python setup.py config_fc --fcompiler gnu95 \ --f77exec /opt/local/bin/gfortran-mp-4.2 \ --f90exec /opt/local/bin/gfortran-mp-4.2 install --prefix=$ {SCIPY_LOCATION}
Is this expected, as I would have expected install to inherit the options that where used during the build phase?
The options used in the build phase aren't stored, so, yes, they need to be respecified. For numpy it doesn't matter, as the Fortran compiler isn't used. Since we use distutils, you can set the config_fc options in a file (either globally for the user in a ~/.pydistutils.cfg, or per-package in a setup.cfg next to the setup.py you're running) by adding the following section to the appropiate file [config_fc] fcompiler=gfortran f77exec=gfortran-mp-4.2 f90exec=gfortran-mp-4.2 -- |>|\/|< /------------------------------------------------------------------\ |David M. Cooke http://arbutus.physics.mcmaster.ca/dmc/ |cookedm@physics.mcmaster.ca
![](https://secure.gravatar.com/avatar/39670e52a1a9e63db9652fdcf64390d7.jpg?s=120&d=mm&r=g)
David M. Cooke wrote:
On Nov 20, 2007, at 09:03 , Adam Mercer wrote:
Hi
Using MacPorts, the gfortran compiler, from gcc-4.2.x, is installed as gfortran-mp-4.2. I have been trying to build scipy with this compiler and found that that numpy I need to build and install with
$ python setup.py config_fc --fcompiler gnu95 \ --f77exec /opt/local/bin/gfortran-mp-4.2 \ --f90exec /opt/local/bin/gfortran-mp-4.2 build $ python setup.py install --prefix=${NUMPY_LOCATION}
however using the above for scipy fails on the install phase with it being unable to locate a fortran compiler. I therefore need to install scipy with
$ python setup.py config_fc --fcompiler gnu95 \ --f77exec /opt/local/bin/gfortran-mp-4.2 \ --f90exec /opt/local/bin/gfortran-mp-4.2 install --prefix=$ {SCIPY_LOCATION}
Is this expected, as I would have expected install to inherit the options that where used during the build phase?
The options used in the build phase aren't stored, so, yes, they need to be respecified. For numpy it doesn't matter, as the Fortran compiler isn't used. Since we use distutils, you can set the config_fc options in a file (either globally for the user in a ~/.pydistutils.cfg, or per-package in a setup.cfg next to the setup.py you're running) by adding the following section to the appropiate file
[config_fc] fcompiler=gfortran f77exec=gfortran-mp-4.2 f90exec=gfortran-mp-4.2
Thanks for the tip, David. I tried it : [cohen@localhost scipy-svn]$ which gfortran /usr/bin/gfortran [cohen@localhost scipy-svn]$ more ~/.pydistutils.cfg [config_fc] fcompiler=gfortran f77exec=gfortran f90exec=gfortran and 'python setup.py build' does correctly use gfortran, but both numpy and scipy keep putting out customize GnuFCompiler gnu: no Fortran 90 compiler found gnu: no Fortran 90 compiler found customize GnuFCompiler gnu: no Fortran 90 compiler found gnu: no Fortran 90 compiler found customize GnuFCompiler using build_ext at install time.... Also, now that I am at it, there seems to be a doubling of the mach library, which should be solved for cleanliness : customize UnixCCompiler using build_ext library 'mach' defined more than once, overwriting build_info {'sources': ['scipy/integrate/mach/i1mach.f', 'scipy/integrate/mach/xerror.f', 'scipy/integrate/mach/r1mach.f', 'scipy/integrate/mach/d1mach.f'], 'config_fc': {'noopt': ('scipy/integrate/setup.pyc', 1)}, 'source_languages': ['f77']}... with {'sources': ['scipy/special/mach/i1mach.f', 'scipy/special/mach/xerror.f', 'scipy/special/mach/r1mach.f', 'scipy/special/mach/d1mach.f'], 'config_fc': {'noopt': ('scipy/special/setup.pyc', 1)}, 'source_languages': ['f77']}... best, Johann
![](https://secure.gravatar.com/avatar/fbee6b353123221d89ab786eeeee7260.jpg?s=120&d=mm&r=g)
I've got an extended version of the same query. I have installed gcc43 into /opt/local/bin from macports, and would like to use this gcc (and associated c++ and gfortran) to compile numpy/scipy/pytables/matplotlib. /opt/local/bin is at the start of my $PATH I understand I create ~/.pydistutils.cfg something like [config_fc] fcompiler=gfortran f77exec=gfortran-mp-4.3 f90exec=gfortran-mp-4.3 opt='-mtune=core2 -march=core2' [config] compiler=gcc cc=gcc-mp-4.3 But ... 1. how do i specify the gcc4.3 C++ compiler for matplotlib etc..? 2. how do i specify the C & C++ compiler options (like -mtune=core2, -march=core2) 2. do I need to add /opt/local/lib to my $LD_LIBRARY_PATH? Or is there a less drastic method? 3. Is there anything else I need? Apologies if I've missed the documentation. Regards, George Nurser.
participants (4)
-
Adam Mercer
-
David M. Cooke
-
George Nurser
-
Johann Cohen-Tanugi