Skip to content
Permalink
Browse files

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.
  • Loading branch information
dminor authored and nyalldawson committed Jul 15, 2020
1 parent 573ace1 commit 4009fa8e22bb8f763c5e0ef5fb616a92537746ca
Showing with 6 additions and 4 deletions.
  1. +4 −4 cmake/FindPyQt5.cmake
  2. +2 −0 cmake/FindPyQt5.py
@@ -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)
@@ -52,6 +52,8 @@
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,

0 comments on commit 4009fa8

Please sign in to comment.
You can’t perform that action at this time.