On Mon, May 6, 2013 at 3:53 PM, Michael Droettboom <mdroe@...86...> wrote:
My understanding is that distutils builds up the commandline arguments for
gcc in this order:
1) From Python's Makefile.
2) From environment variables
3) From whatever was added by the setup.py script
It looks like you have some extra stuff in (1), namely
You can find the Python Makefile that is being used to source this
from distutils import sysconfig
In : from distutils import sysconfig
In : sysconfig.get_makefile_filename()
You can edit that file, though obviously that's a bit of a hack.
It contains the lines:
CPPFLAGS= -I. -IInclude -I$(srcdir)/Include -I/usr/include/x86_64-linux-gnu
LDFLAGS= -L/usr/lib/x86_64-linux-gnu -L/lib/x86_64-linux-gnu
So indeed this is causing it. I think this comes from building our own
Python, which I do with:
export arch=$(dpkg-architecture -qDEB_HOST_MULTIARCH)
export LDFLAGS="-L/usr/lib/$arch -L/lib/$arch"
# Fix for #21:
And this is a bit of a hack too, Ubuntu specific etc. I think I should
start fixing things here.
It just wouldn't occur to me, that remains of how I built Python would
bite me later when building
So to test if modifying the Python makefile fixes it, I did:
--- Makefile.old 2013-05-06 16:26:25.426440205 -0600
+++ Makefile 2013-05-06 16:27:05.282439550 -0600
@@ -73,8 +73,8 @@
# Both CPPFLAGS and LDFLAGS need to contain the shell's value for setup.py to
# be able to build extension modules using the directories specified in the
# environment variables
-CPPFLAGS= -I. -IInclude -I$(srcdir)/Include -I/usr/include/x86_64-linux-gnu
-LDFLAGS= -L/usr/lib/x86_64-linux-gnu -L/lib/x86_64-linux-gnu
+CPPFLAGS= -I. -IInclude -I$(srcdir)/Include
but mpl build system still shows the system one. The _png.so is built with:
[matplotlib] g++ -pthread -shared
-L/usr/lib -lpng12 -lz -lstdc++ -lm -o
Which in my opinion looks good -- my own version of PNG is offered
first on the gcc command line. But the -lpng12 part spoils it --- that
forces gcc to use the systemone, because my own version is newer.
So I think that part of the problem gets fixed by modifying the Python
Makefile, but the other part of the problem is how to force distutils
to look for my PNG version before the systemwide. Any ideas?
Maybe it is something that is added by the mpl setup.py script.
I've run into this problem before, and there doesn't seem to be any good way
around it -- i.e. there doesn't seem to be a way to insert local environment
variables in front of the global Python configuration. Reason number #47
why distutils is a poor build system for C/C++ code.
This is amazingly broken.