summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2018-12-15 20:25:09 +0100
committerChristian Tismer <tismer@stackless.com>2018-12-17 08:17:30 +0000
commitd248f7e81bf6db90a03e8bca7059e81e3e37158c (patch)
tree24868e3d61d39b227544583e2b6cf61791b53cd9
parentdf61c5a59f54bf03907e30e16dc9fd5247611201 (diff)
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 <Friedemann.Kleint@qt.io>
-rw-r--r--sources/pyside2/PySide2/support/generate_pyi.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/sources/pyside2/PySide2/support/generate_pyi.py b/sources/pyside2/PySide2/support/generate_pyi.py
index 44ccd71d..d754bce7 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()))