From d248f7e81bf6db90a03e8bca7059e81e3e37158c Mon Sep 17 00:00:00 2001 From: Christian Tismer Date: Sat, 15 Dec 2018 20:25:09 +0100 Subject: Refine .pyi Messages The generation of .pyi files talks too much when "--reuse-build" is used and actually no files are created at all. This patch guarantees that only one message comes out. Change-Id: I41f1aada0da27f0fab880ad51838f8615d61b08c Reviewed-by: Friedemann Kleint --- sources/pyside2/PySide2/support/generate_pyi.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/sources/pyside2/PySide2/support/generate_pyi.py b/sources/pyside2/PySide2/support/generate_pyi.py index 44ccd71d2..d754bce76 100644 --- a/sources/pyside2/PySide2/support/generate_pyi.py +++ b/sources/pyside2/PySide2/support/generate_pyi.py @@ -181,7 +181,13 @@ def generate_pyi(import_name, outpath, options): """ Generates a .pyi file. - Returns 1 If the result is valid, else 0. + Returns 1 If the result is valid, -1 if the result existed already + and was skipped, else 0. + + This function will get called during a PySide build, and many concurrent + process might try to create .pyi files. We let only one process at a + time work on these files, but it will still be different processes which + do the work. """ pid = os.getpid() plainname = import_name.split(".")[-1] @@ -189,7 +195,7 @@ def generate_pyi(import_name, outpath, options): if options.skip and os.path.exists(outfilepath): logger.debug("{pid}:Skipped existing: {op}" .format(op=os.path.basename(outfilepath), **locals())) - return 1 + return -1 try: top = __import__(import_name) @@ -283,7 +289,7 @@ def generate_all_pyi(outpath, options): from PySide2.support.signature import inspect from PySide2.support.signature.lib.enum_sig import HintingEnumerator - valid = 0 + valid = check = 0 if not outpath: outpath = os.path.dirname(PySide2.__file__) lockdir = os.path.join(outpath, "generate_pyi.lockfile") @@ -291,10 +297,14 @@ def generate_all_pyi(outpath, options): if locked: for mod_name in PySide2.__all__: import_name = "PySide2." + mod_name - valid += generate_pyi(import_name, outpath, options) + step = generate_pyi(import_name, outpath, options) + valid += abs(step) + check += step npyi = len(PySide2.__all__) - if valid == npyi: + # Prevent too many messages when '--reuse-build' is used. We check that + # all files are created, but at least one was really computed. + if valid == npyi and check != -npyi: logger.info("+++ All {npyi} .pyi files have been created.".format(**locals())) -- cgit v1.2.3