17db96d56Sopenharmony_ci:mod:`compileall` --- Byte-compile Python libraries 27db96d56Sopenharmony_ci=================================================== 37db96d56Sopenharmony_ci 47db96d56Sopenharmony_ci.. module:: compileall 57db96d56Sopenharmony_ci :synopsis: Tools for byte-compiling all Python source files in a directory tree. 67db96d56Sopenharmony_ci 77db96d56Sopenharmony_ci**Source code:** :source:`Lib/compileall.py` 87db96d56Sopenharmony_ci 97db96d56Sopenharmony_ci-------------- 107db96d56Sopenharmony_ci 117db96d56Sopenharmony_ciThis module provides some utility functions to support installing Python 127db96d56Sopenharmony_cilibraries. These functions compile Python source files in a directory tree. 137db96d56Sopenharmony_ciThis module can be used to create the cached byte-code files at library 147db96d56Sopenharmony_ciinstallation time, which makes them available for use even by users who don't 157db96d56Sopenharmony_cihave write permission to the library directories. 167db96d56Sopenharmony_ci 177db96d56Sopenharmony_ci.. include:: ../includes/wasm-notavail.rst 187db96d56Sopenharmony_ci 197db96d56Sopenharmony_ciCommand-line use 207db96d56Sopenharmony_ci---------------- 217db96d56Sopenharmony_ci 227db96d56Sopenharmony_ciThis module can work as a script (using :program:`python -m compileall`) to 237db96d56Sopenharmony_cicompile Python sources. 247db96d56Sopenharmony_ci 257db96d56Sopenharmony_ci.. program:: compileall 267db96d56Sopenharmony_ci 277db96d56Sopenharmony_ci.. cmdoption:: directory ... 287db96d56Sopenharmony_ci file ... 297db96d56Sopenharmony_ci 307db96d56Sopenharmony_ci Positional arguments are files to compile or directories that contain 317db96d56Sopenharmony_ci source files, traversed recursively. If no argument is given, behave as if 327db96d56Sopenharmony_ci the command line was ``-l <directories from sys.path>``. 337db96d56Sopenharmony_ci 347db96d56Sopenharmony_ci.. cmdoption:: -l 357db96d56Sopenharmony_ci 367db96d56Sopenharmony_ci Do not recurse into subdirectories, only compile source code files directly 377db96d56Sopenharmony_ci contained in the named or implied directories. 387db96d56Sopenharmony_ci 397db96d56Sopenharmony_ci.. cmdoption:: -f 407db96d56Sopenharmony_ci 417db96d56Sopenharmony_ci Force rebuild even if timestamps are up-to-date. 427db96d56Sopenharmony_ci 437db96d56Sopenharmony_ci.. cmdoption:: -q 447db96d56Sopenharmony_ci 457db96d56Sopenharmony_ci Do not print the list of files compiled. If passed once, error messages will 467db96d56Sopenharmony_ci still be printed. If passed twice (``-qq``), all output is suppressed. 477db96d56Sopenharmony_ci 487db96d56Sopenharmony_ci.. cmdoption:: -d destdir 497db96d56Sopenharmony_ci 507db96d56Sopenharmony_ci Directory prepended to the path to each file being compiled. This will 517db96d56Sopenharmony_ci appear in compilation time tracebacks, and is also compiled in to the 527db96d56Sopenharmony_ci byte-code file, where it will be used in tracebacks and other messages in 537db96d56Sopenharmony_ci cases where the source file does not exist at the time the byte-code file is 547db96d56Sopenharmony_ci executed. 557db96d56Sopenharmony_ci 567db96d56Sopenharmony_ci.. cmdoption:: -s strip_prefix 577db96d56Sopenharmony_ci.. cmdoption:: -p prepend_prefix 587db96d56Sopenharmony_ci 597db96d56Sopenharmony_ci Remove (``-s``) or append (``-p``) the given prefix of paths 607db96d56Sopenharmony_ci recorded in the ``.pyc`` files. 617db96d56Sopenharmony_ci Cannot be combined with ``-d``. 627db96d56Sopenharmony_ci 637db96d56Sopenharmony_ci.. cmdoption:: -x regex 647db96d56Sopenharmony_ci 657db96d56Sopenharmony_ci regex is used to search the full path to each file considered for 667db96d56Sopenharmony_ci compilation, and if the regex produces a match, the file is skipped. 677db96d56Sopenharmony_ci 687db96d56Sopenharmony_ci.. cmdoption:: -i list 697db96d56Sopenharmony_ci 707db96d56Sopenharmony_ci Read the file ``list`` and add each line that it contains to the list of 717db96d56Sopenharmony_ci files and directories to compile. If ``list`` is ``-``, read lines from 727db96d56Sopenharmony_ci ``stdin``. 737db96d56Sopenharmony_ci 747db96d56Sopenharmony_ci.. cmdoption:: -b 757db96d56Sopenharmony_ci 767db96d56Sopenharmony_ci Write the byte-code files to their legacy locations and names, which may 777db96d56Sopenharmony_ci overwrite byte-code files created by another version of Python. The default 787db96d56Sopenharmony_ci is to write files to their :pep:`3147` locations and names, which allows 797db96d56Sopenharmony_ci byte-code files from multiple versions of Python to coexist. 807db96d56Sopenharmony_ci 817db96d56Sopenharmony_ci.. cmdoption:: -r 827db96d56Sopenharmony_ci 837db96d56Sopenharmony_ci Control the maximum recursion level for subdirectories. 847db96d56Sopenharmony_ci If this is given, then ``-l`` option will not be taken into account. 857db96d56Sopenharmony_ci :program:`python -m compileall <directory> -r 0` is equivalent to 867db96d56Sopenharmony_ci :program:`python -m compileall <directory> -l`. 877db96d56Sopenharmony_ci 887db96d56Sopenharmony_ci.. cmdoption:: -j N 897db96d56Sopenharmony_ci 907db96d56Sopenharmony_ci Use *N* workers to compile the files within the given directory. 917db96d56Sopenharmony_ci If ``0`` is used, then the result of :func:`os.cpu_count()` 927db96d56Sopenharmony_ci will be used. 937db96d56Sopenharmony_ci 947db96d56Sopenharmony_ci.. cmdoption:: --invalidation-mode [timestamp|checked-hash|unchecked-hash] 957db96d56Sopenharmony_ci 967db96d56Sopenharmony_ci Control how the generated byte-code files are invalidated at runtime. 977db96d56Sopenharmony_ci The ``timestamp`` value, means that ``.pyc`` files with the source timestamp 987db96d56Sopenharmony_ci and size embedded will be generated. The ``checked-hash`` and 997db96d56Sopenharmony_ci ``unchecked-hash`` values cause hash-based pycs to be generated. Hash-based 1007db96d56Sopenharmony_ci pycs embed a hash of the source file contents rather than a timestamp. See 1017db96d56Sopenharmony_ci :ref:`pyc-invalidation` for more information on how Python validates 1027db96d56Sopenharmony_ci bytecode cache files at runtime. 1037db96d56Sopenharmony_ci The default is ``timestamp`` if the :envvar:`SOURCE_DATE_EPOCH` environment 1047db96d56Sopenharmony_ci variable is not set, and ``checked-hash`` if the ``SOURCE_DATE_EPOCH`` 1057db96d56Sopenharmony_ci environment variable is set. 1067db96d56Sopenharmony_ci 1077db96d56Sopenharmony_ci.. cmdoption:: -o level 1087db96d56Sopenharmony_ci 1097db96d56Sopenharmony_ci Compile with the given optimization level. May be used multiple times 1107db96d56Sopenharmony_ci to compile for multiple levels at a time (for example, 1117db96d56Sopenharmony_ci ``compileall -o 1 -o 2``). 1127db96d56Sopenharmony_ci 1137db96d56Sopenharmony_ci.. cmdoption:: -e dir 1147db96d56Sopenharmony_ci 1157db96d56Sopenharmony_ci Ignore symlinks pointing outside the given directory. 1167db96d56Sopenharmony_ci 1177db96d56Sopenharmony_ci.. cmdoption:: --hardlink-dupes 1187db96d56Sopenharmony_ci 1197db96d56Sopenharmony_ci If two ``.pyc`` files with different optimization level have 1207db96d56Sopenharmony_ci the same content, use hard links to consolidate duplicate files. 1217db96d56Sopenharmony_ci 1227db96d56Sopenharmony_ci.. versionchanged:: 3.2 1237db96d56Sopenharmony_ci Added the ``-i``, ``-b`` and ``-h`` options. 1247db96d56Sopenharmony_ci 1257db96d56Sopenharmony_ci.. versionchanged:: 3.5 1267db96d56Sopenharmony_ci Added the ``-j``, ``-r``, and ``-qq`` options. ``-q`` option 1277db96d56Sopenharmony_ci was changed to a multilevel value. ``-b`` will always produce a 1287db96d56Sopenharmony_ci byte-code file ending in ``.pyc``, never ``.pyo``. 1297db96d56Sopenharmony_ci 1307db96d56Sopenharmony_ci.. versionchanged:: 3.7 1317db96d56Sopenharmony_ci Added the ``--invalidation-mode`` option. 1327db96d56Sopenharmony_ci 1337db96d56Sopenharmony_ci.. versionchanged:: 3.9 1347db96d56Sopenharmony_ci Added the ``-s``, ``-p``, ``-e`` and ``--hardlink-dupes`` options. 1357db96d56Sopenharmony_ci Raised the default recursion limit from 10 to 1367db96d56Sopenharmony_ci :py:func:`sys.getrecursionlimit()`. 1377db96d56Sopenharmony_ci Added the possibility to specify the ``-o`` option multiple times. 1387db96d56Sopenharmony_ci 1397db96d56Sopenharmony_ci 1407db96d56Sopenharmony_ciThere is no command-line option to control the optimization level used by the 1417db96d56Sopenharmony_ci:func:`compile` function, because the Python interpreter itself already 1427db96d56Sopenharmony_ciprovides the option: :program:`python -O -m compileall`. 1437db96d56Sopenharmony_ci 1447db96d56Sopenharmony_ciSimilarly, the :func:`compile` function respects the :attr:`sys.pycache_prefix` 1457db96d56Sopenharmony_cisetting. The generated bytecode cache will only be useful if :func:`compile` is 1467db96d56Sopenharmony_cirun with the same :attr:`sys.pycache_prefix` (if any) that will be used at 1477db96d56Sopenharmony_ciruntime. 1487db96d56Sopenharmony_ci 1497db96d56Sopenharmony_ciPublic functions 1507db96d56Sopenharmony_ci---------------- 1517db96d56Sopenharmony_ci 1527db96d56Sopenharmony_ci.. 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, hardlink_dupes=False) 1537db96d56Sopenharmony_ci 1547db96d56Sopenharmony_ci Recursively descend the directory tree named by *dir*, compiling all :file:`.py` 1557db96d56Sopenharmony_ci files along the way. Return a true value if all the files compiled successfully, 1567db96d56Sopenharmony_ci and a false value otherwise. 1577db96d56Sopenharmony_ci 1587db96d56Sopenharmony_ci The *maxlevels* parameter is used to limit the depth of the recursion; it 1597db96d56Sopenharmony_ci defaults to ``sys.getrecursionlimit()``. 1607db96d56Sopenharmony_ci 1617db96d56Sopenharmony_ci If *ddir* is given, it is prepended to the path to each file being compiled 1627db96d56Sopenharmony_ci for use in compilation time tracebacks, and is also compiled in to the 1637db96d56Sopenharmony_ci byte-code file, where it will be used in tracebacks and other messages in 1647db96d56Sopenharmony_ci cases where the source file does not exist at the time the byte-code file is 1657db96d56Sopenharmony_ci executed. 1667db96d56Sopenharmony_ci 1677db96d56Sopenharmony_ci If *force* is true, modules are re-compiled even if the timestamps are up to 1687db96d56Sopenharmony_ci date. 1697db96d56Sopenharmony_ci 1707db96d56Sopenharmony_ci If *rx* is given, its ``search`` method is called on the complete path to each 1717db96d56Sopenharmony_ci file considered for compilation, and if it returns a true value, the file 1727db96d56Sopenharmony_ci is skipped. This can be used to exclude files matching a regular expression, 1737db96d56Sopenharmony_ci given as a :ref:`re.Pattern <re-objects>` object. 1747db96d56Sopenharmony_ci 1757db96d56Sopenharmony_ci If *quiet* is ``False`` or ``0`` (the default), the filenames and other 1767db96d56Sopenharmony_ci information are printed to standard out. Set to ``1``, only errors are 1777db96d56Sopenharmony_ci printed. Set to ``2``, all output is suppressed. 1787db96d56Sopenharmony_ci 1797db96d56Sopenharmony_ci If *legacy* is true, byte-code files are written to their legacy locations 1807db96d56Sopenharmony_ci and names, which may overwrite byte-code files created by another version of 1817db96d56Sopenharmony_ci Python. The default is to write files to their :pep:`3147` locations and 1827db96d56Sopenharmony_ci names, which allows byte-code files from multiple versions of Python to 1837db96d56Sopenharmony_ci coexist. 1847db96d56Sopenharmony_ci 1857db96d56Sopenharmony_ci *optimize* specifies the optimization level for the compiler. It is passed to 1867db96d56Sopenharmony_ci the built-in :func:`compile` function. Accepts also a sequence of optimization 1877db96d56Sopenharmony_ci levels which lead to multiple compilations of one :file:`.py` file in one call. 1887db96d56Sopenharmony_ci 1897db96d56Sopenharmony_ci The argument *workers* specifies how many workers are used to 1907db96d56Sopenharmony_ci compile files in parallel. The default is to not use multiple workers. 1917db96d56Sopenharmony_ci If the platform can't use multiple workers and *workers* argument is given, 1927db96d56Sopenharmony_ci then sequential compilation will be used as a fallback. If *workers* 1937db96d56Sopenharmony_ci is 0, the number of cores in the system is used. If *workers* is 1947db96d56Sopenharmony_ci lower than ``0``, a :exc:`ValueError` will be raised. 1957db96d56Sopenharmony_ci 1967db96d56Sopenharmony_ci *invalidation_mode* should be a member of the 1977db96d56Sopenharmony_ci :class:`py_compile.PycInvalidationMode` enum and controls how the generated 1987db96d56Sopenharmony_ci pycs are invalidated at runtime. 1997db96d56Sopenharmony_ci 2007db96d56Sopenharmony_ci The *stripdir*, *prependdir* and *limit_sl_dest* arguments correspond to 2017db96d56Sopenharmony_ci the ``-s``, ``-p`` and ``-e`` options described above. 2027db96d56Sopenharmony_ci They may be specified as ``str`` or :py:class:`os.PathLike`. 2037db96d56Sopenharmony_ci 2047db96d56Sopenharmony_ci If *hardlink_dupes* is true and two ``.pyc`` files with different optimization 2057db96d56Sopenharmony_ci level have the same content, use hard links to consolidate duplicate files. 2067db96d56Sopenharmony_ci 2077db96d56Sopenharmony_ci .. versionchanged:: 3.2 2087db96d56Sopenharmony_ci Added the *legacy* and *optimize* parameter. 2097db96d56Sopenharmony_ci 2107db96d56Sopenharmony_ci .. versionchanged:: 3.5 2117db96d56Sopenharmony_ci Added the *workers* parameter. 2127db96d56Sopenharmony_ci 2137db96d56Sopenharmony_ci .. versionchanged:: 3.5 2147db96d56Sopenharmony_ci *quiet* parameter was changed to a multilevel value. 2157db96d56Sopenharmony_ci 2167db96d56Sopenharmony_ci .. versionchanged:: 3.5 2177db96d56Sopenharmony_ci The *legacy* parameter only writes out ``.pyc`` files, not ``.pyo`` files 2187db96d56Sopenharmony_ci no matter what the value of *optimize* is. 2197db96d56Sopenharmony_ci 2207db96d56Sopenharmony_ci .. versionchanged:: 3.6 2217db96d56Sopenharmony_ci Accepts a :term:`path-like object`. 2227db96d56Sopenharmony_ci 2237db96d56Sopenharmony_ci .. versionchanged:: 3.7 2247db96d56Sopenharmony_ci The *invalidation_mode* parameter was added. 2257db96d56Sopenharmony_ci 2267db96d56Sopenharmony_ci .. versionchanged:: 3.7.2 2277db96d56Sopenharmony_ci The *invalidation_mode* parameter's default value is updated to None. 2287db96d56Sopenharmony_ci 2297db96d56Sopenharmony_ci .. versionchanged:: 3.8 2307db96d56Sopenharmony_ci Setting *workers* to 0 now chooses the optimal number of cores. 2317db96d56Sopenharmony_ci 2327db96d56Sopenharmony_ci .. versionchanged:: 3.9 2337db96d56Sopenharmony_ci Added *stripdir*, *prependdir*, *limit_sl_dest* and *hardlink_dupes* arguments. 2347db96d56Sopenharmony_ci Default value of *maxlevels* was changed from ``10`` to ``sys.getrecursionlimit()`` 2357db96d56Sopenharmony_ci 2367db96d56Sopenharmony_ci.. function:: compile_file(fullname, ddir=None, force=False, rx=None, quiet=0, legacy=False, optimize=-1, invalidation_mode=None, *, stripdir=None, prependdir=None, limit_sl_dest=None, hardlink_dupes=False) 2377db96d56Sopenharmony_ci 2387db96d56Sopenharmony_ci Compile the file with path *fullname*. Return a true value if the file 2397db96d56Sopenharmony_ci compiled successfully, and a false value otherwise. 2407db96d56Sopenharmony_ci 2417db96d56Sopenharmony_ci If *ddir* is given, it is prepended to the path to the file being compiled 2427db96d56Sopenharmony_ci for use in compilation time tracebacks, and is also compiled in to the 2437db96d56Sopenharmony_ci byte-code file, where it will be used in tracebacks and other messages in 2447db96d56Sopenharmony_ci cases where the source file does not exist at the time the byte-code file is 2457db96d56Sopenharmony_ci executed. 2467db96d56Sopenharmony_ci 2477db96d56Sopenharmony_ci If *rx* is given, its ``search`` method is passed the full path name to the 2487db96d56Sopenharmony_ci file being compiled, and if it returns a true value, the file is not 2497db96d56Sopenharmony_ci compiled and ``True`` is returned. This can be used to exclude files matching 2507db96d56Sopenharmony_ci a regular expression, given as a :ref:`re.Pattern <re-objects>` object. 2517db96d56Sopenharmony_ci 2527db96d56Sopenharmony_ci If *quiet* is ``False`` or ``0`` (the default), the filenames and other 2537db96d56Sopenharmony_ci information are printed to standard out. Set to ``1``, only errors are 2547db96d56Sopenharmony_ci printed. Set to ``2``, all output is suppressed. 2557db96d56Sopenharmony_ci 2567db96d56Sopenharmony_ci If *legacy* is true, byte-code files are written to their legacy locations 2577db96d56Sopenharmony_ci and names, which may overwrite byte-code files created by another version of 2587db96d56Sopenharmony_ci Python. The default is to write files to their :pep:`3147` locations and 2597db96d56Sopenharmony_ci names, which allows byte-code files from multiple versions of Python to 2607db96d56Sopenharmony_ci coexist. 2617db96d56Sopenharmony_ci 2627db96d56Sopenharmony_ci *optimize* specifies the optimization level for the compiler. It is passed to 2637db96d56Sopenharmony_ci the built-in :func:`compile` function. Accepts also a sequence of optimization 2647db96d56Sopenharmony_ci levels which lead to multiple compilations of one :file:`.py` file in one call. 2657db96d56Sopenharmony_ci 2667db96d56Sopenharmony_ci *invalidation_mode* should be a member of the 2677db96d56Sopenharmony_ci :class:`py_compile.PycInvalidationMode` enum and controls how the generated 2687db96d56Sopenharmony_ci pycs are invalidated at runtime. 2697db96d56Sopenharmony_ci 2707db96d56Sopenharmony_ci The *stripdir*, *prependdir* and *limit_sl_dest* arguments correspond to 2717db96d56Sopenharmony_ci the ``-s``, ``-p`` and ``-e`` options described above. 2727db96d56Sopenharmony_ci They may be specified as ``str`` or :py:class:`os.PathLike`. 2737db96d56Sopenharmony_ci 2747db96d56Sopenharmony_ci If *hardlink_dupes* is true and two ``.pyc`` files with different optimization 2757db96d56Sopenharmony_ci level have the same content, use hard links to consolidate duplicate files. 2767db96d56Sopenharmony_ci 2777db96d56Sopenharmony_ci .. versionadded:: 3.2 2787db96d56Sopenharmony_ci 2797db96d56Sopenharmony_ci .. versionchanged:: 3.5 2807db96d56Sopenharmony_ci *quiet* parameter was changed to a multilevel value. 2817db96d56Sopenharmony_ci 2827db96d56Sopenharmony_ci .. versionchanged:: 3.5 2837db96d56Sopenharmony_ci The *legacy* parameter only writes out ``.pyc`` files, not ``.pyo`` files 2847db96d56Sopenharmony_ci no matter what the value of *optimize* is. 2857db96d56Sopenharmony_ci 2867db96d56Sopenharmony_ci .. versionchanged:: 3.7 2877db96d56Sopenharmony_ci The *invalidation_mode* parameter was added. 2887db96d56Sopenharmony_ci 2897db96d56Sopenharmony_ci .. versionchanged:: 3.7.2 2907db96d56Sopenharmony_ci The *invalidation_mode* parameter's default value is updated to None. 2917db96d56Sopenharmony_ci 2927db96d56Sopenharmony_ci .. versionchanged:: 3.9 2937db96d56Sopenharmony_ci Added *stripdir*, *prependdir*, *limit_sl_dest* and *hardlink_dupes* arguments. 2947db96d56Sopenharmony_ci 2957db96d56Sopenharmony_ci.. function:: compile_path(skip_curdir=True, maxlevels=0, force=False, quiet=0, legacy=False, optimize=-1, invalidation_mode=None) 2967db96d56Sopenharmony_ci 2977db96d56Sopenharmony_ci Byte-compile all the :file:`.py` files found along ``sys.path``. Return a 2987db96d56Sopenharmony_ci true value if all the files compiled successfully, and a false value otherwise. 2997db96d56Sopenharmony_ci 3007db96d56Sopenharmony_ci If *skip_curdir* is true (the default), the current directory is not included 3017db96d56Sopenharmony_ci in the search. All other parameters are passed to the :func:`compile_dir` 3027db96d56Sopenharmony_ci function. Note that unlike the other compile functions, ``maxlevels`` 3037db96d56Sopenharmony_ci defaults to ``0``. 3047db96d56Sopenharmony_ci 3057db96d56Sopenharmony_ci .. versionchanged:: 3.2 3067db96d56Sopenharmony_ci Added the *legacy* and *optimize* parameter. 3077db96d56Sopenharmony_ci 3087db96d56Sopenharmony_ci .. versionchanged:: 3.5 3097db96d56Sopenharmony_ci *quiet* parameter was changed to a multilevel value. 3107db96d56Sopenharmony_ci 3117db96d56Sopenharmony_ci .. versionchanged:: 3.5 3127db96d56Sopenharmony_ci The *legacy* parameter only writes out ``.pyc`` files, not ``.pyo`` files 3137db96d56Sopenharmony_ci no matter what the value of *optimize* is. 3147db96d56Sopenharmony_ci 3157db96d56Sopenharmony_ci .. versionchanged:: 3.7 3167db96d56Sopenharmony_ci The *invalidation_mode* parameter was added. 3177db96d56Sopenharmony_ci 3187db96d56Sopenharmony_ci .. versionchanged:: 3.7.2 3197db96d56Sopenharmony_ci The *invalidation_mode* parameter's default value is updated to None. 3207db96d56Sopenharmony_ci 3217db96d56Sopenharmony_ciTo force a recompile of all the :file:`.py` files in the :file:`Lib/` 3227db96d56Sopenharmony_cisubdirectory and all its subdirectories:: 3237db96d56Sopenharmony_ci 3247db96d56Sopenharmony_ci import compileall 3257db96d56Sopenharmony_ci 3267db96d56Sopenharmony_ci compileall.compile_dir('Lib/', force=True) 3277db96d56Sopenharmony_ci 3287db96d56Sopenharmony_ci # Perform same compilation, excluding files in .svn directories. 3297db96d56Sopenharmony_ci import re 3307db96d56Sopenharmony_ci compileall.compile_dir('Lib/', rx=re.compile(r'[/\\][.]svn'), force=True) 3317db96d56Sopenharmony_ci 3327db96d56Sopenharmony_ci # pathlib.Path objects can also be used. 3337db96d56Sopenharmony_ci import pathlib 3347db96d56Sopenharmony_ci compileall.compile_dir(pathlib.Path('Lib/'), force=True) 3357db96d56Sopenharmony_ci 3367db96d56Sopenharmony_ci.. seealso:: 3377db96d56Sopenharmony_ci 3387db96d56Sopenharmony_ci Module :mod:`py_compile` 3397db96d56Sopenharmony_ci Byte-compile a single source file. 340