matplotlib OS-X binary problems.

Hi all,

I posted a note here the other day about a matplotlib binary. I've discovered a problem with it. Apparently, it has linked against the libfreetype in /usr/X11. That means it will work fine on a system with Apple's X11 installed (like mine or the first system I tested it on).

So, the question remains: How to I get distutils to statically link selected libs? Bob had suggested:

"""Make sure you don't have libpng.dylib or libfreetype.dylib sitting around on your link paths...

Build them like this:
./configure --disable-shared --enable static

Make sure you only have libpng.a and libfreetype.a on your link paths. It will link statically.
"""

However, that doesn't seem to work if I have libfreetype.dylib somewhere standard, and I certainly don't want to remove it! (Maybe I could temporarily, but that's hardly the robust solution I'm looking for)

By the way, it would also be good to get this to work with TK and/or GTK. Has anyone done that successfully that would like to help out with this?

Also, as far as PyGTK is concerned. Can you run it without running Fink? That's the only way I've seen it done. If it is a Fink only option, then this is moot, as I'm looking for a Fink free approach, and someone else has put together a fink matplotlib package.

By the way the package, as it stands, can be found at:

http://undefined.org/python/matplotlib-0.71-py2.3-macosx10.3.zip

thanks to Bob Ippolito

-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...

I posted a note here the other day about a matplotlib binary. I've discovered a problem with it. Apparently, it has linked against the libfreetype in /usr/X11. That means it will work fine on a system with Apple's X11 installed (like mine or the first system I tested it on).

.. and the system that I tested it on :slight_smile:

So, the question remains: How to I get distutils to statically link selected libs? Bob had suggested:

"""Make sure you don't have libpng.dylib or libfreetype.dylib sitting around on your link paths...

Build them like this:
./configure --disable-shared --enable static

Make sure you only have libpng.a and libfreetype.a on your link paths. It will link statically.
"""

However, that doesn't seem to work if I have libfreetype.dylib somewhere standard, and I certainly don't want to remove it! (Maybe I could temporarily, but that's hardly the robust solution I'm looking for)

You have three options:
- make sure the dylibs aren't sitting around in the same location as the .a, and make sure the .a's path is preferred (you could make a local dir, -L to it, symlink the archives in)
- change the setup.py relatively significantly and specify them as object files with their full path (I can't tell you off the top of my head what the distutils incantation would be for this, but you definitely can not use it's "libraries" option, or whatever that is called)
- don't link statically and install the dylibs too, somehow (possibly by building+installing them with --prefix=/Library/Python/2.3/matplotlib/lib-dynload/ and -L to that when linking.. note that this would require a bdist_mpkg subclass to make a .pkg out of it)

-bob

···

On Feb 3, 2005, at 19:07, Chris Barker wrote:

Chris Barker wrote:

However, that doesn't seem to work if I have libfreetype.dylib somewhere standard, and I certainly don't want to remove it! (Maybe I could temporarily, but that's hardly the robust solution I'm looking for)

Change the paths that distutils will add to the link line. They're at the top of setupext.py . Remove the ones you don't need.

By the way, it would also be good to get this to work with TK and/or GTK. Has anyone done that successfully that would like to help out with this?

With TclTkAqua, it Just Works.

Also, as far as PyGTK is concerned. Can you run it without running Fink? That's the only way I've seen it done. If it is a Fink only option, then this is moot, as I'm looking for a Fink free approach, and someone else has put together a fink matplotlib package.

You could try Darwinports. Set Darwinports' prefix to /usr/local, and use port(1) to make Installer.app packages for GTK et al. Bundle them with your bdist_mpkg metapackage.

My strategy for building matplotlib (and I've done it *a lot* in the past few weeks) is as follows:

I have Darwinports with a prefix in a GNU Stow repository. What Stow does is it allows you to install stuff into it's own directory (/usr/local/stow/darwinports, which has bin/, lib/, share/ et al.) and then makes symlinks such that everything appears to be installed to /usr/local. So I have Darwinports install libpng and libfreetype. I have a script that will remove the symlinks to the dylibs for libpng, libfreetype, and libz (I could probably resolve this by changing the order of search). I build matplotlib and double-check the dylib dependencies with "otool -L". I do not bother with GTK at this time.

···

--
Robert Kern
rkern@...376...

"In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die."
   -- Richard Harter

And while we're on the subject of OS X builds, I have a request.

Can you add /usr/local/share/matplotlib to the list of default locations search for the data directory?

/System/Library/Frameworks/Python.framework/Versions/Current/share/matplotlib is not, I think a good place for it.

···

--
Robert Kern
rkern@...376...

"In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die."
   -- Richard Harter

Robert Kern wrote:

Chris Barker wrote:

However, that doesn't seem to work if I have libfreetype.dylib somewhere standard, and I certainly don't want to remove it! (Maybe I could temporarily, but that's hardly the robust solution I'm looking for)

Change the paths that distutils will add to the link line. They're at the top of setupext.py . Remove the ones you don't need.

Except that the *.a and *.dylib are put in the same place. Darn.

By the way, it would also be good to get this to work with TK and/or GTK. Has anyone done that successfully that would like to help out with this?

With TclTkAqua, it Just Works.

Someone posted recently to the MacPython Mailing list with a series of questions that this was not the case, at least to for him. So I wasn't sure.

Also, as far as PyGTK is concerned. Can you run it without running Fink? That's the only way I've seen it done. If it is a Fink only option, then this is moot, as I'm looking for a Fink free approach, and someone else has put together a fink matplotlib package.

You could try Darwinports. Set Darwinports' prefix to /usr/local, and use port(1) to make Installer.app packages for GTK et al. Bundle them with your bdist_mpkg metapackage.

Hmm. That sounds promising. However...

My immediate need to to get matplotlib installed on and OS-X Server box that someone else is administering. For this purpose, I only need the Agg back end. However, for my own purposes, I also want wx. The easiest way for me to accomplish my immediate goal is probably to just install all the libs needed on that server, but I'm trying to keep it simple for the admin, and I figured this could be a useful contribution to the MacPython community.

However, here is the complication. As long as I am doing this, I'd like to make it as useful as possible. That means it would be nice if I could come up with a single binary that works with all the available back ends on OS-X (Agg, wx, PyGTK, Tkinter). I also want people to be able to install it on a stock box and have it work. This doesn't mean that I want it to include PyGTK and TK, but it would be nice if it worked with those, if they were present.

The question is: Can I build a binary version that will work with all the back ends, if they are there, but also work on what is there if they aren't all. This comes down to when the linking happens, I guess. Experimentation will answer this for me, but I welcome and insight any of you may have.

One issue that has come up is libfreetype. If you have GTK, you have X11, so you have libfreetype. Indeed, I don't have GTK, but I do have X11, and the X11 freetype got linked to my package. I can probably fix this by removing "/usr/X11R6" from the basedir list for darwin. Then I'll have libfreetype statically linked to matplotlib, but PyGTK, if the user has it, will have a different version dynamically linked. Is this going to cause problems?

More as I make more progress...

-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...

Chris Barker wrote:

Robert Kern wrote:

Change the paths that distutils will add to the link line. They're at the top of setupext.py . Remove the ones you don't need.

Except that the *.a and *.dylib are put in the same place. Darn.

Copy (and re-ranlib) the static library and headers to another place.

···

--
Robert Kern
rkern@...376...

"In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die."
   -- Richard Harter