aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2019-01-18 12:21:05 +0100
committerChristian Tismer <tismer@stackless.com>2019-01-22 11:42:39 +0000
commitcebc32a588358851dd58dc0fc892e986dd263efb (patch)
tree41bb409cd2abe394b8336577ad38e9131fb802df
parente947bd79d7f0f0aca8f3f20d01c9dc8475df5696 (diff)
Run generate_pyi After Generation of All Binaries
In COIN, there is a racing condition under Windows: Python opens as many modules as it can, while the build process is not yet done. This can lead to the situation that a module is loaded by Python before the Windows Manifest Tool has been run, and that creates a crash. We therefore wait when COIN is run, until all binaries have been created. That means that we are the last process, and the tool must have been already run. In non-COIN builds it is more convenient when in case of errors the generator crashes early. Task-number: PYSIDE-735 Change-Id: I060dbd54432778f14f74830596f28b4db83a0692 Reviewed-by: Christian Tismer <tismer@stackless.com>
-rw-r--r--sources/pyside2/PySide2/support/generate_pyi.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/sources/pyside2/PySide2/support/generate_pyi.py b/sources/pyside2/PySide2/support/generate_pyi.py
index d754bce76..f1913d03f 100644
--- a/sources/pyside2/PySide2/support/generate_pyi.py
+++ b/sources/pyside2/PySide2/support/generate_pyi.py
@@ -52,6 +52,7 @@ import io
import re
import subprocess
import argparse
+import glob
from contextlib import contextmanager
from textwrap import dedent
@@ -68,6 +69,9 @@ sourcepath = os.path.splitext(__file__)[0] + ".py"
USE_PEP563 = sys.version_info[:2] >= (3, 7)
indent = " " * 4
+is_py3 = sys.version_info[0] == 3
+is_ci = os.environ.get("QTEST_ENVIRONMENT", "") == "ci"
+
class Writer(object):
def __init__(self, outfile):
@@ -248,7 +252,7 @@ def generate_pyi(import_name, outpath, options):
else:
wr.print(line)
logger.info("Generated: {outfilepath}".format(**locals()))
- if sys.version_info[0] == 3:
+ if is_py3:
# Python 3: We can check the file directly if the syntax is ok.
subprocess.check_output([sys.executable, outfilepath])
return 1
@@ -295,6 +299,16 @@ def generate_all_pyi(outpath, options):
lockdir = os.path.join(outpath, "generate_pyi.lockfile")
with single_process(lockdir) as locked:
if locked:
+ if is_ci:
+ # When COIN is running, we sometimes get racing conditions with
+ # the windows manifest tool which wants access to a module that
+ # we already have imported. But when we wait until all binaries
+ # are created, that cannot happen, because we are then the last
+ # process, and the tool has already been run.
+ bin_pattern = "Qt*.pyd" if sys.platform == "win32" else "Qt*.so"
+ search = os.path.join(PySide2.__path__[0], bin_pattern)
+ if len(glob.glob(search)) < len(PySide2.__all__):
+ return
for mod_name in PySide2.__all__:
import_name = "PySide2." + mod_name
step = generate_pyi(import_name, outpath, options)