On this page
compileall.compile_dir
Up: compileall | Next: compileall.compile_file
Rel: compileall.compile_file, compileall.compile_path
Ref: docs.python.org — compileall.compile_dir
Tags: #public #python3 #stdlib #compileall
Import
import compileall
from compileall import compile_dir
Signature & Overview
compileall.compile_dir(dir, maxlevels=None, 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, hardlink_dupes=False)
Byte-compile all modules in the given directory tree.
Usage
import compileall
from pathlib import Path
import tempfile
with tempfile.TemporaryDirectory() as tmp:
(Path(tmp) / "ok.py").write_text("x = 1\n", encoding="utf-8")
assert compileall.compile_dir(tmp, quiet=1) is True
Gotchas
- Returns
Trueif all files compiled withoutSyntaxError: Passworkers=0to parallelize across CPU cores.
REPL Inspect
from compileall import compile_dir
help(compile_dir)
Linked from
Related notes
- tuts/python3/stdlib_module/compileall/compile_file Linked here; links to this page; shared tags: #compileall, #stdlib
- tuts/python3/stdlib_module/compileall/compile_path Linked here; links to this page; shared tags: #compileall, #stdlib
- tuts/python3/stdlib_module/compileall Linked here; links to this page; shared tags: #stdlib
- tuts/c/stdlib shared tags: #stdlib
- tuts/c/stdlib/assert shared tags: #stdlib
- tuts/c/stdlib/assert/assert shared tags: #stdlib
- tuts/c/stdlib/assert/static_assert shared tags: #stdlib
- tuts/c/stdlib/ctype shared tags: #stdlib
- tuts/c/stdlib/ctype/isalpha shared tags: #stdlib
- tuts/c/stdlib/ctype/isdigit shared tags: #stdlib