How to compile a python script to *.pyo
MFranklin1 at gatwick.westerngeco.slb.com
Thu Apr 3 21:24:07 CEST 2003
danny at iamlearning.com wrote:
> I'm new on this, please bear with we.
> Let's say I have this script:
> #!/usr/bin/env python
> x = 'Hello Python'
> print x,
> How can I compile this script to *.pyo?
I'll ignore the why's and wherefore's and give you what I consider a
Python Library Documentation: module compileall
compileall - Module/script to "compile" all .py files to .pyc (or
When called as a script with arguments, this compiles the directories
given as arguments recursively; the -l option prevents it from
recursing into directories.
Without arguments, if compiles all modules on sys.path, without
recursing into subdirectories. (Even though it should do so for
packages -- for now, you'll have to deal with packages separately.)
See module py_compile for details of the actual byte-compilation.
compile_dir(dir, maxlevels=10, ddir=None, force=0, rx=None)
Byte-compile all modules in the given directory tree.
..... snip .....
I use this for yes you've guessed it compiling my applications, on the fly
as they are installed.
More information about the Python-list