[Python-Dev] python package

Gordon McMillan gmcm@hypernet.com
Sun, 14 Jul 2002 13:24:48 -0400


On 14 Jul 2002 at 16:32, M.-A. Lemburg wrote:

> Gordon McMillan wrote:

[various cute hacks]

> > None of these will freeze successfully.
> 
> Hmm, then how do you freeze _xmlplue ?

Most people whine publicly until someone comes
up with a workaround. Installer has a way of hooking
modules & packages that play games like that, but
if you're using tools/freeze, you'll probably be told 
to overlay xml with _xmlplus.

If the package uses lots of nasty tricks (eg,
pyopengl), the answer is "you don't".

> > Two of them appear to rely on an implementation
> > detail - that __path__ (only defined for
> > imp.PKG_DIRECTORY's) will be followed even in
> > a plain module.
> 
> AFAIK, that's not an implementation detail, but a
> documented way of finding out whether a module is a
> package or not.

Correct. But stuffing a __path__ attribute into
a module does *not* make the module a package.

'''Whenever a submodule of a package is loaded, Python makes sure that the package itself is loaded first, loading its __init__.py file if necessary.'''

and

'''Once loaded, the difference between a package and a module is minimal.'''
 
> But it works (tm) :-)

For a sufficiently short-sighted definition of "work".

-- Gordon
http://www.mcmillan-inc.com/