@@ -52,6 +52,13 @@ compile Python sources.
52
52
cases where the source file does not exist at the time the byte-code file is
53
53
executed.
54
54
55
+ .. cmdoption :: -s strip_prefix
56
+ .. cmdoption :: -p prepend_prefix
57
+
58
+ Remove (``-s ``) or append (``-p ``) the given prefix of paths
59
+ recorded in the ``.pyc `` files.
60
+ Raises :exc: `ValueError ` if combined with ``-d ``.
61
+
55
62
.. cmdoption :: -x regex
56
63
57
64
regex is used to search the full path to each file considered for
@@ -96,6 +103,16 @@ compile Python sources.
96
103
variable is not set, and ``checked-hash `` if the ``SOURCE_DATE_EPOCH ``
97
104
environment variable is set.
98
105
106
+ .. cmdoption :: -o level
107
+
108
+ Compile with the given optimization level. May be used multiple times
109
+ to compile for multiple levels at a time (for example,
110
+ ``compileall -o 1 -o 2 ``).
111
+
112
+ .. cmdoption :: -e dir
113
+
114
+ Ignore symlinks pointing outside the given directory.
115
+
99
116
.. versionchanged :: 3.2
100
117
Added the ``-i ``, ``-b `` and ``-h `` options.
101
118
@@ -107,6 +124,12 @@ compile Python sources.
107
124
.. versionchanged :: 3.7
108
125
Added the ``--invalidation-mode `` option.
109
126
127
+ .. versionchanged :: 3.9
128
+ Added the ``-s ``, ``-p ``, ``-e `` options.
129
+ Raised the default default recursion limit from 10 to
130
+ :py:func: `sys.getrecursionlimit() `.
131
+ Added the possibility to specify the ``-o `` option multiple times.
132
+
110
133
111
134
There is no command-line option to control the optimization level used by the
112
135
:func: `compile ` function, because the Python interpreter itself already
@@ -120,7 +143,7 @@ runtime.
120
143
Public functions
121
144
----------------
122
145
123
- .. function :: compile_dir(dir, maxlevels=10 , ddir=None, force=False, rx=None, quiet=0, legacy=False, optimize=-1, workers=1, invalidation_mode=None)
146
+ .. function :: compile_dir(dir, maxlevels=sys.getrecursionlimit() , ddir=None, force=False, rx=None, quiet=0, legacy=False, optimize=-1, workers=1, invalidation_mode=None, stripdir=None, prependdir=None, limit_sl_dest =None)
124
147
125
148
Recursively descend the directory tree named by *dir *, compiling all :file: `.py `
126
149
files along the way. Return a true value if all the files compiled successfully,
@@ -166,6 +189,10 @@ Public functions
166
189
:class: `py_compile.PycInvalidationMode ` enum and controls how the generated
167
190
pycs are invalidated at runtime.
168
191
192
+ The *stripdir *, *prependdir * and *limit_sl_dest * arguments correspond to
193
+ the ``-s ``, ``-p `` and ``-e `` options described above.
194
+ They may be specified as ``str ``, ``bytes `` or :py:class: `os.PathLike `.
195
+
169
196
.. versionchanged :: 3.2
170
197
Added the *legacy * and *optimize * parameter.
171
198
@@ -191,6 +218,9 @@ Public functions
191
218
.. versionchanged :: 3.8
192
219
Setting *workers * to 0 now chooses the optimal number of cores.
193
220
221
+ .. versionchanged :: 3.9
222
+ Added *stripdir *, *prependdir * and *limit_sl_dest * arguments.
223
+
194
224
.. function :: compile_file(fullname, ddir=None, force=False, rx=None, quiet=0, legacy=False, optimize=-1, invalidation_mode=None)
195
225
196
226
Compile the file with path *fullname *. Return a true value if the file
@@ -223,6 +253,10 @@ Public functions
223
253
:class: `py_compile.PycInvalidationMode ` enum and controls how the generated
224
254
pycs are invalidated at runtime.
225
255
256
+ The *stripdir *, *prependdir * and *limit_sl_dest * arguments correspond to
257
+ the ``-s ``, ``-p `` and ``-e `` options described above.
258
+ They may be specified as ``str ``, ``bytes `` or :py:class: `os.PathLike `.
259
+
226
260
.. versionadded :: 3.2
227
261
228
262
.. versionchanged :: 3.5
@@ -238,6 +272,9 @@ Public functions
238
272
.. versionchanged :: 3.7.2
239
273
The *invalidation_mode * parameter's default value is updated to None.
240
274
275
+ .. versionchanged :: 3.9
276
+ Added *stripdir *, *prependdir * and *limit_sl_dest * arguments.
277
+
241
278
.. function :: compile_path(skip_curdir=True, maxlevels=0, force=False, quiet=0, legacy=False, optimize=-1, invalidation_mode=None)
242
279
243
280
Byte-compile all the :file: `.py ` files found along ``sys.path ``. Return a
0 commit comments