2 :mod:`compileall` --- Byte-compile Python libraries
3 ===================================================
6 :synopsis: Tools for byte-compiling all Python source files in a directory tree.
9 This module provides some utility functions to support installing Python
10 libraries. These functions compile Python source files in a directory tree,
11 allowing users without permission to write to the libraries to take advantage of
12 cached byte-code files.
14 The source file for this module may also be used as a script to compile Python
15 sources in directories named on the command line or in ``sys.path``.
18 .. function:: compile_dir(dir[, maxlevels[, ddir[, force[, rx[, quiet]]]]])
20 Recursively descend the directory tree named by *dir*, compiling all :file:`.py`
21 files along the way. The *maxlevels* parameter is used to limit the depth of
22 the recursion; it defaults to ``10``. If *ddir* is given, it is used as the
23 base path from which the filenames used in error messages will be generated.
24 If *force* is true, modules are re-compiled even if the timestamps are up to
27 If *rx* is given, it specifies a regular expression of file names to exclude
28 from the search; that expression is searched for in the full path.
30 If *quiet* is true, nothing is printed to the standard output in normal
34 .. function:: compile_path([skip_curdir[, maxlevels[, force]]])
36 Byte-compile all the :file:`.py` files found along ``sys.path``. If
37 *skip_curdir* is true (the default), the current directory is not included in
38 the search. The *maxlevels* and *force* parameters default to ``0`` and are
39 passed to the :func:`compile_dir` function.
41 To force a recompile of all the :file:`.py` files in the :file:`Lib/`
42 subdirectory and all its subdirectories::
46 compileall.compile_dir('Lib/', force=True)
48 # Perform same compilation, excluding files in .svn directories.
50 compileall.compile_dir('Lib/', rx=re.compile('/[.]svn'), force=True)
55 Module :mod:`py_compile`
56 Byte-compile a single source file.