Mercurial > cpython-lru_cache-weakref
annotate Doc/lib/libpycompile.tex @ 27998:e27f58a50737 legacy-trunk
SF bug #690377: Dud footnote reference in distutils docs
| author | Raymond Hettinger <python@rcn.com> |
|---|---|
| date | Fri, 21 Feb 2003 02:47:09 +0000 |
| parents | 16a876746285 |
| children | 64c83e0f683e |
| rev | line source |
|---|---|
|
12223
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
8936
diff
changeset
|
1 \section{\module{py_compile} --- |
|
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
8936
diff
changeset
|
2 Compile Python source files} |
|
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
8936
diff
changeset
|
3 |
|
8936
5b73d5babc78
Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
4 % Documentation based on module docstrings, by Fred L. Drake, Jr. |
|
5b73d5babc78
Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
5 % <fdrake@acm.org> |
|
5b73d5babc78
Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
6 |
|
5b73d5babc78
Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
7 \declaremodule[pycompile]{standard}{py_compile} |
|
5b73d5babc78
Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
8 |
|
5b73d5babc78
Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
9 \modulesynopsis{Compile Python source files to byte-code files.} |
|
5b73d5babc78
Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
10 |
|
5b73d5babc78
Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
11 |
|
5b73d5babc78
Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
12 \indexii{file}{byte-code} |
|
24938
e9500709d49c
Added a main() function and support to run this module as a script.
Fred Drake <fdrake@acm.org>
parents:
12223
diff
changeset
|
13 The \module{py_compile} module provides a function to generate a |
|
e9500709d49c
Added a main() function and support to run this module as a script.
Fred Drake <fdrake@acm.org>
parents:
12223
diff
changeset
|
14 byte-code file from a source file, and another function used when the |
|
e9500709d49c
Added a main() function and support to run this module as a script.
Fred Drake <fdrake@acm.org>
parents:
12223
diff
changeset
|
15 module source file is invoked as a script. |
|
8936
5b73d5babc78
Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
16 |
|
5b73d5babc78
Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
17 Though not often needed, this function can be useful when installing |
|
5b73d5babc78
Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
18 modules for shared use, especially if some of the users may not have |
|
5b73d5babc78
Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
19 permission to write the byte-code cache files in the directory |
|
5b73d5babc78
Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
20 containing the source code. |
|
5b73d5babc78
Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
21 |
|
27250
16a876746285
Patch #661719: Expose compilation errors as exceptions on request.
Martin v. Löwis <martin@v.loewis.de>
parents:
24938
diff
changeset
|
22 \begin{excdesc}{PyCompileError} |
|
16a876746285
Patch #661719: Expose compilation errors as exceptions on request.
Martin v. Löwis <martin@v.loewis.de>
parents:
24938
diff
changeset
|
23 Exception raised when an error occurs while attempting to compile the file. |
|
16a876746285
Patch #661719: Expose compilation errors as exceptions on request.
Martin v. Löwis <martin@v.loewis.de>
parents:
24938
diff
changeset
|
24 \end{excdesc} |
|
8936
5b73d5babc78
Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
25 |
|
27250
16a876746285
Patch #661719: Expose compilation errors as exceptions on request.
Martin v. Löwis <martin@v.loewis.de>
parents:
24938
diff
changeset
|
26 \begin{funcdesc}{compile}{file\optional{, cfile\optional{, dfile\optional{, doraise}}}} |
|
8936
5b73d5babc78
Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
27 Compile a source file to byte-code and write out the byte-code cache |
|
5b73d5babc78
Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
28 file. The source code is loaded from the file name \var{file}. The |
|
5b73d5babc78
Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
29 byte-code is written to \var{cfile}, which defaults to \var{file} |
|
5b73d5babc78
Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
30 \code{+} \code{'c'} (\code{'o'} if optimization is enabled in the |
|
5b73d5babc78
Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
31 current interpreter). If \var{dfile} is specified, it is used as |
|
5b73d5babc78
Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
32 the name of the source file in error messages instead of \var{file}. |
|
27250
16a876746285
Patch #661719: Expose compilation errors as exceptions on request.
Martin v. Löwis <martin@v.loewis.de>
parents:
24938
diff
changeset
|
33 If \var{doraise} = True, a PyCompileError is raised when an error is |
|
16a876746285
Patch #661719: Expose compilation errors as exceptions on request.
Martin v. Löwis <martin@v.loewis.de>
parents:
24938
diff
changeset
|
34 encountered while compiling \var{file}. If \var{doraise} = False (the default), |
|
16a876746285
Patch #661719: Expose compilation errors as exceptions on request.
Martin v. Löwis <martin@v.loewis.de>
parents:
24938
diff
changeset
|
35 an error string is written to sys.stderr, but no exception is raised. |
|
8936
5b73d5babc78
Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
36 \end{funcdesc} |
|
5b73d5babc78
Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
37 |
|
24938
e9500709d49c
Added a main() function and support to run this module as a script.
Fred Drake <fdrake@acm.org>
parents:
12223
diff
changeset
|
38 \begin{funcdesc}{main}{\optional{args}} |
|
e9500709d49c
Added a main() function and support to run this module as a script.
Fred Drake <fdrake@acm.org>
parents:
12223
diff
changeset
|
39 Compile several source files. The files named in \var{args} (or on |
|
e9500709d49c
Added a main() function and support to run this module as a script.
Fred Drake <fdrake@acm.org>
parents:
12223
diff
changeset
|
40 the command line, if \var{args} is not specified) are compiled and |
|
e9500709d49c
Added a main() function and support to run this module as a script.
Fred Drake <fdrake@acm.org>
parents:
12223
diff
changeset
|
41 the resulting bytecode is cached in the normal manner. This |
|
e9500709d49c
Added a main() function and support to run this module as a script.
Fred Drake <fdrake@acm.org>
parents:
12223
diff
changeset
|
42 function does not search a directory structure to locate source |
|
e9500709d49c
Added a main() function and support to run this module as a script.
Fred Drake <fdrake@acm.org>
parents:
12223
diff
changeset
|
43 files; it only compiles files named explicitly. |
|
e9500709d49c
Added a main() function and support to run this module as a script.
Fred Drake <fdrake@acm.org>
parents:
12223
diff
changeset
|
44 \end{funcdesc} |
|
e9500709d49c
Added a main() function and support to run this module as a script.
Fred Drake <fdrake@acm.org>
parents:
12223
diff
changeset
|
45 |
|
e9500709d49c
Added a main() function and support to run this module as a script.
Fred Drake <fdrake@acm.org>
parents:
12223
diff
changeset
|
46 When this module is run as a script, the \function{main()} is used to |
|
e9500709d49c
Added a main() function and support to run this module as a script.
Fred Drake <fdrake@acm.org>
parents:
12223
diff
changeset
|
47 compile all the files named on the command line. |
|
e9500709d49c
Added a main() function and support to run this module as a script.
Fred Drake <fdrake@acm.org>
parents:
12223
diff
changeset
|
48 |
|
8936
5b73d5babc78
Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
49 \begin{seealso} |
|
5b73d5babc78
Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
50 \seemodule{compileall}{Utilities to compile all Python source files |
|
5b73d5babc78
Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
51 in a directory tree.} |
|
5b73d5babc78
Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
52 \end{seealso} |
