PATCH: fix libpng URLs for OS X makefile

Hi,

This patch reminded me to ask why the builtin libpng, zlib and
libfreetype on Mac OS 10.5 and later are not used to build Matplotlib,
removing the need to download these extra libraries. I was pleased to
discover that Snow Leopard shipped with libpng and libfreetype as part
of X11, only to find that even my old Leopard installation had them.
I've been successfully building Matplotlib against them on both
platforms. Besides skipping the download step, these libraries have
the advantage of being correct universal binaries, eliminating another
potential stumbling block. The only problem would be if these
libraries were outdated, but I haven't come across any problems yet.

For the record, I set the following environment variables in
~/.profile on Snow Leopard:

    # These compiler flags ensure 32-bit + 64-bit code generation, as
Snow Leopard produces 64-bit code by default
    export MACOSX_DEPLOYMENT_TARGET=10.6
    export CFLAGS="-arch i386 -arch x86_64 -isysroot
/Developer/SDKs/MacOSX10.6.sdk"
    export LDFLAGS="-arch i386 -arch x86_64
-syslibroot,/Developer/SDKs/MacOSX10.6.sdk"
    export FFLAGS="-m32 -m64"

I then build a Matplotlib egg with:

CFLAGS=${CFLAGS}" -I/usr/X11/include -I/usr/X11/include/freetype2"
LDFLAGS=${LDFLAGS}" -L/usr/X11/lib" python setupegg.py bdist_egg

I've been meaning to publish my installation instructions for
numpy/scipy/matplotlib/ipython on Snow Leopard somewhere for quite a
while, but that will have to wait for another day... I've tried to
trim down my installation procedure to the minimum steps that will
guarantee a working system without introducing extra libraries /
Pythons / etc, so there might be some interest in it.

Ludwig

It may be because we still want to support OS-X 10.4 .

Also, not everyone has X11 installed (or does everyone now?)

I also notice that they are in: MacOSX10.4u.sdk (under X11) -- so maybe the static libs in there could be used.

-Chris

···

On 12/9/10 11:57 PM, Ludwig Schwardt wrote:

This patch reminded me to ask why the builtin libpng, zlib and
libfreetype on Mac OS 10.5 and later are not used to build Matplotlib,

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...236...

2010/12/10 Christopher Barker <Chris.Barker@...236...>:

This patch reminded me to ask why the builtin libpng, zlib and
libfreetype on Mac OS 10.5 and later are not used to build Matplotlib,

It may be because we still want to support OS-X 10.4 .

I was not aware of the presence of libfreetype so far. I'm +1 on
using the libraries shipped with OS X. It should be possible to
deliver an extra package which just installs these libs on 10.4 (in
/usr/local/). But, I don't know when and if I'll finally find the
"time" to look into it definitely.

Anyway, this all would apply only to persons who build from source on
OS X, right? The binaries still have to use static linkage, or am I
wrong?

Also, not everyone has X11 installed (or does everyone now?)

One can opt X11 out at installation time IIRC. But it's a rare case I believe.

I also notice that they are in: MacOSX10.4u.sdk (under X11) -- so maybe
the static libs in there could be used.

This is a question to Russell it seems to me.

Friedrich

···

On 12/9/10 11:57 PM, Ludwig Schwardt wrote:

2010/12/10 Ludwig Schwardt <ludwig.schwardt@...149...>:

For the record, I set the following environment variables in
~/.profile on Snow Leopard:

# These compiler flags ensure 32-bit + 64-bit code generation, as
Snow Leopard produces 64-bit code by default
export MACOSX_DEPLOYMENT_TARGET=10.6
export CFLAGS="-arch i386 -arch x86_64 -isysroot
/Developer/SDKs/MacOSX10.6.sdk"
export LDFLAGS="-arch i386 -arch x86_64
-syslibroot,/Developer/SDKs/MacOSX10.6.sdk"
export FFLAGS="-m32 -m64"

CFLAGS=\{CFLAGS\}&quot; \-I/usr/X11/include \-I/usr/X11/include/freetype2&quot; LDFLAGS={LDFLAGS}" -L/usr/X11/lib" python setupegg.py bdist_egg

Python normally chooses those -arch flags which were chosen for Python
at compile time.

It's not a good idea to set CFLAGS and LDFLAGS with distutils I
learned. They do not stack with the compilation time CFLAGS etc., but
completely override. Better adapt the pathes in setupext.py.

I've been meaning to publish my installation instructions for
numpy/scipy/matplotlib/ipython on Snow Leopard somewhere for quite a
while, but that will have to wait for another day... I've tried to
trim down my installation procedure to the minimum steps that will
guarantee a working system without introducing extra libraries /
Pythons / etc, so there might be some interest in it.

So we should team up in improving our docs :slight_smile:

Friedrich

I don’t know what the situation is now, but the last version of OS X I installed was 10.4 and X11 was a separate installation from xcode, if I recall correctly. Are you sure it is on by default?

I don’t mind using system libs

  • if we are sure they are there

  • they are in a consistent location

The reason we switched to static builds was there was so much variation in where these libs were coming from (macports, fink, system libs) and some of the versions were out of date, it was almost impossible to ship usable binaries.

Russell will have to take the lead on this if he thinks it is a good idea, as he is the OSX build master.

JDH

···

On Fri, Dec 31, 2010 at 9:54 AM, Friedrich Romstedt <friedrichromstedt@…149…> wrote:

Also, not everyone has X11 installed (or does everyone now?)

One can opt X11 out at installation time IIRC. But it’s a rare case I believe.

We’d be happy to have a doc contribution to the installing page or to the FAQ.

JDH

···

On Fri, Dec 31, 2010 at 10:00 AM, Friedrich Romstedt <friedrichromstedt@…149…> wrote:

I’ve been meaning to publish my installation instructions for

numpy/scipy/matplotlib/ipython on Snow Leopard somewhere for quite a

while, but that will have to wait for another day… I’ve tried to

trim down my installation procedure to the minimum steps that will

guarantee a working system without introducing extra libraries /

Pythons / etc, so there might be some interest in it.

So we should team up in improving our docs :slight_smile:

2010/12/31 John Hunter <jdh2358@...149...>:

I don't know what the situation is now, but the last version of OS X I
installed was 10.4 and X11 was a separate installation from xcode, if I
recall correctly. Are you sure it is on by default?

I'm not completely sure, but really quite sure. I don't think it's
coming from Xcode on 10.6. E.g. Inkscape runs on X11, and it ran from
the beginning. I don't think they'll distribute binaries depending on
an Xcode installation. To be sure, I'll soon have probably the
opportunity to reinstall some both 10.5 and 10.6 machines, so I can
have a look. And I heard before about the libpng libraries in
/usr/X11/lib/, and I just verified. Developer stuff goes to
/Developer/.

I don't mind using system libs

* if we are sure they are there

* they are in a consistent location

The reason we switched to static builds was there was so much variation in
where these libs were coming from (macports, fink, system libs) and some of
the versions were out of date, it was almost impossible to ship usable
binaries.

I agree, and I personally would prefer static libs for binary
distribution, since we would be limited to the 10.5 libs, or, more
strictly, one could say that binaries should also run on 10.4. I
think it's mainly targeting people who want to build their mpl
themselves, let it be for bug tracking, but are frightened by the
dependencies atm.

Russell will have to take the lead on this if he thinks it is a good idea,
as he is the OSX build master.

I agree fully.

Friedrich