aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2021-11-22 18:29:56 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-11-29 15:42:46 +0000
commit389538e2ecb4b07c28ce274087baacdac51996d8 (patch)
tree865fa37bc9bdb94bd5322d847da8ef4d82474afc
parente47762e7ad848bb45676913d75f44f7485494479 (diff)
setup.py: Simplify logic of qmake and qtpaths lookup
If an explicit qmake or qtpaths option is given, use it to determine the Qt prefix dir. If no option is specified, try to find qtpaths in PATH. Don't try to find the sibling tool as we did before this change, there's no benefit in doing that. Either one can be used to query the required Qt information. Make sure to log both tool paths. Amends 3b4764fefbb349eafb831b5da90f565b34c77a52 Change-Id: I03afaa8d8476b3d09affdde28f3ff6f1fdf652b6 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> (cherry picked from commit ed095a59eb91b48bd4e62e0b3d6005ab2d058d17) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--build_scripts/main.py1
-rw-r--r--build_scripts/options.py53
-rw-r--r--build_scripts/qtinfo.py4
3 files changed, 26 insertions, 32 deletions
diff --git a/build_scripts/main.py b/build_scripts/main.py
index 268b1fbc2..df1b29688 100644
--- a/build_scripts/main.py
+++ b/build_scripts/main.py
@@ -616,6 +616,7 @@ class PysideBuild(_build, DistUtilsCommandMixin):
log.info(f"Python scripts: {self.py_scripts_dir}")
log.info("-" * 3)
log.info(f"Qt qmake: {self.qtinfo.qmake_command}")
+ log.info(f"Qt qtpaths: {self.qtinfo.qtpaths_command}")
log.info(f"Qt version: {self.qtinfo.version}")
log.info(f"Qt bins: {self.qtinfo.bins_dir}")
log.info(f"Qt docs: {self.qtinfo.docs_dir}")
diff --git a/build_scripts/options.py b/build_scripts/options.py
index ff1260586..fdf246e26 100644
--- a/build_scripts/options.py
+++ b/build_scripts/options.py
@@ -308,13 +308,13 @@ class DistUtilsCommandMixin(object):
OPTION['SHORTER_PATHS'] = self.shorter_paths
OPTION['DOC_BUILD_ONLINE'] = self.doc_build_online
- qtpaths_abs_path = ''
+ qtpaths_abs_path = None
if self.qtpaths:
qtpaths_abs_path = os.path.abspath(self.qtpaths)
OPTION['QTPATHS'] = qtpaths_abs_path
# FIXME PYSIDE7: Remove qmake handling
# make qtinfo.py independent of relative paths.
- qmake_abs_path = ''
+ qmake_abs_path = None
if self.qmake:
qmake_abs_path = os.path.abspath(self.qmake)
OPTION['QMAKE'] = qmake_abs_path
@@ -338,6 +338,12 @@ class DistUtilsCommandMixin(object):
OPTION['NO_QT_TOOLS'] = self.no_qt_tools
OPTION['PYSIDE_NUMPY_SUPPORT'] = self.pyside_numpy_support
+ def _find_qtpaths_in_path(self):
+ if not self.qtpaths:
+ self.qtpaths = which("qtpaths")
+ if not self.qtpaths:
+ self.qtpaths = which("qtpaths6")
+
def _determine_defaults_and_check(self):
if not self.cmake:
self.cmake = which("cmake")
@@ -348,45 +354,28 @@ class DistUtilsCommandMixin(object):
log.error(f"'{self.cmake}' does not exist.")
return False
- if not self.qtpaths:
- self.qtpaths = which("qtpaths")
- if not self.qtpaths:
- self.qtpaths = find_executable("qtpaths6")
-
+ # Enforce usage of qmake in QtInfo if it was given explicitly.
if self.qmake:
self.has_qmake_option = True
- else:
- self.qmake = which("qmake")
- if not self.qmake:
- self.qmake = find_executable("qmake6")
- if not self.qmake:
- self.qmake = find_executable("qmake-qt5")
+ # If no option was given explicitly, prefer to find qtpaths
+ # in PATH.
+ if not self.qmake and not self.qtpaths:
+ self._find_qtpaths_in_path()
+
+ # If no tool was specified and qtpaths was not found in PATH,
+ # ask to provide a path to qtpaths.
if not self.qtpaths and not self.qmake:
log.error("No value provided to --qtpaths option. Please provide one to find Qt.")
return False
- # Derive tool path from the option that is not empty.
- if not self.qmake:
- base_dir = Path(self.qtpaths).parent
- self.qmake = os.fspath(base_dir / "qmake")
- if not os.path.exists(self.qmake):
- self.qmake = os.fspath(base_dir / "qmake6")
- if not os.path.exists(self.qmake):
- self.qmake = os.fspath(base_dir / "qmake-qt5")
-
- if not self.qtpaths:
- base_dir = Path(self.qmake).parent
- self.qtpaths = os.fspath(base_dir / "qtpaths")
- if not os.path.exists(self.qtpaths):
- self.qtpaths = os.fspath(base_dir / "qtpaths6")
-
- if not os.path.exists(self.qtpaths):
- log.error(f"Provided '{self.qtpaths}' path does not exist.")
+ # Validate that the given tool path exists.
+ if self.qtpaths and not os.path.exists(self.qtpaths):
+ log.error(f"The specified qtpaths path '{self.qtpaths}' does not exist.")
return False
- if not os.path.exists(self.qmake):
- log.error(f"Provided '{self.qmake}' path does not exist.")
+ if self.qmake and not os.path.exists(self.qmake):
+ log.error(f"The specified qmake path '{self.qmake}' does not exist.")
return False
if not self.make_spec:
diff --git a/build_scripts/qtinfo.py b/build_scripts/qtinfo.py
index 94d216fb9..749342679 100644
--- a/build_scripts/qtinfo.py
+++ b/build_scripts/qtinfo.py
@@ -97,6 +97,10 @@ class QtInfo(object):
return self._qmake_command
@property
+ def qtpaths_command(self):
+ return self._qtpaths_command
+
+ @property
def version(self):
return self.get_property("QT_VERSION")