python package using a Fortran library

Ryan Schmidt ryandesign at macports.org
Wed Jul 17 02:20:05 PDT 2013


On Jul 17, 2013, at 04:18, Michael Wimmer wrote:

> I want to write a Portfile for a python package that (amongst other
> things) interfaces to a Fortran library.
> 
> To that extent, there are some C-files there that have to be compiled
> and then linked to the library under question, and then in addition also
> to libgfortran (since it's C code). The compilation is done by the
> python setuptools, i.e. the python package is installed by the generic
> "python setup.py install".
> 
> Now, by default (and I'm not entirely sure if it is possible or even
> desirble to change that), python setuptools uses the same C compiler
> with which python itself is compiled, and that apparently is the Xcode
> compiler. The Fortran library I want to link to has been compiled by a
> gfortran of macports. Hence, I need to specify the location where Xcode
> can find the corresponding libgfortran (as far as I have seen, it is
> /opt/local/lib/gcc..).
> 
> My question now is, how can I figure out the path of that library
> automatically?

If you want to use gfortran, you need to use a compiler that has it, like the gcc ports. Add variants allowing the user to choose which one, and default to 4.7:

https://trac.macports.org/wiki/PortfileRecipes#gcc

If the build does not respect the compiler choice, that is a bug that should be fixed.



More information about the macports-users mailing list