|
From: Chris B. <Chr...@no...> - 2005-06-17 00:19:18
Attachments:
BuildingMatplotlib.txt
|
Hi all,
I've been working on my binary packages for OS-X. What I'd like to do is
change the setupext.py to be able to "just work" on OS-X. this is a
trick, because while OS-X is a very standardized platform (compared to
Linux at least) that only applies to stuff Apple provides. If Apple
doesn't provide it, we're left with:
fink
darwinports
gentoo
tarball+make
etc.
Each of these puts stuff in different places, so it's a pain to try to
accommodate them.
My goal is to build a single installable package for mpl that an OS-X
user can just install, without needing any non-python dependencies. I
accomplish this by statically lining libpng and libfreetype in, and it
all works pretty well. Unfortunately, the only way I know of to
statically link libs is to make sure the linker finds only the static
versions when linking. I've accomplished this by creating a StaticLibs
directory inside the mpl source tree, putting that on the path, and
putting the libs and needed header files in there.
What I propose for setup.py is to have a little section that looks at
your system to figure out what you might have installed, and sets the
paths accordingly. At the top of setupext.py, I've put:
## CHB: added the following for some "smarts" on OS-X
import sys
if sys.platform == 'darwin':
## This is OS-X is some form, but which?
if os.path.isdir('StaticLibs'):
# The StaticLibs dir is there, it should have everything needed.
# that is: libfreeype.a and libpng.a, and the freetype include dir
darwinpath = ['StaticLibs']
elif os.path.isdir('/sw'):
# It looks like this is a fink system, so let's look there too:
# Someone please check this: I don't have fink.
darwinpath = ['/sw/lib/freetype219', '/usr/local', '/usr', '/sw']
else:
#Let's just try some generic locations
# there should be a darwinports option here too,
# but I don't know what it would be.
darwinpath = ['/usr/local', '/usr']
else:
darwinpath = None
## Note: This is where you could put in whatever you want instead:
#darwinpath = ['/usr/local', '/usr', '/sw', '/usr/X11R6']
basedir = {
'win32' : ['win32_static',],
'linux2' : ['/usr/local', '/usr',],
'linux' : ['/usr/local', '/usr',],
# Charles Moad recommends not putting in /usr/X11R6 for darwin
# because freetype in this dir is too old for mpl
'darwin' : darwinpath,
'freebsd4' : ['/usr/local', '/usr'],
'freebsd5' : ['/usr/local', '/usr'],
'freebsd6' : ['/usr/local', '/usr'],
'sunos5' : [os.getenv('MPLIB_BASE') or '/usr/local',],
}
If people have fink, and darwinports, and the static libs installed, I
figure they are on their own!
What do you all think? Perhaps, if nothing else, it could check in more
detail that just the presence of those top level directories. I've only
tested this with the StaticLibs approach.
I've also enclosed my write-up of how to setup and build a static
version on OS-X. Comments on that would be great too.
Other thoughts?
-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
Chr...@no...
|
|
From: John H. <jdh...@ac...> - 2005-06-17 03:47:11
|
>>>>> "Chris" == Chris Barker <Chr...@no...> writes:
Chris> Hi all, I've been working on my binary packages for
Chris> I've also enclosed my write-up of how to setup and build a
Chris> static version on OS-X. Comments on that would be great
Chris> too.
Chris> Other thoughts?
I think all of this looks good. My only comment is that I think it
would save work in the long run to not use static libs in the static
dir, but instead put in the src trees for zlib, libpng and freetype,
because then it can be reused by all other platforms (win32, UNIX*,
linux, OSX...). It's a little more work initially, but the work will
benefit many more platforms. We could then distribute this tar file
as a separate file to keep the distribution size down. I think that
zlib and png are pretty trivial (everything in one dir); freetype
would take a little thought because of its more complicated dir
structure.
JDH
|
|
From: Chris B. <Chr...@no...> - 2005-06-17 16:53:00
|
John Hunter wrote:
>>>>>>"Chris" == Chris Barker <Chr...@no...> writes:
> Chris> I've also enclosed my write-up of how to setup and build a
> Chris> static version on OS-X. Comments on that would be great
> Chris> too.
>
> Chris> Other thoughts?
>
> I think all of this looks good. My only comment is that I think it
> would save work in the long run to not use static libs in the static
> dir, but instead put in the src trees for zlib, libpng and freetype,
> because then it can be reused by all other platforms (win32, UNIX*,
> linux, OSX...)
This is a fine idea, but I'm not going to do it. If someone else does,
I'll update my docs with the new info. Basically, I don't know how to
make setup.py build the libs inside the tree, and I'm not sure I want to
figure it out. I'm spent more time on this than I intended as it is.
A small note: OS-X includes zib, so that's not needed, at least for OS-X.
One other concern: This will mean that those libs might not match the
versions used by other python packages. Would there be any conflict if
there are essentially two versions of the same lib both linked to python
at the same time?
> freetype
> would take a little thought because of its more complicated dir
> structure.
True, but it does build with a simple "make", so it may not be a big deal.
-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
Chr...@no...
|