[PEAK] Packaging peak apps

Stephen Haberman stephenh at chase3000.com
Thu Sep 16 17:31:32 EDT 2004

> Hi Stephen.  I don't understand why 'path' has to be non-null.  Not only
that, but if it *is* null and the module has no __path__, your patch is
still going to pass in a null path.  So I'm confused.  How did you discover
the problem?

Good point. I discovered the problem by originally not having that path code
in the subname == NULL case and having it fail on a line somewhere in

Yeah, this line (1154):

	if (path == NULL || !PyList_Check(path)) {
				"sys.path must be a list of directory
		return NULL;

I was getting an "ImportError: sys.path must be..." exception with my
original patch. Scratching my head and looking at what the subname != NULL
case did with its path variable, I tried doing the same in the subname ==
NULL case, assigning path to m.__path__, and it magically worked.


> Similarly, I'm confused as to why 'mod=reload(mod)' would be necessary
now, but wasn't before.  There have been no changes that I see in
test_importhooks that would cause that.  What was your testing methodology
for this?

My methodology was that my original patch had just 'reload(mod)' and, though
it worked great before, now it was failing, saying that the new function,
get_foo, could not be found, and, here's where my methodology gets fancy, I
guessed that 'mod=reload(mod)' would work, and it did.


I had a feeling both of these cases were not right, but frankly the unit
tests passed, and I have very little knowledge of this whole PEP 302 thing,
so I got lazy and thought it was good enough.

> Together, maybe we can get the base issue fixed before 2.4 beta, which
> would allow people to package PEAK apps using py2exe and Python 2.4 (or
> 2.3.5, if there is one).

Sounds like a great idea, but as you can see I already don't really have a
clue what I'm doing with the code and just happened to get lucky and find
the loader not being passed when I was first looking into this problem
months ago.

Also, I'm no longer doing any apps with PEAK (unfortunately), so I can't
really spend time on it.

So, with those two things in mind, I think my patches will just have to be a
starting point for someone who really knows what they're doing to finish and
fully implement them correctly.

- Stephen

More information about the PEAK mailing list