[Pythonmac-SIG] python package module name collision

Greg Welch welch@cs.unc.edu
Fri, 12 Jul 2002 11:20:14 -0400


I am using Python 2.2.1-6 (from Fink) on OS X 10.1.5. A colleague (Gary
Bishop) and I have found what seems to be a bug in that version of Python on
the Mac. I have verified it in the stock tgz release of 2.2.1. The problem
does not seem to occur w/ the same Python under Windows (Cygwin).

I have made a tiny tgz archive with code that illustrates the problem. The
file is at

    http://mac-welch.cs.unc.edu/~welch/tmp/samename.tgz

Just unpack, "cd samename," and "sudo python setup.py install."

The problem occurs when (it seems) if you have two *different* extension
packages ("Package_1" and "Package_2" in my example) that use different
shared library modules that have the *same* name ("samename.so" in my
example).

If you import "Package_1" Python loads *its* respective "samename" module
just fine. However if you then load "Package_2" Python does *not* load *its*
"samename" module. It apparently thinks it has already has "samename"
leftover from the previous load of "Package_1".

FYI, I discovered the problem when trying to build PyOpenGL, which I think I
successfully did, working from the PyOpenGL part of Bob Ippolito's
"ultramega" source package (http://redivi.com/~bob/). Unfortunately the
PyOpenGL code (we discovered) has shared libraries called "__init___.so" in
*both* the OpenGL.GL and OpenGL.GLU

Here is example session where I import Package_1, then Package_2, then
restart python and import in the opposite order. In each case you can see
second import runs the same init module.

[mac-welch] welch% python
Python 2.2.1 (#1, 07/10/02, 10:09:28)
[GCC Apple cpp-precomp 6.12] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Welcome to Lazy Python.  Type "help LazyPython" for help.
>>> import Package_1
Init samename from Package_1
>>> import Package_2
Init samename from Package_1
>>> 
[mac-welch:lib/python2.2/site-packages] welch% python
Python 2.2.1 (#1, 07/10/02, 10:09:28)
[GCC Apple cpp-precomp 6.12] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Welcome to Lazy Python.  Type "help LazyPython" for help.
>>> import Package_2
Init samename from Package_2
>>> import Package_1
Init samename from Package_2
>>> 
[mac-welch] welch% 


   ________

Gregory F. Welch
Research Associate Professor
Department of Computer Science
University of North Carolina at Chapel Hill
http://www.cs.unc.edu/~welch
welch@cs.unc.edu
919-962-1819