.pyo's without .pyc's?

Randall Hopper aa8vb at yahoo.com
Thu May 27 07:31:59 EDT 1999


--- "M.-A. Lemburg" <mal at lemburg.com> wrote:
> Randall Hopper wrote:
> > 
> > I'm trying to cook a minimalist Python install,
> > and I find that python -O won't run without .pyc's
> > in-place, even when there are pyo's.
>
> Looks like you have setup PYTHONPATH to point to
> some old extensions.py file (the compiled versions >
> seemed to be ok).

I'd reset PYTHONPATH.

> Try "python -vv" to have a look at the path scanning
> Python does on startup.

Thanks, that turned out to be very useful.  Here's a
unified diff of what's different between a "python -O"
startup with and without .pyc's.  In this specific
case, it appears it's not even going to look for a
.pyo for the exceptions module:

--- OUT.normal  Thu May 27 07:20:43 1999
+++ OUT.nopyc   Thu May 27 07:20:59 1999
@@ -2,7 +2,21 @@
 # trying .../lib/python1.5/exceptionsmodule.so
 # trying .../lib/python1.5/exceptions.py
 # trying .../lib/python1.5/exceptions.pyc
-import exceptions # precompiled from 
 .../lib/python1.5/exceptions.pyc
+# trying
.../lib/python1.5/plat-irix646-n32/exceptions.so
+# trying
.../lib/python1.5/plat-irix646-n32/exceptionsmodule.so
+# trying
.../lib/python1.5/plat-irix646-n32/exceptions.py
+# trying
.../lib/python1.5/plat-irix646-n32/exceptions.pyc
+# trying .../lib/python1.5/lib-tk/exceptions.so
+# trying .../lib/python1.5/lib-tk/exceptionsmodule.so
+# trying .../lib/python1.5/lib-tk/exceptions.py
+# trying .../lib/python1.5/lib-tk/exceptions.pyc
+# trying
.../ARCH/IRIX/lib/python1.5/lib-dynload/exceptions.so
+# trying
.../ARCH/IRIX/lib/python1.5/lib-dynload/exceptionsmodule.so
+# trying
.../ARCH/IRIX/lib/python1.5/lib-dynload/exceptions.py
+# trying
.../ARCH/IRIX/lib/python1.5/lib-dynload/exceptions.pyc
+'import exceptions' failed; traceback:
+ImportError: No module named exceptions
+Warning!  Falling back to string-based exceptions


> 
> Running Python with .pyo files only works just fine
> if you remember to always use the -O flag on the
> command line.

I was hoping for that, but that's not what I'm seeing.

> For minimalist Python installs, you could also check
> out the mxCGIPython project:
> 
>
http://starship.skyport.net/~lemburg/mxCGIPython.html
>
> It's Python wrapped into a single file (with the
> standard lib compiled with -O BTW).

Will do.  That sounds useful.

Thanks,

Randall
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com





More information about the Python-list mailing list