<!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.0 Transitional//EN">
<link rel=
"STYLESHEET" href=
"lib.css" type='text/css'
/>
<link rel=
"SHORTCUT ICON" href=
"../icons/pyfav.png" type=
"image/png" />
<link rel='start' href='../index.html' title='Python Documentation Index'
/>
<link rel=
"first" href=
"lib.html" title='Python Library Reference'
/>
<link rel='contents' href='contents.html'
title=
"Contents" />
<link rel='index' href='genindex.html' title='Index'
/>
<link rel='last' href='about.html' title='About this document...'
/>
<link rel='help' href='about.html' title='About this document...'
/>
<link rel=
"next" href=
"module-dis.html" />
<link rel=
"prev" href=
"module-pycompile.html" />
<link rel=
"parent" href=
"language.html" />
<link rel=
"next" href=
"module-dis.html" />
<meta name='aesop' content='information'
/>
<title>18.9 compileall -- Byte-compile Python libraries
</title>
<div id='top-navigation-panel' xml:id='top-navigation-panel'
>
<table align=
"center" width=
"100%" cellpadding=
"0" cellspacing=
"2">
<td class='online-navigation'
><a rel=
"prev" title=
"18.8 py_compile "
href=
"module-pycompile.html"><img src='../icons/previous.png'
border='
0' height='
32' alt='Previous Page' width='
32'
/></A></td>
<td class='online-navigation'
><a rel=
"parent" title=
"18. Python Language Services"
href=
"language.html"><img src='../icons/up.png'
border='
0' height='
32' alt='Up One Level' width='
32'
/></A></td>
<td class='online-navigation'
><a rel=
"next" title=
"18.10 dis "
href=
"module-dis.html"><img src='../icons/next.png'
border='
0' height='
32' alt='Next Page' width='
32'
/></A></td>
<td align=
"center" width=
"100%">Python Library Reference
</td>
<td class='online-navigation'
><a rel=
"contents" title=
"Table of Contents"
href=
"contents.html"><img src='../icons/contents.png'
border='
0' height='
32' alt='Contents' width='
32'
/></A></td>
<td class='online-navigation'
><a href=
"modindex.html" title=
"Module Index"><img src='../icons/modules.png'
border='
0' height='
32' alt='Module Index' width='
32'
/></a></td>
<td class='online-navigation'
><a rel=
"index" title=
"Index"
href=
"genindex.html"><img src='../icons/index.png'
border='
0' height='
32' alt='Index' width='
32'
/></A></td>
<div class='online-navigation'
>
<b class=
"navlabel">Previous:
</b>
<a class=
"sectref" rel=
"prev" href=
"module-pycompile.html">18.8 py_compile
</A>
<b class=
"navlabel">Up:
</b>
<a class=
"sectref" rel=
"parent" href=
"language.html">18. Python Language Services
</A>
<b class=
"navlabel">Next:
</b>
<a class=
"sectref" rel=
"next" href=
"module-dis.html">18.10 dis
</A>
<!--End of Navigation Panel-->
<H1><A NAME=
"SECTION0020900000000000000000">
18.9 <tt class=
"module">compileall
</tt> --
Byte-compile Python libraries
</A>
<A NAME=
"module-compileall"></A>
This module provides some utility functions to support installing
Python libraries. These functions compile Python source files in a
directory tree, allowing users without permission to write to the
libraries to take advantage of cached byte-code files.
The source file for this module may also be used as a script to
compile Python sources in directories named on the command line or in
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
4998' xml:id='l2h-
4998'
class=
"function">compile_dir
</tt></b>(
</nobr></td>
<td><var>dir
</var><big>[
</big><var>, maxlevels
</var><big>[
</big><var>,
ddir
</var><big>[
</big><var>, force
</var><big>[
</big><var>,
rx
</var><big>[
</big><var>, quiet
</var><big>]
</big><var></var><big>]
</big><var></var><big>]
</big><var></var><big>]
</big><var></var><big>]
</big><var></var>)
</td></tr></table></dt>
Recursively descend the directory tree named by
<var>dir
</var>, compiling
all
<span class=
"file">.py
</span> files along the way. The
<var>maxlevels
</var> parameter
is used to limit the depth of the recursion; it defaults to
<code>10</code>. If
<var>ddir
</var> is given, it is used as the base path from
which the filenames used in error messages will be generated. If
<var>force
</var> is true, modules are re-compiled even if the timestamps
If
<var>rx
</var> is given, it specifies a regular expression of file
names to exclude from the search; that expression is searched for in
If
<var>quiet
</var> is true, nothing is printed to the standard output
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
4999' xml:id='l2h-
4999'
class=
"function">compile_path
</tt></b>(
</nobr></td>
<td><var></var><big>[
</big><var>skip_curdir
</var><big>[
</big><var>,
maxlevels
</var><big>[
</big><var>, force
</var><big>]
</big><var></var><big>]
</big><var></var><big>]
</big><var></var>)
</td></tr></table></dt>
Byte-compile all the
<span class=
"file">.py
</span> files found along
<code>sys.path
</code>.
If
<var>skip_curdir
</var> is true (the default), the current directory is
not included in the search. The
<var>maxlevels
</var> and
<var>force
</var> parameters default to
<code>0</code> and are passed to the
<tt class=
"function">compile_dir()
</tt> function.
<p class=
"heading">See Also:
</p>
<dl compact=
"compact" class=
"seemodule">
<dt>Module
<b><tt class=
"module"><a href=
"module-pycompile.html">py_compile
</a></tt>:
</b>
<dd>Byte-compile a single source file.
<div class='online-navigation'
>
<table align=
"center" width=
"100%" cellpadding=
"0" cellspacing=
"2">
<td class='online-navigation'
><a rel=
"prev" title=
"18.8 py_compile "
href=
"module-pycompile.html"><img src='../icons/previous.png'
border='
0' height='
32' alt='Previous Page' width='
32'
/></A></td>
<td class='online-navigation'
><a rel=
"parent" title=
"18. Python Language Services"
href=
"language.html"><img src='../icons/up.png'
border='
0' height='
32' alt='Up One Level' width='
32'
/></A></td>
<td class='online-navigation'
><a rel=
"next" title=
"18.10 dis "
href=
"module-dis.html"><img src='../icons/next.png'
border='
0' height='
32' alt='Next Page' width='
32'
/></A></td>
<td align=
"center" width=
"100%">Python Library Reference
</td>
<td class='online-navigation'
><a rel=
"contents" title=
"Table of Contents"
href=
"contents.html"><img src='../icons/contents.png'
border='
0' height='
32' alt='Contents' width='
32'
/></A></td>
<td class='online-navigation'
><a href=
"modindex.html" title=
"Module Index"><img src='../icons/modules.png'
border='
0' height='
32' alt='Module Index' width='
32'
/></a></td>
<td class='online-navigation'
><a rel=
"index" title=
"Index"
href=
"genindex.html"><img src='../icons/index.png'
border='
0' height='
32' alt='Index' width='
32'
/></A></td>
<div class='online-navigation'
>
<b class=
"navlabel">Previous:
</b>
<a class=
"sectref" rel=
"prev" href=
"module-pycompile.html">18.8 py_compile
</A>
<b class=
"navlabel">Up:
</b>
<a class=
"sectref" rel=
"parent" href=
"language.html">18. Python Language Services
</A>
<b class=
"navlabel">Next:
</b>
<a class=
"sectref" rel=
"next" href=
"module-dis.html">18.10 dis
</A>
<span class=
"release-info">Release
2.4.2, documentation updated on
28 September
2005.
</span>
<!--End of Navigation Panel-->
See
<i><a href=
"about.html">About this document...
</a></i> for information on suggesting changes.