[Distutils] distutils on OS X?

Jack Jansen jack@oratrix.nl
Fri Nov 9 05:51:01 2001


> Hi,
> 
> I haven't seen many postings about Darwin and Mac OS X in this 
> group, so let me add one!
> 
> Has anybody a clue about the official status of distutils on 
> this platform? I'm trying to build the reportlab package, 
> but find that distutils seems to be fully unaware of anything
> like a 'darwin' platform...

Hmm, distutils seems to be aware enough of Darwin that Python's own setup.py, 
for building the standard extension modules, works grand.

> [...]
>
> cc -bundle -undefined suppress build/temp.darwin-1.4-Power Macintosh-2.1/_rl_accel.o -o build/lib.darwin-1.4-Power Macintosh-2.1/_rl_accel.so
> /usr/bin/ld: /usr/lib/libSystem.dylib load command 6 unknown cmd field
> error: command 'cc' failed with exit status 1

My guess is that the "-undefined suppress" is the main problem. As of Mac OS X 
10.1 using that option is heavily discouraged. What the option does is 
basically say "ignore all undefined references, we'll see what we can do about 
them at load time". I'm not 100% sure that this is the problem here, because 
the error message looks a bit funny, but the rest of the info in this message 
is true anyway, even if it doesn't solve the immedeate problem:-)

The correct way to build extensions is either one of the following:
- Build a framework Python, by using --enable-framework on the configure.
  This will create the whole Python core as a framework, and extensions
  will be linked against this framework. This creates a more MacOSX-like
  python (and it is what I usually do), but the Python will be less unix-like.
  Distutils already understands about this one.
- Modify distutils so that it passes the "-bundle_loader python" option
  to the linker (where "python" is the path to the Python executable), and
  not pass "-undefined suppress". This will allow the linker to lookup the
  external references from the extension in the python executable, and register
  that those externals will be satisfied from the loading executable at load
  time. (Note that the executable at load time needn't be in the same place).

--
Jack Jansen             | ++++ stop the execution of Mumia Abu-Jamal ++++
Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++
www.cwi.nl/~jack        | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm