[Python-Dev] python package

M.-A. Lemburg mal@lemburg.com
Sun, 14 Jul 2002 22:44:26 +0200


Gordon McMillan wrote:
>>You haven't commented on the sys.modules trick yet.
>>This one doesn't even use the __path__ hackery :-)
>>
>>DateTime.py:
>>import sys
>>import mx.DateTime
>>sys.modules[__name__] = mx.DateTime
> 
> [...]
> 
>>See: it's the same module :-)
> 
> 
> Anytime x != sys.modules[x].__name__,
> someone, sometime will suffer.
> 
> Installer and (I believe) py2exe have hooks
> so that this gets analyzed properly. The hook
> is keyed by "DateTime".
> 
> If you really find it intolerable to stick your
> users with making a one line change in their
> code, you might consider contributing hooks 
> to Installer (or patches to py2exe).

I don't. I'm just using my package series as
example of how moving a set of top-level modules/packages
to a single package can be accomplished. That's
all.

I told my users to upgrade their applications
from 1.x to 2.0 by switching from 'import DateTime'
to 'from mx import DateTime' when I made the move
and indeed, only one user complained -- which is
why I provided him with a backwards compatiblity
package along the lines of what I've posted here.
He only needed it to be able to read back pickled
data, BTW.

> Particularly for your non-free packages, since
> I'm not going to download those and reverse-engineer 
> them.

Hmm, I don't understand this comment.

> Or perhaps you could do like Pmw, and
> include a "bundle" script.

py2exe works just fine with the mx stuff. I suppose
your installer does too.

-- 
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
_______________________________________________________________________
eGenix.com -- Makers of the Python mx Extensions: mxDateTime,mxODBC,...
Python Consulting:                               http://www.egenix.com/
Python Software:                    http://www.egenix.com/files/python/