Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix build with newer sip versions
Fixes #19476
  • Loading branch information
nyalldawson committed Oct 23, 2018
1 parent 2fce570 commit 0fad3e5
Show file tree
Hide file tree
Showing 16 changed files with 48 additions and 18 deletions.
10 changes: 5 additions & 5 deletions python/CMakeLists.txt
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions python/PyQt/CMakeLists.txt
Expand Up @@ -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
Expand Down
29 changes: 29 additions & 0 deletions python/PyQt/PyQt5/sip.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 *
2 changes: 1 addition & 1 deletion python/plugins/processing/gui/NumberInputPanel.py
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/python/qgspythonutilsimpl.cpp
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/src/python/test_core_additions.py
Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion tests/src/python/test_qgslayout.py
Expand Up @@ -13,7 +13,7 @@
__revision__ = '$Format:%H$'

import qgis # NOQA
import sip
from qgis.PyQt import sip
import tempfile
import shutil
import os
Expand Down
2 changes: 1 addition & 1 deletion tests/src/python/test_qgslayoutaligner.py
Expand Up @@ -13,7 +13,7 @@
__revision__ = '$Format:%H$'

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

from qgis.core import (QgsUnitTypes,
QgsLayout,
Expand Down
2 changes: 1 addition & 1 deletion tests/src/python/test_qgslayoutatlas.py
Expand Up @@ -13,7 +13,7 @@
__revision__ = '$Format:%H$'

import qgis # NOQA
import sip
from qgis.PyQt import sip
import tempfile
import shutil
import os
Expand Down
2 changes: 1 addition & 1 deletion tests/src/python/test_qgslayoutexporter.py
Expand Up @@ -13,7 +13,7 @@
__revision__ = '$Format:%H$'

import qgis # NOQA
import sip
from qgis.PyQt import sip
import tempfile
import shutil
import os
Expand Down
2 changes: 1 addition & 1 deletion tests/src/python/test_qgslayoutguides.py
Expand Up @@ -32,7 +32,7 @@

from qgis.testing import start_app, unittest

import sip
from qgis.PyQt import sip

start_app()

Expand Down
2 changes: 1 addition & 1 deletion tests/src/python/test_qgslayoutpagecollection.py
Expand Up @@ -13,7 +13,7 @@
__revision__ = '$Format:%H$'

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

from qgis.core import (QgsUnitTypes,
QgsLayout,
Expand Down
2 changes: 1 addition & 1 deletion tests/src/python/test_qgslayoutview.py
Expand Up @@ -13,7 +13,7 @@
__revision__ = '$Format:%H$'

import qgis # NOQA
import sip
from qgis.PyQt import sip
from qgis.core import (QgsProject,
QgsLayout,
QgsUnitTypes,
Expand Down
2 changes: 1 addition & 1 deletion tests/src/python/test_qgslocator.py
Expand Up @@ -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()


Expand Down
2 changes: 1 addition & 1 deletion tests/src/python/test_qgsmaplayerstore.py
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tests/src/python/test_qgsproject.py
Expand Up @@ -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)
Expand Down

7 comments on commit 0fad3e5

@nirvn
Copy link
Contributor

@nirvn nirvn commented on 0fad3e5 Oct 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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
Copy link
Member

@jef-n jef-n commented on 0fad3e5 Oct 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nirvn You have to specify SIP_IMPORT=sip

@jef-n
Copy link
Member

@jef-n jef-n commented on 0fad3e5 Oct 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nirvn see also #8295

@nirvn
Copy link
Contributor

@nirvn nirvn commented on 0fad3e5 Oct 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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
Copy link
Member

@jef-n jef-n commented on 0fad3e5 Oct 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@nirvn
Copy link
Contributor

@nirvn nirvn commented on 0fad3e5 Oct 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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
Copy link
Member

@jef-n jef-n commented on 0fad3e5 Oct 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nirvn auto-detecting version in 4464089

Please sign in to comment.