Compiling matplotlib against 64 bit python 2.6 on OSX Snow Leopard

Dear Friedrich,

sorry for the confusion.
It may very well be that I misinterpreted part of the problem as I am
no expert either.
The problem came to be as follows.
At first I used the binaries for the latest stable releases of Python
2.6 + numpy + matplotlib from the respected websites.
But in order to compile a custom library I needed Python to be compiled 64 bit.
This worked for Python, numpy and scipy but not for matplotlib.
I used to be able to compile matplotlib with a simple "sudo python
setup.py install" but when I tried to do this after the change to 64
bit the build failed with some errors which seemed to me to be related
to freetype not being compiled 64 bit (these errors, which I
unfortunately did not save clearly indicated that the linker could not
find some symbols and when I checked the architecture of the libs it
was i386 only).
I tried to fix this by first compiling freetype 64 bit, and later
libpng as well.
The problem now was that setupext.py did not look in the right
location for my new libpng build.
After I installed pkgtool this was also solved, however now the
reported error occurred.
I also could not use the make.osx script from the latest svn checkout
because of a bug in the fetching of zlib which John fixed.
Finally removing my custom installations of freetype and libpng and
using make.osx to fetch and build them solved the problem.
Oh and somewhere in all this mess I also managed to build it but then
got a malloc error when loading so I tried the removing of i386 but
this did not solve the problem so I changed it back.
I guess the conclusion is that the current svn works, but only with
the make.osx approach.
If I had the time I would try it again on a fresh install to see where
the bug is that prevents setup.py from working with a custom compiled
freetype and libpng but for now I am happy that it finally works :slight_smile:

Kind regards,

Pim Schellart

2010/5/27 Friedrich Romstedt <friedrichromstedt@...287...>:

ยทยทยท

2010/5/27 Pim Schellart <p.schellart@...287...>:

thank you for the tip, I'll try and see if the stable release works as
well with this adjustment.
The problem however was not just in compiling on Snow Leopard, but
compiling specifically against a custom compiled 64 bit only version
of python.
This now works with the make.osx file and the latest svn release,
although I agree this is an ugly solution and would prefer the same
build system on every OS.

Pim,

I must confess that I'm lost a bit in all this details and all this
patches ... I hope that I'm not alone with this ... Can you maybe give
a short summary on the list?

First I don't understand why you compiled a "64 bit only" version of
your Python. I.e., what am I missing, when I compile my Python 2.6
the usual way? (I also have a 64 bit machine.)

Then, your first error seems to originate from:

src/ft2font.h:13:22: error: ft2build.h: No such file or directory

I don't know, but I guess it's due to not finding the correct include
directory for you self-compiled freetype2? If it is like this, I
fixed it in setupext.py (the "darwin" section, not the "darwin_"
section). The search path list is empty for "darwin", and I added
"/usr/local" into it. Actually I don't remember precisely what the
error was making me fixing this ... And it's true, I simply ignored
the "# So I'm pointing to ..." comment in setupext.py ...

Then the next error you reported was clearly related to libpng API
change, so again nothing with 32/64 bit issues.

So, I don't understand your conclusion that at all you have problems
due to your 64bit-only built Python? Sorry, maybe I miss something
obvious? I think people have been trusting you that it's a 64bit
issue, and gave suggestions based on that, but maybe it isn't at all?
Just a whacky thought! I simply cannot find an error pointing towards
this root! I now went throught it again finally, and I found that
magically John mentioned his "work for 64bit Python on the make.osx
file", and then there was some "remove all -arch i386" recommendation,
but it's all a bit unclear to me ... Sorry, I'm not an expert at all,
my intention is just to track the problem /not to the false root/
down.

My explanation is: You downloaded by using make.osx an older version
of libpng (1.2) and additionally a freetype version in local
directory, so all the -Is are working respectively. This solved both
your freetype problem and your libpng problem. I need some advice
what else was solved by make.osx?

Of course this path is good for creating binaries with libpng and
freetype2 hardlinked, but I don't see the clue for your case.

Friedrich

Dear Pim,

2010/5/27 Pim Schellart <p.schellart@...287...>:

At first I used the binaries for the latest stable releases of Python
2.6 + numpy + matplotlib from the respected websites.
But in order to compile a custom library I needed Python to be compiled 64 bit.

For me this was the same with PIL ... though I didn't need 64bit for
that. And I agree, for a new Mac user it's a mess.

This worked for Python, numpy and scipy but not for matplotlib.
I used to be able to compile matplotlib with a simple "sudo python
setup.py install" but when I tried to do this after the change to 64
bit the build failed with some errors which seemed to me to be related
to freetype not being compiled 64 bit (these errors, which I
unfortunately did not save clearly indicated that the linker could not
find some symbols and when I checked the architecture of the libs it
was i386 only).
I tried to fix this by first compiling freetype 64 bit, and later
libpng as well.
The problem now was that setupext.py did not look in the right
location for my new libpng build.
After I installed pkgtool this was also solved, however now the
reported error occurred.

And this error was due to the API change.

I also could not use the make.osx script from the latest svn checkout
because of a bug in the fetching of zlib which John fixed.
Finally removing my custom installations of freetype and libpng and
using make.osx to fetch and build them solved the problem.

Oh and somewhere in all this mess I also managed to build it but then
got a malloc error when loading so I tried the removing of i386 but
this did not solve the problem so I changed it back.

This I don't understand.

I guess the conclusion is that the current svn works, but only with
the make.osx approach.

I cannot agree currently. I can try to do my first contact with svn,
but for the stable release, it works as said before with some tweaking
in setupext.py and src/_png.cpp too. Also we seem to have quite
similar machines and prerequisites. The setupext.py tweak may be
omittable by using pkgtool.

So my conclusion is that with using pkgtool and the change in
src/_png.cpp matplotlib should be buildable from sources with
setup.py.

John, shouldn't we finally fix this ugly src/_png.cpp problem? More
and more people run into problems when using the recent libpng-1.4.
The lines to be added to _png.cpp are:

#define png_infopp_NULL (png_infopp)NULL
#define int_p_NULL (int*)NULL

Maybe libpng defines some constant to make use of in determining
whether the build is with libpng-1.2 or 1.4.

If I had the time I would try it again on a fresh install to see where
the bug is that prevents setup.py from working with a custom compiled
freetype and libpng but for now I am happy that it finally works :slight_smile:

I can understand you and I'm facing the same problem.

Friedrich