#!/usr/bin/env python3.7 # Copyright (c) 2011-2019 Eric Froemling """ Compiles Python files into PYC files using the same version of Python that we bundle with our standalone builds. It creates hash-based PYC files in opt level 1 with hash checks defaulting to off, so we don't have to worry about timestamps or loading speed hits due to hash checks. (see PEP 552). We just need to tell modders that they'll need to clear these cache files out or turn on debugging mode if they want to tweak the built-in scripts. """ import os import py_compile import sys def main() -> None: """Main script entry point.""" for arg in sys.argv[1:]: # hmm; seems mypy doesn't know about invalidation_mode yet... mode = py_compile.PycInvalidationMode.UNCHECKED_HASH # type: ignore py_compile.compile( # type: ignore arg, dfile=os.path.basename(arg), doraise=True, optimize=1, invalidation_mode=mode) if __name__ == '__main__': main()