Problem

Using the PathModule from Jason Jorendorff, modulefinder.py, which is called by Py2Exe, gets into an endless recursion.

It tries to resolve os.path, gets to  os.os.path , further to  os.os.path  and breaks somewhere at os.os.os.os.os.os.os.os.os.os.os.os.os.os.os.os.os.os.os.os.os.os.os.os.os.os.os.path  at which point you get a RuntimeError: maximum recursion depth exceeded.

(Maybe it would be a test to use StackLess Python, it would run forever or until the maximum string length of pyhton is reached. But maximum string length in Python is only limited by memory, memory is limited by address-space ... )

But apart from joking: it is IMPOSSIBLE to generate an exe with the modern 0.5 Version of Py2Exe when path.py is installed.

Workaround

Just rename

site-packages/path.py

to

site-packages/jpath.py

and make sure also to toggle your imports to

   1 import jpath

and to delete path.pyc and path.pyo from your site-packages directory.

20041013HAM

Possible Bugfix

This patch to Lib/modulefinder.py should fix the problem, it would be nice if people would try it out, and report back here:

   1 Index: modulefinder.py
   2 ===================================================================
   3 RCS file: /cvsroot/python/python/dist/src/Lib/modulefinder.py,v
   4 retrieving revision 1.7.6.1
   5 diff -c -r1.7.6.1 modulefinder.py
   6 *** modulefinder.py     14 Nov 2003 10:23:03 -0000      1.7.6.1
   7 --- modulefinder.py     30 Mar 2004 18:54:01 -0000
   8 ***************
   9 *** 245,250 ****
  10 --- 245,253 ----
  11           if self.badmodules.has_key(fqname):
  12               self.msgout(3, "import_module -> None")
  13               return None
  14 +         if parent and parent.__path__ is None:
  15 +             self.msgout(3, "import_module -> None")
  16 +             return None
  17           try:
  18               fp, pathname, stuff = self.find_module(partname,
  19                                                      parent and parent.__path__, parent)

Works for me on a simple test -- Paul Moore
Works for me -- Maxime Vernier
Works for me too -- Matteo Bertini

PathModul (last edited 2008-07-08 11:27:43 by localhost)