[Python-Dev] Freeze hacks

Thomas Heller thomas.heller@ion-tof.com
Wed, 18 Jul 2001 17:32:37 +0200

From: "Martin von Loewis" <loewis@informatik.hu-berlin.de>
> A number of modules in the standard library make use of dynamic
> imports, or import modules through C code. In either case, no import
> statement can be found.
> Unfortunately, this means that tools like freeze or py2exe cannot
> detect that those modules are used, so the frozen applications will
> then fail at runtime. To make this work, I suggest to add explicit
> import statements, which are put into a conditional 'if 0:'.
Very good idea IMO, but 'if 0:' is optimized away.
This one works:

if _FAKE:
     import whatever