PageRenderTime 21ms CodeModel.GetById 17ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/Doc/library/compileall.rst

http://unladen-swallow.googlecode.com/
ReStructuredText | 62 lines | 41 code | 21 blank | 0 comment | 0 complexity | 7e6a23cffba4f9c08e5fd3e8b08cfb58 MD5 | raw file
 1
 2:mod:`compileall` --- Byte-compile Python libraries
 3===================================================
 4
 5.. module:: compileall
 6   :synopsis: Tools for byte-compiling all Python source files in a directory tree.
 7
 8
 9This module provides some utility functions to support installing Python
10libraries.  These functions compile Python source files in a directory tree,
11allowing users without permission to write to the libraries to take advantage of
12cached byte-code files.
13
14This module may also be used as a script (using the :option:`-m` Python flag) to
15compile Python sources.  Directories to recursively traverse (passing
16:option:`-l` stops the recursive behavior) for sources are listed on the command
17line.  If no arguments are given, the invocation is equivalent to ``-l
18sys.path``.  Printing lists of the files compiled can be disabled with the
19:option:`-q` flag.  In addition, the :option:`-x` option takes a regular
20expression argument.  All files that match the expression will be skipped.
21
22
23.. function:: compile_dir(dir[, maxlevels[, ddir[, force[,  rx[, quiet]]]]])
24
25   Recursively descend the directory tree named by *dir*, compiling all :file:`.py`
26   files along the way.  The *maxlevels* parameter is used to limit the depth of
27   the recursion; it defaults to ``10``.  If *ddir* is given, it is used as the
28   base path from  which the filenames used in error messages will be generated.
29   If *force* is true, modules are re-compiled even if the timestamps are up to
30   date.
31
32   If *rx* is given, it specifies a regular expression of file names to exclude
33   from the search; that expression is searched for in the full path.
34
35   If *quiet* is true, nothing is printed to the standard output in normal
36   operation.
37
38
39.. function:: compile_path([skip_curdir[, maxlevels[, force]]])
40
41   Byte-compile all the :file:`.py` files found along ``sys.path``. If
42   *skip_curdir* is true (the default), the current directory is not included in
43   the search.  The *maxlevels* and *force* parameters default to ``0`` and are
44   passed to the :func:`compile_dir` function.
45
46To force a recompile of all the :file:`.py` files in the :file:`Lib/`
47subdirectory and all its subdirectories::
48
49   import compileall
50
51   compileall.compile_dir('Lib/', force=True)
52
53   # Perform same compilation, excluding files in .svn directories.
54   import re
55   compileall.compile_dir('Lib/', rx=re.compile('/[.]svn'), force=True)
56
57
58.. seealso::
59
60   Module :mod:`py_compile`
61      Byte-compile a single source file.
62