diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2021-09-29 19:01:51 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-11-26 23:24:22 +0000 |
commit | 8d1de6f4953f2775a16d92126ef4cdcc24d1f5f0 (patch) | |
tree | 6bd8bf7c1056dab6efdc12139bf2b9b3ff3aa441 | |
parent | 2ef8c00cae0be47fcacf631a68a8298bd89213e3 (diff) |
setup.py: Don't add the Qt prefix dir to PATH env var before building
Modifying PATH influences which packages are found by CMake's
find_package, as well as which binaries are available to execute
during the CMake build phase.
Instead of relying on PATH, we should rely on passing the detected Qt
prefix dir to CMAKE_PREFIX_PATH.
This makes the build process more robust against differences
in environment variables, as well as ensuring reproducibility
when incrementally rebuilding a project manually without going
through setup.py.
Task-number: PYSIDE-1033
Change-Id: I9c36d9924b82cb1133c44f4ef44ca785bbf7e862
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Christian Tismer <tismer@stackless.com>
(cherry picked from commit 99e49333432ab2ca7c185f2504e09480ae8de880)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | build_scripts/main.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/build_scripts/main.py b/build_scripts/main.py index 10510f648..268b1fbc2 100644 --- a/build_scripts/main.py +++ b/build_scripts/main.py @@ -469,13 +469,12 @@ class PysideBuild(_build, DistUtilsCommandMixin): self.py_scripts_dir = py_scripts_dir self.qtinfo = QtInfo() - qt_dir = os.path.dirname(OPTION["QTPATHS"]) - if OPTION['HAS_QMAKE_OPTION']: - qt_dir = os.path.dirname(OPTION["QMAKE"]) qt_version = get_qt_version() - # Update the PATH environment variable - additional_paths = [self.py_scripts_dir, qt_dir] + # Don't add Qt to PATH env var, we don't want it to interfere + # with CMake's find_package calls which will use + # CMAKE_PREFIX_PATH. + additional_paths = [self.py_scripts_dir] # Add Clang to path for Windows. # Revisit once Clang is bundled with Qt. @@ -864,6 +863,9 @@ class PysideBuild(_build, DistUtilsCommandMixin): if OPTION["PYSIDE_NUMPY_SUPPORT"]: cmake_cmd.append("-DPYSIDE_NUMPY_SUPPORT=1") + target_qt_prefix_path = self.qtinfo.prefix_dir + cmake_cmd.append(f"-DCMAKE_PREFIX_PATH={target_qt_prefix_path}") + if not OPTION["SKIP_CMAKE"]: log.info(f"Configuring module {extension} ({module_src_dir})...") if run_process(cmake_cmd) != 0: |