📄 module-compileall.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>17.9 compileall -- Byte-compile Python libraries</title>
<META NAME="description" CONTENT="17.9 compileall -- Byte-compile Python libraries">
<META NAME="keywords" CONTENT="lib">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="STYLESHEET" href="lib.css" tppabs="http://www.python.org/doc/current/lib/lib.css">
<LINK REL="next" href="module-dis.html" tppabs="http://www.python.org/doc/current/lib/module-dis.html">
<LINK REL="previous" href="module-pycompile.html" tppabs="http://www.python.org/doc/current/lib/module-pycompile.html">
<LINK REL="up" href="language.html" tppabs="http://www.python.org/doc/current/lib/language.html">
<LINK REL="next" href="module-dis.html" tppabs="http://www.python.org/doc/current/lib/module-dis.html">
</head>
<body>
<DIV CLASS="navigation"><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="module-pycompile.html" tppabs="http://www.python.org/doc/current/lib/module-pycompile.html"><img src="previous.gif" tppabs="http://www.python.org/doc/current/icons/previous.gif" border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A href="language.html" tppabs="http://www.python.org/doc/current/lib/language.html"><img src="up.gif" tppabs="http://www.python.org/doc/current/icons/up.gif" border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A href="module-dis.html" tppabs="http://www.python.org/doc/current/lib/module-dis.html"><img src="next.gif" tppabs="http://www.python.org/doc/current/icons/next.gif" border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td><A href="contents.html" tppabs="http://www.python.org/doc/current/lib/contents.html"><img src="contents.gif" tppabs="http://www.python.org/doc/current/icons/contents.gif" border="0" height="32"
alt="Contents" width="32"></A></td>
<td><a href="modindex.html" tppabs="http://www.python.org/doc/current/lib/modindex.html" title="Module Index"><img src="modules.gif" tppabs="http://www.python.org/doc/current/icons/modules.gif" border="0" height="32"
alt="Module Index" width="32"></a></td>
<td><A href="genindex.html" tppabs="http://www.python.org/doc/current/lib/genindex.html"><img src="index.gif" tppabs="http://www.python.org/doc/current/icons/index.gif" border="0" height="32"
alt="Index" width="32"></A></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="module-pycompile.html" tppabs="http://www.python.org/doc/current/lib/module-pycompile.html">17.8 py_compile </A>
<b class="navlabel">Up:</b> <a class="sectref" href="language.html" tppabs="http://www.python.org/doc/current/lib/language.html">17. Python Language Services</A>
<b class="navlabel">Next:</b> <a class="sectref" href="module-dis.html" tppabs="http://www.python.org/doc/current/lib/module-dis.html">17.10 dis </A>
<br><hr></DIV>
<!--End of Navigation Panel-->
<H1><A NAME="SECTION0019900000000000000000">
17.9 <tt class="module">compileall</tt> --
Byte-compile Python libraries</A>
</H1>
<P>
<P>
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.
<P>
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
<code>sys.path</code>.
<P>
<dl><dt><b><a name='l2h-3062'><tt class='function'>compile_dir</tt></a></b> (<var>dir</var><big>[</big><var>, maxlevels</var><big>[</big><var>,
ddir</var><big>[</big><var>, force</var><big>]</big><big>]</big><big>]</big>)
<dd>
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
are up to date.
</dl>
<P>
<dl><dt><b><a name='l2h-3063'><tt class='function'>compile_path</tt></a></b> (<big>[</big><var>skip_curdir</var><big>[</big><var>,
maxlevels</var><big>[</big><var>, force</var><big>]</big><big>]</big><big>]</big>)
<dd>
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.
</dl>
<P>
<div class='seealso'>
<p class='heading'><b>See Also:</b></p>
<dl compact class="seemodule">
<dt>Module <b><tt class='module'><a href="module-pycompile.html" tppabs="http://www.python.org/doc/current/lib/module-pycompile.html">py_compile</a></tt>:</b>
<dd>Byte-compile a single source file.
</dl>
</div>
<DIV CLASS="navigation"><p><hr><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="module-pycompile.html" tppabs="http://www.python.org/doc/current/lib/module-pycompile.html"><img src="previous.gif" tppabs="http://www.python.org/doc/current/icons/previous.gif" border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A href="language.html" tppabs="http://www.python.org/doc/current/lib/language.html"><img src="up.gif" tppabs="http://www.python.org/doc/current/icons/up.gif" border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A href="module-dis.html" tppabs="http://www.python.org/doc/current/lib/module-dis.html"><img src="next.gif" tppabs="http://www.python.org/doc/current/icons/next.gif" border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td><A href="contents.html" tppabs="http://www.python.org/doc/current/lib/contents.html"><img src="contents.gif" tppabs="http://www.python.org/doc/current/icons/contents.gif" border="0" height="32"
alt="Contents" width="32"></A></td>
<td><a href="modindex.html" tppabs="http://www.python.org/doc/current/lib/modindex.html" title="Module Index"><img src="modules.gif" tppabs="http://www.python.org/doc/current/icons/modules.gif" border="0" height="32"
alt="Module Index" width="32"></a></td>
<td><A href="genindex.html" tppabs="http://www.python.org/doc/current/lib/genindex.html"><img src="index.gif" tppabs="http://www.python.org/doc/current/icons/index.gif" border="0" height="32"
alt="Index" width="32"></A></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="module-pycompile.html" tppabs="http://www.python.org/doc/current/lib/module-pycompile.html">17.8 py_compile </A>
<b class="navlabel">Up:</b> <a class="sectref" href="language.html" tppabs="http://www.python.org/doc/current/lib/language.html">17. Python Language Services</A>
<b class="navlabel">Next:</b> <a class="sectref" href="module-dis.html" tppabs="http://www.python.org/doc/current/lib/module-dis.html">17.10 dis </A>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
<hr>See <i><a href="about.html" tppabs="http://www.python.org/doc/current/lib/about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -