|
From: Chris B. <Chr...@no...> - 2005-06-17 00:19:18
|
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...
|