Skip to content
Permalink
Browse files

Fix build with newer sip versions

Fixes #19476
  • Loading branch information
nyalldawson committed Oct 23, 2018
1 parent 2fce570 commit 0fad3e5731b32680acab9a43b146c73f4e1dab6a
@@ -179,7 +179,7 @@ FILE(GLOB_RECURSE sip_files_core core/*.sip core/*.sip.in)
SET(SIP_EXTRA_FILES_DEPEND ${sip_files_core})
SET(SIP_EXTRA_OPTIONS ${PYQT_SIP_FLAGS} -g -o -a ${CMAKE_BINARY_DIR}/python/qgis.core.api)
IF((${SIP_VERSION_STR} VERSION_EQUAL 4.19.11) OR (${SIP_VERSION_STR} VERSION_GREATER 4.19.11))
SET(SIP_EXTRA_OPTIONS ${SIP_EXTRA_OPTIONS} -n sip)
SET(SIP_EXTRA_OPTIONS ${SIP_EXTRA_OPTIONS} -n PyQt5.sip)
ENDIF((${SIP_VERSION_STR} VERSION_EQUAL 4.19.11) OR (${SIP_VERSION_STR} VERSION_GREATER 4.19.11))
IF((${SIP_VERSION_STR} VERSION_EQUAL 4.18) OR (${SIP_VERSION_STR} VERSION_GREATER 4.18))
SET(SIP_EXTRA_OPTIONS ${SIP_EXTRA_OPTIONS} -y ${QGIS_PYTHON_OUTPUT_DIRECTORY}/_core.pyi)
@@ -203,7 +203,7 @@ IF (WITH_GUI)
SET(SIP_EXTRA_FILES_DEPEND ${sip_files_core} ${sip_files_gui})
SET(SIP_EXTRA_OPTIONS ${PYQT_SIP_FLAGS} -g -o -a ${CMAKE_BINARY_DIR}/python/qgis.gui.api)
IF((${SIP_VERSION_STR} VERSION_EQUAL 4.19.11) OR (${SIP_VERSION_STR} VERSION_GREATER 4.19.11))
SET(SIP_EXTRA_OPTIONS ${SIP_EXTRA_OPTIONS} -n sip)
SET(SIP_EXTRA_OPTIONS ${SIP_EXTRA_OPTIONS} -n PyQt5.sip)
ENDIF((${SIP_VERSION_STR} VERSION_EQUAL 4.19.11) OR (${SIP_VERSION_STR} VERSION_GREATER 4.19.11))
IF((${SIP_VERSION_STR} VERSION_EQUAL 4.18) OR (${SIP_VERSION_STR} VERSION_GREATER 4.18))
SET(SIP_EXTRA_OPTIONS ${SIP_EXTRA_OPTIONS} -y ${QGIS_PYTHON_OUTPUT_DIRECTORY}/_gui.pyi)
@@ -234,7 +234,7 @@ IF (WITH_3D)
SET(SIP_EXTRA_FILES_DEPEND ${sip_files_core} ${sip_files_3d})
SET(SIP_EXTRA_OPTIONS ${PYQT_SIP_FLAGS} -g -o -a ${CMAKE_BINARY_DIR}/python/qgis.qgis3d.api)
IF((${SIP_VERSION_STR} VERSION_EQUAL 4.19.11) OR (${SIP_VERSION_STR} VERSION_GREATER 4.19.11))
SET(SIP_EXTRA_OPTIONS ${SIP_EXTRA_OPTIONS} -n sip)
SET(SIP_EXTRA_OPTIONS ${SIP_EXTRA_OPTIONS} -n PyQt5.sip)
ENDIF((${SIP_VERSION_STR} VERSION_EQUAL 4.19.11) OR (${SIP_VERSION_STR} VERSION_GREATER 4.19.11))
IF((${SIP_VERSION_STR} VERSION_EQUAL 4.18) OR (${SIP_VERSION_STR} VERSION_GREATER 4.18))
SET(SIP_EXTRA_OPTIONS ${SIP_EXTRA_OPTIONS} -y ${QGIS_PYTHON_OUTPUT_DIRECTORY}/_qgis3d.pyi)
@@ -257,7 +257,7 @@ IF (WITH_SERVER AND WITH_SERVER_PLUGINS)
SET(SIP_EXTRA_FILES_DEPEND ${sip_files_core} ${sip_files_server})
SET(SIP_EXTRA_OPTIONS ${PYQT_SIP_FLAGS} -g -o -a ${CMAKE_BINARY_DIR}/python/qgis.server.api)
IF((${SIP_VERSION_STR} VERSION_EQUAL 4.19.11) OR (${SIP_VERSION_STR} VERSION_GREATER 4.19.11))
SET(SIP_EXTRA_OPTIONS ${SIP_EXTRA_OPTIONS} -n sip)
SET(SIP_EXTRA_OPTIONS ${SIP_EXTRA_OPTIONS} -n PyQt5.sip)
ENDIF((${SIP_VERSION_STR} VERSION_EQUAL 4.19.11) OR (${SIP_VERSION_STR} VERSION_GREATER 4.19.11))
IF((${SIP_VERSION_STR} VERSION_EQUAL 4.18) OR (${SIP_VERSION_STR} VERSION_GREATER 4.18))
SET(SIP_EXTRA_OPTIONS ${SIP_EXTRA_OPTIONS} -y ${QGIS_PYTHON_OUTPUT_DIRECTORY}/_server.pyi)
@@ -290,7 +290,7 @@ FILE(GLOB_RECURSE sip_files_analysis analysis/*.sip analysis/*.sip.in)
SET(SIP_EXTRA_FILES_DEPEND ${sip_files_core} ${sip_files_analysis})
SET(SIP_EXTRA_OPTIONS ${PYQT_SIP_FLAGS} -g -o -a ${CMAKE_BINARY_DIR}/python/qgis.analysis.api)
IF((${SIP_VERSION_STR} VERSION_EQUAL 4.19.11) OR (${SIP_VERSION_STR} VERSION_GREATER 4.19.11))
SET(SIP_EXTRA_OPTIONS ${SIP_EXTRA_OPTIONS} -n sip)
SET(SIP_EXTRA_OPTIONS ${SIP_EXTRA_OPTIONS} -n PyQt5.sip)
ENDIF((${SIP_VERSION_STR} VERSION_EQUAL 4.19.11) OR (${SIP_VERSION_STR} VERSION_GREATER 4.19.11))
IF((${SIP_VERSION_STR} VERSION_EQUAL 4.18) OR (${SIP_VERSION_STR} VERSION_GREATER 4.18))
SET(SIP_EXTRA_OPTIONS ${SIP_EXTRA_OPTIONS} -y ${QGIS_PYTHON_OUTPUT_DIRECTORY}/_analysis.pyi)
@@ -16,6 +16,7 @@ SET(PYQT_COMPAT_FILES
QtSvg.py
Qsci.py
Qt.py
sip.py
uic/__init__.py
uic/pyuic.py
uic/properties.py
@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-

"""
***************************************************************************
sip.py
---------------------
Date : October 2018
Copyright : (C) 2018 by Nyall Dawson
Email : nyall dot dawson at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""

__author__ = 'Nyall Dawson'
__date__ = 'October 2017'
__copyright__ = '(C) 2018, Nyall Dawson'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

try:
from PyQt5.sip import *
except ModuleNotFoundError:
from sip import *
@@ -27,10 +27,10 @@

import os
import math
import sip
import warnings

from qgis.PyQt import uic
from qgis.PyQt import sip
from qgis.PyQt.QtCore import pyqtSignal, QSize
from qgis.PyQt.QtWidgets import QDialog, QLabel, QComboBox

@@ -104,7 +104,7 @@ bool QgsPythonUtilsImpl::checkSystemImports()
runString( "sys.path = [" + newpaths.join( QStringLiteral( "," ) ) + "] + sys.path" );

// import SIP
if ( !runString( QStringLiteral( "import sip" ),
if ( !runString( QStringLiteral( "from qgis.PyQt import sip" ),
QObject::tr( "Couldn't load SIP module." ) + '\n' + QObject::tr( "Python support will be disabled." ) ) )
{
return false;
@@ -17,7 +17,7 @@

from qgis.testing import unittest, start_app
from qgis.core import metaEnumFromValue, metaEnumFromType, QgsTolerance, QgsMapLayer
import sip
from qgis.PyQt import sip

start_app()

@@ -13,7 +13,7 @@
__revision__ = '$Format:%H$'

import qgis # NOQA
import sip
from qgis.PyQt import sip
import tempfile
import shutil
import os
@@ -13,7 +13,7 @@
__revision__ = '$Format:%H$'

import qgis # NOQA
import sip
from qgis.PyQt import sip

from qgis.core import (QgsUnitTypes,
QgsLayout,
@@ -13,7 +13,7 @@
__revision__ = '$Format:%H$'

import qgis # NOQA
import sip
from qgis.PyQt import sip
import tempfile
import shutil
import os
@@ -13,7 +13,7 @@
__revision__ = '$Format:%H$'

import qgis # NOQA
import sip
from qgis.PyQt import sip
import tempfile
import shutil
import os
@@ -32,7 +32,7 @@

from qgis.testing import start_app, unittest

import sip
from qgis.PyQt import sip

start_app()

@@ -13,7 +13,7 @@
__revision__ = '$Format:%H$'

import qgis # NOQA
import sip
from qgis.PyQt import sip

from qgis.core import (QgsUnitTypes,
QgsLayout,
@@ -13,7 +13,7 @@
__revision__ = '$Format:%H$'

import qgis # NOQA
import sip
from qgis.PyQt import sip
from qgis.core import (QgsProject,
QgsLayout,
QgsUnitTypes,
@@ -26,7 +26,7 @@
from qgis.PyQt.QtCore import QVariant, pyqtSignal, QCoreApplication
from time import sleep
from qgis.testing import start_app, unittest
import sip
from qgis.PyQt import sip
start_app()


@@ -15,7 +15,7 @@
from qgis.core import QgsMapLayerStore, QgsVectorLayer, QgsMapLayer
from qgis.testing import start_app, unittest
from qgis.PyQt.QtCore import QT_VERSION_STR
import sip
from qgis.PyQt import sip
from qgis.PyQt.QtTest import QSignalSpy
from time import sleep

@@ -33,7 +33,7 @@

from qgis.PyQt.QtTest import QSignalSpy
from qgis.PyQt.QtCore import QT_VERSION_STR, QTemporaryDir
import sip
from qgis.PyQt import sip

from qgis.testing import start_app, unittest
from utilities import (unitTestDataPath)

7 comments on commit 0fad3e5

@nirvn

This comment has been minimized.

Copy link
Contributor

@nirvn nirvn replied Oct 24, 2018

@nyalldawson , this broke python support when building on ubuntu 18.10. When launching QGIS, I get this error:

Couldn't load PyQGIS.
Python support will be disabled.


Traceback (most recent call last):
  File "", line 1, in 
  File "/home/webmaster/dev/cpp/bm-qt5/output/python/qgis/core/__init__.py", line 27, in 
    from qgis._core import *
ModuleNotFoundError: No module named 'PyQt5.sip'
@jef-n

This comment has been minimized.

Copy link
Member

@jef-n jef-n replied Oct 24, 2018

@nirvn You have to specify SIP_IMPORT=sip

@jef-n

This comment has been minimized.

Copy link
Member

@jef-n jef-n replied Oct 24, 2018

@nirvn see also #8295

@nirvn

This comment has been minimized.

Copy link
Contributor

@nirvn nirvn replied Oct 24, 2018

@jef-n , thanks, my system's SIP_IMPORT was wrongly set to PyQt5.sip. I've tried creating a new build directory and the initial cmake ../QGIS properly sets it to sip now.

@jef-n

This comment has been minimized.

Copy link
Member

@jef-n jef-n replied Oct 24, 2018

@nirvn well, the default is PyQt5.sip, because that's PyQt5's default. PyQt5 in debian is patched to use sip.

@nirvn

This comment has been minimized.

Copy link
Contributor

@nirvn nirvn replied Oct 24, 2018

@jef-n , OK; I'd expect us to fill the correct value based on the system within which a builder is creating a build directory via (c)cmake, whether it's PyQt5.sip or sip. I think it does so, since I did check that and our cmake scripts ended up selecting the right value to use there.

@jef-n

This comment has been minimized.

Copy link
Member

@jef-n jef-n replied Oct 24, 2018

@nirvn auto-detecting version in 4464089

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