Fix FindPyQt5 cmake and python scripts

As written, the FindPyQt5.cmake and FindPyQt5.py scripts will succeed even if
PyQt5 is not installed. In FindPyQt5.cmake, we have PYQT5_FIND_REQUIRED rather
than PyQt5_FIND_REQUIRED, so the package is always treated as though it is
optional. In FindPyQt5.py, the script will succeed with a default location for
the sip directory, even if the PyQt5 directory is not located.

For some systems, if enough other dependencies are installed, the build can
get about halfway complete without the main PyQt5 dependency, and then fail
with a message like:

sip: Unable to find file "QtXml/QtXmlmod.sip"

I hit this building on Ubuntu, and there have been a few similar bug reports in
the past.
This commit is contained in:
Daniel Minor 2020-07-14 19:03:29 -04:00 committed by Nyall Dawson
parent 573ace14bf
commit 4009fa8e22
2 changed files with 6 additions and 4 deletions

View File

@ -47,13 +47,13 @@ ELSE(EXISTS PYQT5_VERSION)
ENDIF(pyqt_config)
IF(PYQT5_FOUND)
IF(NOT PYQT5_FIND_QUIETLY)
IF(NOT PyQt5_FIND_QUIETLY)
MESSAGE(STATUS "Found PyQt5 version: ${PYQT5_VERSION_STR}")
ENDIF(NOT PYQT5_FIND_QUIETLY)
ELSE(PYQT5_FOUND)
IF(PYQT5_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find Python")
ENDIF(PYQT5_FIND_REQUIRED)
IF(PyQt5_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find PyQt5")
ENDIF(PyQt5_FIND_REQUIRED)
ENDIF(PYQT5_FOUND)
ENDIF(EXISTS PYQT5_VERSION)

View File

@ -52,6 +52,8 @@ except ImportError:
if os.path.exists(os.path.join(p, "QtCore", "QtCoremod.sip")):
sip_dir = p
break
else:
sys.exit(1)
cfg = {
'pyqt_version': PyQt5.QtCore.PYQT_VERSION,
'pyqt_version_str': PyQt5.QtCore.PYQT_VERSION_STR,