Problem with Fortran compilation when numpy.distutils is used

Joshua Root jmr at macports.org
Tue Jan 14 12:45:57 PST 2014


On 2014-1-15 05:42 , Peter Danecek wrote:
> 
> Hi all,
> 
> here as short follow up on this issue (the problems was described earlier, see below), as I have now a clearer idea what is happening. There seems to be no other python port (Python Portgroup) using numpy.distutils to compile Python extensions written in Fortran. 
> 
> Now I understand better that the difference between building manually and using Macports and what is causing the problem. I have found solutions to the problem, but I am not sure if it would be okay.
> 
> It is caused by the Python Portgroup which is setting by default the environment variable LDFLAGS to pass the architecture, (see http://guide.macports.org/#reference.portgroup.python.keywords). If this environment variable is set, the `setup.py` script (or more precisely `numpy.distutils.fcompiler`) fails to determine the correct linker flags ("-undefined dynamic_lookup -bundle" is missing) and to link the binary extension file (*.so) from fortran sources. This affects only fortran code.

The normal distutils behaviour is to append the flags from the
environment to the default value. So it seems numpy.distutils behaves
incompatibly.

> One solution I came up with is to set `python.add_archflags no`. Is this appropriate? I am not exactly sure why this setting of LDFLAGS is done the first place, but I assume it could be related to universal builds. The port is `universal_variant no` so is it okay just to disable?

You can do that, but you need to insert the archflags yourself then.
Even without a universal variant you still need to support build_arch.

- Josh


More information about the macports-dev mailing list