Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Building PySide2 against non-gui Qt

Building PySide2 against non-gui Qt

Scheduled Pinned Locked Moved Solved Qt for Python
5 Posts 4 Posters 676 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • snkaupeS Offline
    snkaupeS Offline
    snkaupe
    wrote on last edited by snkaupe
    #1

    Hello there!

    I'm trying to build PySide2/Shiboken2 against a minimized Qt installation, that is, a Qt installation that eschews all modules not necessary for our purposes, which are basically all GUI modules.

    However, when I try to run the setup.py script from PySide's Git repo, I always end up with the following error message:

    $ python3 setup.py build --qmake=/path/to/my/qmake --build-tests --ignore-git --parallel=8 --skip-modules=Gui,Declarative,Widgets,Location,Sensors,GraphicalEffects,QuickControls,WebSockets,QuickControls2,Qml,UiTools,Help,OpenGL,OpenGLFunctions,QuickWidgets,Svg,Quick,X11Extras,Test,Sql,PrintSupport
    Project ERROR: Unknown module(s) in QT: gui
    Traceback (most recent call last):
      File "setup.py", line 286, in <module>
        from build_scripts.main import get_package_version, check_allowed_python_version
      File "/home/<user>/Projekte/<client>/pyside-setup/build_scripts/main.py", line 289, in <module>
        qtinfo = QtInfo(QMAKE_COMMAND)
      File "/home/<user>/Projekte/<client>/pyside-setup/build_scripts/qtinfo.py", line 61, in __init__
        self._init_properties()
      File "/home/<user>/Projekte/<client>/pyside-setup/build_scripts/qtinfo.py", line 199, in _init_properties
        self._get_other_properties()
      File "/home/<user>/Projekte/<client>/pyside-setup/build_scripts/qtinfo.py", line 184, in _get_other_properties
        self._get_qmake_mkspecs_variables()
      File "/home/<user>/Projekte/<client>/pyside-setup/build_scripts/qtinfo.py", line 208, in _get_qmake_mkspecs_variables
        lines = [s.strip() for s in qmake_output.splitlines()]
    AttributeError: 'NoneType' object has no attribute 'splitlines'
    

    The same message appears when I try to build a different project that makes no use of GUI components and disables the GUI module in it's QMake project file using QT -= gui. Yet, somehow, QMake seems to be looking for it, if I understand the error message and my earlier Google results correctly.

    I'm building on Fedora 31, Qt 5.14.1 was build on the same machine, PySide 2 version checked out from repo is also 5.14.1. There are no spaces or similar in the path to the QMake installation (which, due to us using Conan as a package manager, is /home/<user>/.conan/data/qt/5.14.1/<client>/stable/package/<package-hash>/).

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      I am not sure it is currently supported. I'd recommend bringing that question to the PySide mailing list. You'll find there PySide2 developers/maintainers. This forum is more user oriented.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • CristianMaureiraC Offline
        CristianMaureiraC Offline
        CristianMaureira
        wrote on last edited by
        #3

        This is the bit it's failing:

            def _get_qmake_mkspecs_variables(self):                                                            
                # Create empty temporary qmake project file.                                                   
                temp_file_name = 'qmake_fake_empty_project.txt'                                                
                open(temp_file_name, 'a').close()                                                              
                                                                                                               
                # Query qmake for all of its mkspecs variables.                                                
                qmake_output = self._get_qmake_output(['-E', temp_file_name])                                  
                lines = [s.strip() for s in qmake_output.splitlines()]  
        

        That means calling qmake failed on the fake_empty_project
        Can you maybe share the whole output of the build process? Then we can check if something is wrong with the Qt detection.

        1 Reply Last reply
        0
        • CristianMaureiraC Offline
          CristianMaureiraC Offline
          CristianMaureira
          wrote on last edited by
          #4

          Quick update, we continued the discussion on the PySide2 Gitter room, and since QtSQL has dependencies with QtWidgets, OP will try to have a local qtbase without QtSQL and hence without the graphical dependencies, because QtGui was not present in the installation.

          The qmake step that produced the error is that we create an empty .txt file to use qmake -E empty.txt and get information from the Qt installation and that command was complaining that GUI was not found.

          1 Reply Last reply
          1
          • snkaupeS Offline
            snkaupeS Offline
            snkaupe
            wrote on last edited by snkaupe
            #5

            I've been working on this and actually got Shiboken and PySide to build, though I could only build with the Core, Xml and Network modules included (including any of the other modules we depend upon in our main application would lead to error messages about QtGui or QtWidgets not being found by CMake). Haven't testet them with our bindings, yet, as we seem to pull QtGui into them at some subproject.

            That said, I needed to patch the pyside2-tools project. As it turns out, pylupdate includes qapplication.h and qmessagebox.h in metatranslator.cpp - to display a message box in case of an error (using a global variable called qApp that I couldn't trace down to decide whether or not to use the message box or stdout).

            I'll mark this as resolved as my original problem has been fixed. Thanks again to all who helped!

            EDIT: For the record, these are my changes in the pyside2-tools subrepo:

            diff --git a/CMakeLists.txt b/CMakeLists.txt
            index ce65750..179ce23 100644
            --- a/CMakeLists.txt
            +++ b/CMakeLists.txt
            @@ -55,12 +55,14 @@ else()
                 set(DESIGNER_PATH "${TOOLS_PATH}/designer${EXE_EXT}")
             endif()
             
            -install(FILES "${UIC_PATH}"
            -        DESTINATION bin
            -        PERMISSIONS
            -        OWNER_EXECUTE OWNER_WRITE OWNER_READ
            -        GROUP_EXECUTE GROUP_READ
            -        WORLD_EXECUTE WORLD_READ)
            +if (EXISTS ${UIC_PATH})
            +    install(FILES "${UIC_PATH}"
            +            DESTINATION bin
            +            PERMISSIONS
            +            OWNER_EXECUTE OWNER_WRITE OWNER_READ
            +            GROUP_EXECUTE GROUP_READ
            +            WORLD_EXECUTE WORLD_READ)
            +endif()
             
             install(FILES "${RCC_PATH}"
                     DESTINATION bin
            diff --git a/pylupdate/CMakeLists.txt b/pylupdate/CMakeLists.txt
            index a46608c..3f67fe7 100644
            --- a/pylupdate/CMakeLists.txt
            +++ b/pylupdate/CMakeLists.txt
            @@ -12,9 +12,7 @@ translator.cpp
             )
             
             find_package(Qt5Core)
            -find_package(Qt5Gui)
             find_package(Qt5Xml)
            -find_package(Qt5Widgets)
             
             set(lupdate_MOC_HEADERS translator.h)
             qt5_wrap_cpp(lupdate_MOC_OUTFILES ${lupdate_MOC_HEADERS})
            @@ -24,15 +22,11 @@ include_directories(pyside2-lupdate
                                 ${CMAKE_CURRENT_SOURCE_DIR}
                                 ${Qt5Xml_INCLUDE_DIRS}
                                 ${Qt5Core_INCLUDE_DIRS}
            -                    ${Qt5Gui_INCLUDE_DIRS}
            -                    ${Qt5Widgets_INCLUDE_DIRS}
                                 )
             
             target_link_libraries(pyside2-lupdate
                                   ${Qt5Core_LIBRARIES}
                                   ${Qt5Xml_LIBRARIES}
            -                      ${Qt5Gui_LIBRARIES}
            -                      ${Qt5Widgets_LIBRARIES}
                                   )
             
             install(TARGETS pyside2-lupdate RUNTIME DESTINATION bin)
            diff --git a/pylupdate/metatranslator.cpp b/pylupdate/metatranslator.cpp
            index 8a8ac8e..2588895 100644
            --- a/pylupdate/metatranslator.cpp
            +++ b/pylupdate/metatranslator.cpp
            @@ -25,10 +25,8 @@
             
             #include "metatranslator.h"
             
            -#include <qapplication.h>
             #include <qbytearray.h>
             #include <qfile.h>
            -#include <qmessagebox.h>
             #include <qtextcodec.h>
             #include <qtextstream.h>
             #include <qxml.h>
            @@ -204,11 +202,7 @@ bool TsHandler::fatalError( const QXmlParseException& exception )
                     const QString msg = QString::asprintf( "Parse error at line %d, column %d (%s).",
                                  exception.lineNumber(), exception.columnNumber(),
                                  exception.message().toLatin1().data() );
            -        if ( qApp == 0 )
            -            fprintf( stderr, "XML error: %s\n", msg.toLatin1().data() );
            -        else
            -            QMessageBox::information(0,
            -                                      QObject::tr("Qt Linguist"), msg );
            +        fprintf( stderr, "XML error: %s\n", msg.toLatin1().data() );
                 }
                 return false;
             }
            
            1 Reply Last reply
            1

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved