matplotlib and freetype2 on OS X

Tom Loredo <loredo@...477...> writes:

E.g., perhaps I should install freetype into some location not on
the usual search paths, and direct matplotlib to look in that place.
Is there a way to do this that doesn't require manually hacking
matplotlib every time I download a new version?

The add_ft2font_flags function in setupext.py is quite enthusiastic
about using every copy of freetype it can find anywhere. I used to
have some build problems since I have one version of freetype from
fink in /sw, another from Gerben Wierda's TeX installer in /usr/local,
and of course one from Apple in /usr/X11R6; somehow a wrong header
file must have gotten included, since I got really strange errors in
the link phase. What I do now is apply the following patch before
building matplotlib, so this solution ranks just a notch above
"manually hacking". I suppose the right solution would be to hack
setup.py to call freetype-config at a configurable path, but this is
good enough for me...

matplotlib-setup.patch (1.03 KB)

John Hunter wrote:

Another option would be to use one of the precompiled matplotlib
packages that have freetype statically compiled in. I think Charles
Moad has been working on this.

Actually that's me. Charles' approach links matplotlib against a Framework build of freetype.

In either case, my concern is that if PYGTK and matplotlib use a different freetype, there could be problems. My goal ,in the past was to build an Apple-centric matplotlib, and I've kept a fink-free system, and never used PyGTK, so I don't know if there's a conflict there or not.

In general, GTK is kind of non-apple-y, so I tell folks that want to use it to go an all-fink or all darwinports route, which would mean a different python, and who knows what freetype lib, but I'm sure fink and darwinports have figured that out.

I know I couldn't figure out Apple's freetype, it seemed to have a totally different versioning system that what I found in sourceforge, and what the matplotlib expect.

E.g., perhaps I should install freetype into some location not on
the usual search paths, and direct matplotlib to look in that place. Is there a way to do this that doesn't require manually hacking
matplotlib every time I download a new version?

Well, what I'm doing is putting the static libs inside the matplotlib source tree.

- 'darwin' : ['/sw/lib/freetype219', '/usr/local', '/usr', '/sw', '/usr/X11R6'],
+ 'darwin' : ['/sw/', '/usr'],

I'm hoping to be able to do is patch the setup.py so that it would build the statically linked libs by default, if they were there. It would be nice to have a whatever is in the official matplotlib source tarball just build properly out of the box. I"m open to suggestions as to how to do this.

One problem is that Python report the system as "darwin", but this could be Apple's Python, an Framework or non-framework build of the tarball python, fink python, darwinports python, etc. They're all darwin, but they all have different library and linking needs.

I'm going to plug away, and hopefully have a static build by the end of the day (Pacific Time), but it wont' include PYGTK. I'd love it if someone else would try building it my way, but adding PyGTK.

Another note: John suggested that we might want to do what he does on Windows and include the freetype and libpng code in the matplotlib source tree, and just have it automatically build and link static versions right there, with nothing else to download and install. Would this end up conflicting with the libs used by PyGTK (or wxPython or...)

-Chris

ยทยทยท

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...259...