Notes on downloading and installing gmpy 1.03 on MacOSX

(by: Alex Martelli, aleaxit@gmail.com, on Jun 22 2007)


1. Why you need to read this document

At the time of this writing, installing gmpy 1.03 on MacOSX is NOT as
easy and smooth as one might desire, mostly because of issues with the
underlying GMP 4.2 (see http://www.swox.com/gmp/ ).

The simplest solution is to get a GMP 4.2 installation via macports, aka
darwinports -- see http://gmp.darwinports.com/ -- THAT approach saves
you from all the hassles related to building GMP, and in 1.03 gmpy's
setup.py file knows how to find the needed includes and libraries in
macports' /opt hierarchy if you have done that installation. The GMP
related notes below are from BEFORE I found the macports solution, I
am leaving them in just in case they can help somebody who's keen to
avoid macports for whatever reason.

If you want to use gmpy 1.03 on MacOSX, you should read this document,
which explains what you must download and how you must install what
you download.  (Volunteers who have a better grasp than me of how to
build nice installers for MacOSX, to make everything run smoothly and
easily, would be MOST welcome -- please mail me!!!).  Sorry:-(.


2. Currently, I provide binaries only for MacOSX 10.5 (Leopard)

I do not have any MacOSX 10.4 or older machines any more, so I cannot
build GMP on those; all the binaries I'm currently distributing are,
therefore, for MacOSX 10.5 only (volunteers with older MacOSX machines,
XCode as updated as may be, and a willingness to fight against GMP's
installation issues or bypass them via darwinports/macports, are MOST
welcome -- please mail me!!!).  Sorry:-(.


3. The binary Universal build of GMP 4.2 (macosx10.4-gmp4.2-tar.bz2)

REMEMBER: all of this point 3 is NOT needed if you get your GMP from
darwinports/macports -- in that case you can just skip it!

At the time of this writing, I've managed to build GMP 4.2 as a static
library for MacOSX with intel processors, in such a way that Python lets
me build a self-contained gmpy.so with it; however, GMP has so far
defeated my attempts to perform the same feat on MacOSX with PPC
processors:-(.  I _have_ managed to build GMP 4.2 as a _dynamic_
library, but that means that, *on PPC only*, you have to install the
dynamic library before Python will be able to load gmpy.so (installed
from any or all of the .tar.gz "dumb installers" explained in the
following part of this document).

*On PPC only*, to use any of the gmpy 1.03 binary builds, you should
download http://gmpy.googlecode.com/files/macosx10.4-gmp4.2-tar.bz2 ,
open a Terminal, cd to the directory to which you have downloaded
it, and execute:

    tar xjvf macosx10.4-gmp4.2-tar.bz2 -C /

You may need to precede this command with a sudo (sudo tar &c &c),
depending on how you have set up permissions on your machine (I will
not repeat this tidbit in the following: if at any time you get some
strange error about permissions, use sudo in front of the rest of the
command as I suggest it).

Then, *on PPC only*, continue your Terminal session with:
    cd /usr/local/lib
    ln -s libgmp.a libgmp.3.dylib

That's all.

*On intel Macs*, if all you want is to download, install and run any or
all of the pre-built binary packages, you do NOT need to download and
install the library (it's only there to help you out if you want to
*recompile* the gmpy sources, as per the following paragraph).

On either PPC *OR* intel processors, if you want to recompile the gmpy
sources without necessarily having to fight with GMP itself, you need to
download and install GMP 4.2.1 from http://www.swox.com/gmp/ -- and if
you have any problem (make check doesn't work, Python has problems
building gmpy.so, whatever) just rm /usr/local/lib/libgmp* and again
perform the tar (and, on PPC only, ln) steps above mentioned (you do
need to install swox's GMP sources because they provide you with a
properly configured /usr/local/include/gmp.h header file, but it's OK to
rm and reinstall the resulting libgmp.a, and, PPC only, libgmp.3.dylib
with the contents of my .tar.bz2 archive).  Phew.

REMEMBER: all of this point 3 is NOT needed if you get your GMP from
darwinports/macports -- in that case you can just feel grateful to the
dawrinports/macports maintainers for the amount of work they've saved
you!-)


4. The binary dumb-installer for system-provided Python

The installer for the system-provided build of Python 2.5 is Universal:
the same binary download will serve just as well (under MacOSX 10.5
in either case) for intel or PPC processor.

gmpy 1.03 also supports Python 2.6 beta 1 (but there is currently no
binary installer for either Python 2.6b1 itself or gmpy 1.03 for it
for the Mac: you must build from sources for now, sorry!).

To install gmpy 1.03 for the system-version of Python 2.5, open a
Terminal, cd to wherever you have downloaded the package (let's call it
X.tar.gz for generality), and:

    tar xzf X.tar.gz -C /

(you may need to prepend this with sudo, depending on permission issues
with your installation).


5. Verifying that your installation is correct

You must get the sources package (even if you don't plan to rebuild for
sources) as it's the only place you get the documentation and tests.  My
strong recommendation is that you (install svn, then) perform:

    svn checkout http://gmpy.googlecode.com/svn/trunk/ gmpy

in a Terminal session, to get a complete download in directory gmpy.
However you may prefer to download and unpack the .zip file of the
sources for 1.03 specifically.

    python gmpy/test/gmpy_test.py

will rapidly run all unit tests and tell you if there are any problems.

   gmpy/doc/gmpydoc.txt

is a textfile with all the docs for GMPY.

If you run into any problem, please open an issue at:

   http://code.google.com/p/gmpy/issues/list

(or, worst case, email me -- you're likely to get a prompter and better
response on the Issues tracker, though, since other people can help
there, but they can't help with mails sent to me directly!-).


Alex

