[Fwd: Re: [Pythonmac-SIG] OS X import bug?]
terabaap at yumpee.org
Sat Jan 26 03:09:31 CET 2002
Confirmed a solution to the OS X import bug/feature.
The flat namespace used in building extension
modules is to blame.
I just edited /usr/local/lib/python2.2/config/Makefile
and changed both LDSHARED and BLDSHARED to be
$(CC) $(LDFLAGS) -bundle -bundle_loader /usr/local/bin/python2.2 -undefined error
(disabling the flat namespace and using
two-level namespace linking)
Now, I can build and import both foo and
bar into the same interpreter session without
problems. Note that I didn't re-build Python,
just edited the Makefile. Not sure if
this will have ramifications for other modules ...
I think I will submit a bug on Sourceforge
asking that flat namespace be disabled.
Manoj Plakal wrote to support at wingide.com:
> I got a few responses to my post to
> c.l.py and pythonmac-sig about the
> OS X import bug.
> OS X 10.1 has two kinds of linking
> of loadable modules: flat and
> two-level. Two-level is what
> is done on Linux (RTLD_LOCAL with
> RTLD_GLOBAL not specified) as
> well as Windows. However, building
> Python releases on OS X enables
> the flat namespace option.
> Looks like Python needs to be set
> up with the flat namespace option
> disabled (when you build your
> extension modules). Also, see this
> -------- Original Message --------
> Subject: Re: [Pythonmac-SIG] OS X import bug?
> Date: Fri, 25 Jan 2002 14:46:37 -0500
> From: Marcelinus Prastawa <prastawa at cs.unc.edu>
> To: Manoj Plakal <terabaap at yumpee.org>
> It worked on my machine.
> OS X's dynamic loader is a bit different. The two modules share the same
> symbols. If they are built as flat namespace binaries, Python would fail
> to build the second one.
> You should remove the "-flat_namespace -undefined suppress" options... If
> you are using Mach-O (UNIX) Python you could edit the options in
> On Thursday, January 24, 2002, at 01:58 , Manoj Plakal wrote:
> > Hello,
> > I've just noticed a weird problem with importing modules
> > on MacOS X 10.1 and Python 2.2.
> > Say I have two modules foo and bar, both of which
> > are built with a common file baz.c with some variables
> > defined in it.
> > I make a setup.py which specifies that module foo
> > is built from foomodule.c and baz.c, and module bar
> > is built from barmodule.c and baz.c.
> > On Red Hat Linux 7.2 with Python 2.2, this builds fine and I
> > can import both foo and bar into the same interpreter session.
> > On OS X 10.1 with Python 2.2, this builds fine but I can
> > only import *ONE* of foo or bar into the same interpreter
> > session. E.g., if I import foo first and then bar,
> > Python craps out saying "Failure linking new module".
> > Similary for bar first and then foo.
> > This is both with a version built from the 2.2 source
> > release, as well as a binary version from Fink
> > (fink.sourceforge.net).
> > I've attached the files which can be used to reproduce
> > this: setup.py, foomodule.c, barmodule.c, baz.c. In
> > case the attachments don't work, you can grab them
> > off the web: http://yumpee.org/python/setup.py
> > http://yumpee.org/python/foomodule.c
> > http://yumpee.org/python/barmodule.c
> > http://yumpee.org/python/baz.c
> > Is this a bug? Undefined behavior? Feature?
> > Is it a fluke that it works on Linux?
> > If someone else with OS X can reproduce this error,
> > (and people on other OSes can confirm that
> > it's working), that would be great ...
> > Manoj
More information about the Python-list