[Pythonmac-SIG] py2app fails to build PyQt5 apps anymore

jack.jansen at cwi.nl jack.jansen at cwi.nl
Wed Dec 22 18:36:36 EST 2021


Hmm, my guess is that it fails when it fails when Qt tries to access the window manager (the `QtWidgets.QApplication( argv )` call). But why it would fail when built with pyinstaller and not with py2app I have absolutely no clue…

Could it be that a new entitlement or something was added by Apple for Monterey, maybe for accessing the window manager, and py2app doesn’t know about this? Anyone (Ronald, probably) have any idea?

--
Jack Jansen, <Jack.Jansen at cwi.nl>, http://www.cwi.nl/~jack
If I can't dance I don't want to be part of your revolution -- Emma Goldman



> On 21 Dec 2021, at 12:46, Barry Scott <barry at barrys-emacs.org> wrote:
> 
> For a long time I have been happily building my App bundles using py2app.
> At some point that stopped working. I do not have a record of exactly
> when. Last time I saw everything work was Feb 2021.
> 
> I have reduced the problem to a simple test program and scripts to
> build and run the test code to show the issue.
> 
> As a comparison I have py2app and pyinstaller versions of the tests.
> The pyinstaller version works and the py2app version fails.
> 
> The code is on github here:
> 
> https://github.com/barry-scott/scm-workbench/tree/master/Source/Experiments
> 
> Run ./build-py2app.sh to build and run the py2app version.
> Run ./build-pyinstaller.sh to build and runt he pyinstaller version.
> 
> The scripts:
> 1. build a venv
> 2. run gui_test.py from the command line
> 3. build the app using py2app or pyinstaller
> 4. run the app.
> 
> I am using macOS 12.1 on Intel MacBook Pro (15-inch, 2016).
> Python 3.10.1 from python.org.
> 
> The gui_test.py code logs to ~/gui_test.log at key points.
> 
> Here is the source:
> 
> ----
> #!/usr/bin/env python
> import sys
> import os
> 
> log_filename = '%s/gui_test.log' % (os.environ['HOME'],)
> sys.stdout = open( log_filename, 'a' )
> sys.stderr = sys.stdout
> print('---- gui_test.py ----', flush=True)
> 
> from PyQt5 import QtCore, QtWidgets
> from PyQt5.QtWidgets import QMainWindow, QLabel, QGridLayout, QWidget
> from PyQt5.QtCore import QSize
> 
> class HelloWindow(QMainWindow): 
>    def __init__( self ):
>        super().__init__()
> 
>        if sys.maxsize > (2**31):
>            size_int_t = 64
>        else:
>            size_int_t = 32
> 
>        py_ver = '%d.%d-%d' % (sys.version_info.major, sys.version_info.minor, size_int_t)
> 
>        self.setMinimumSize( QSize(350, 100) )
>        self.setWindowTitle( 'GUI test - python %s' % (py_ver,) )
> 
>        self.setCentralWidget( QLabel( ' GUI test - python %s ' % (py_ver,), self ) )
> 
> def main( argv ):
>    print('QtWidgets.QApplication()', flush=True)
>    app = QtWidgets.QApplication( argv )
> 
>    print('HelloWindow()', flush=True)
>    main_win = HelloWindow()
> 
>    print('main_win.show()', flush=True)
>    main_win.show()
> 
>    print('app.exec_()', flush=True)
>    rc = app.exec_()
> 
>    print('rc', rc, flush=True)
>    return rc
> 
> if __name__ == "__main__":
>    sys.exit( main( sys.argv ) )
> ----
> 
> On a successful run the log shows:
> 
> ---- gui_test.py ----
> QtWidgets.QApplication()
> HelloWindow()
> main_win.show()
> app.exec_()
> rc 0
> 
> When it fails it shows:
> 
> ---- gui_test.py ----
> QtWidgets.QApplication()
> 
> Here is the problem report that is generated:
> 
> REGION TYPE                        SIZE    COUNT (non-coalesced) 
> ===========                     =======  ======= 
> Activity Tracing                   256K        1 
> Kernel Alloc Once                    8K        1 
> MALLOC                           192.1M       30 
> MALLOC guard page                   16K        4 
> MALLOC_LARGE (reserved)            128K        1         reserved VM address space (unallocated)
> MALLOC_NANO (reserved)           384.0M        1         reserved VM address space (unallocated)
> STACK GUARD                       56.0M        3 
> Stack                             9232K        3 
> VM_ALLOCATE                       6156K        9 
> __DATA                            17.4M      265 
> __DATA_CONST                      10.9M      152 
> __DATA_DIRTY                       492K       86 
> __FONT_DATA                          4K        1 
> __LINKEDIT                       651.4M       26 
> __OBJC_RO                         81.8M        1 
> __OBJC_RW                         3136K        2 
> __TEXT                           205.4M      280 
> __UNICODE                          588K        1 
> dyld private memory               1024K        1 
> mapped file                       28.3M        2 
> shared memory                      592K        7 
> ===========                     =======  ======= 
> TOTAL                              1.6G      877 
> TOTAL, minus reserved VM space     1.2G      877 
> 
> 
> 
> -----------
> Full Report
> -----------
> 
> {"app_name":"gui_test","timestamp":"2021-12-21 11:43:08.00 +0000","app_version":"1.2.3","slice_uuid":"abecb05c-e91d-336e-81d6-4a467d071ee8","build_version":"1.2.3","platform":1,"bundleID":"gui_test","share_with_app_devs":0,"is_first_party":0,"bug_type":"309","os_version":"macOS 12.1 (21C52)","incident_id":"6A9D2853-2DEE-4C33-B374-1017075B2772","name":"gui_test"}
> {
>  "uptime" : 110000,
>  "procLaunch" : "2021-12-21 11:43:08.5661 +0000",
>  "procRole" : "Background",
>  "version" : 2,
>  "userID" : 501,
>  "deployVersion" : 210,
>  "modelCode" : "MacBookPro13,3",
>  "procStartAbsTime" : 113541505574837,
>  "coalitionID" : 515116,
>  "osVersion" : {
>    "train" : "macOS 12.1",
>    "build" : "21C52",
>    "releaseType" : "User"
>  },
>  "captureTime" : "2021-12-21 11:43:08.7600 +0000",
>  "incident" : "6A9D2853-2DEE-4C33-B374-1017075B2772",
>  "bug_type" : "309",
>  "pid" : 17474,
>  "procExitAbsTime" : 113541698791884,
>  "cpuType" : "X86-64",
>  "procName" : "gui_test",
>  "procPath" : "\/Users\/USER\/*\/gui_test.app\/Contents\/MacOS\/gui_test",
>  "bundleInfo" : {"CFBundleShortVersionString":"1.2.3","CFBundleVersion":"1.2.3","CFBundleIdentifier":"gui_test"},
>  "storeInfo" : {"deviceIdentifierForVendor":"58974244-6450-5437-A094-9481191631E1","thirdParty":true},
>  "parentProc" : "launchd",
>  "parentPid" : 1,
>  "coalitionName" : "gui_test",
>  "crashReporterKey" : "0947E507-B37B-E5B7-D29C-312263801DC3",
>  "wakeTime" : 4348,
>  "bridgeVersion" : {"build":"14Y908","train":"3.0"},
>  "sleepWakeUUID" : "BEA2B543-B8F3-412A-9B1A-07DB3F35A685",
>  "sip" : "enabled",
>  "isCorpse" : 1,
>  "exception" : {"codes":"0x0000000000000000, 0x0000000000000000","rawCodes":[0,0],"type":"EXC_CRASH","signal":"SIGABRT"},
>  "asi" : {"libsystem_c.dylib":["abort() called"]},
>  "extMods" : {"caller":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"system":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"targeted":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"warnings":0},
>  "faultingThread" : 0,
>  "threads" : [{"triggered":true,"id":2520143,"threadState":{"r13":{"value":4432803416,"symbolLocation":0,"symbol":"QListData::shared_null"},"rax":{"value":0},"rflags":{"value":582},"cpu":{"value":0},"r14":{"value":6},"rsi":{"value":6},"r8":{"value":140704637244760,"symbolLocation":456,"symbol":"__sFX"},"cr2":{"value":4372226054},"rdx":{"value":0},"r10":{"value":0},"r9":{"value":0},"r15":{"value":22},"rbx":{"value":4570531328,"symbolLocation":0,"symbol":"_main_thread"},"trap":{"value":133},"err":{"value":33554760},"r11":{"value":582},"rip":{"value":140703537946898,"matchesCrashFrame":1},"rbp":{"value":140701977840384},"rsp":{"value":140701977840344},"r12":{"value":259},"rcx":{"value":140701977840344},"flavor":"x86_THREAD_STATE","rdi":{"value":259}},"queue":"com.apple.main-thread","frames":[{"imageOffset":28946,"symbol":"__pthread_kill","symbolLocation":10,"imageIndex":0},{"imageOffset":25108,"symbol":"pthread_kill","symbolLocation":263,"imageIndex":1},{"imageOffset":531728,"!
> symbol":"
> abort","symbolLocation":123,"imageIndex":2},{"imageOffset":99625,"symbol":"qt_message_fatal(QtMsgType, QMessageLogContext const&, QString const&)","symbolLocation":9,"imageIndex":3},{"imageOffset":105588,"symbol":"QMessageLogger::fatal(char const*, ...) const","symbolLocation":202,"imageIndex":3},{"imageOffset":230361,"symbol":"QGuiApplicationPrivate::createPlatformIntegration()","symbolLocation":7193,"imageIndex":4},{"imageOffset":230395,"symbol":"QGuiApplicationPrivate::createEventDispatcher()","symbolLocation":27,"imageIndex":4},{"imageOffset":2064815,"symbol":"QCoreApplicationPrivate::init()","symbolLocation":1599,"imageIndex":3},{"imageOffset":207705,"symbol":"QGuiApplicationPrivate::init()","symbolLocation":57,"imageIndex":4},{"imageOffset":43738,"symbol":"QApplicationPrivate::init()","symbolLocation":26,"imageIndex":5},{"imageOffset":1357272,"symbol":"init_type_QApplication(_sipSimpleWrapper*, _object*, _object*, _object**, _object**, _object**)","symbolLocation":168!
> ,"imageIn
> dex":6},{"imageOffset":26459,"symbol":"sipSimpleWrapper_init","symbolLocation":203,"imageIndex":7},{"imageOffset":1121781,"symbol":"type_call","symbolLocation":325,"imageIndex":8},{"imageOffset":552935,"symbol":"_PyObject_MakeTpCall","symbolLocation":135,"imageIndex":8},{"imageOffset":1868333,"symbol":"call_function","symbolLocation":365,"imageIndex":8},{"imageOffset":1833294,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":28702,"imageIndex":8},{"imageOffset":1798114,"symbol":"_PyEval_Vector","symbolLocation":402,"imageIndex":8},{"imageOffset":1868143,"symbol":"call_function","symbolLocation":175,"imageIndex":8},{"imageOffset":1824309,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":19717,"imageIndex":8},{"imageOffset":1798114,"symbol":"_PyEval_Vector","symbolLocation":402,"imageIndex":8},{"imageOffset":1774299,"symbol":"builtin_exec","symbolLocation":331,"imageIndex":8},{"imageOffset":973990,"symbol":"cfunction_vectorcall_FASTCALL","symbolLocation":86,"imageIndex"!
> :8},{"ima
> geOffset":1868143,"symbol":"call_function","symbolLocation":175,"imageIndex":8},{"imageOffset":1824309,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":19717,"imageIndex":8},{"imageOffset":1798114,"symbol":"_PyEval_Vector","symbolLocation":402,"imageIndex":8},{"imageOffset":1868143,"symbol":"call_function","symbolLocation":175,"imageIndex":8},{"imageOffset":1824309,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":19717,"imageIndex":8},{"imageOffset":1798114,"symbol":"_PyEval_Vector","symbolLocation":402,"imageIndex":8},{"imageOffset":2278253,"symbol":"pyrun_file","symbolLocation":333,"imageIndex":8},{"imageOffset":2276141,"symbol":"_PyRun_SimpleFileObject","symbolLocation":365,"imageIndex":8},{"imageOffset":2291149,"symbol":"PyRun_SimpleFileExFlags","symbolLocation":109,"imageIndex":8},{"imageOffset":20165,"symbol":"py2app_main","symbolLocation":5481,"imageIndex":9},{"imageOffset":13143,"symbol":"main","symbolLocation":257,"imageIndex":9},{"imageOffset":21758,"symbo!
> l":"start
> ","symbolLocation":462,"imageIndex":10}]},{"id":2520154,"frames":[{"imageOffset":8172,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":1}]},{"id":2520155,"frames":[{"imageOffset":8172,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":1}]}],
>  "usedImages" : [
>  {
>    "source" : "P",
>    "arch" : "x86_64",
>    "base" : 140703537917952,
>    "size" : 225280,
>    "uuid" : "5aa1e5be-b5b8-3a02-9885-a8c99e0ca378",
>    "path" : "\/usr\/lib\/system\/libsystem_kernel.dylib",
>    "name" : "libsystem_kernel.dylib"
>  },
>  {
>    "source" : "P",
>    "arch" : "x86_64",
>    "base" : 140703538143232,
>    "size" : 49152,
>    "uuid" : "6c7561b4-4b92-3f45-921e-abe669299844",
>    "path" : "\/usr\/lib\/system\/libsystem_pthread.dylib",
>    "name" : "libsystem_pthread.dylib"
>  },
>  {
>    "source" : "P",
>    "arch" : "x86_64",
>    "base" : 140703536902144,
>    "size" : 561152,
>    "uuid" : "e58814cc-dcb7-35a5-badc-e367ed3ac207",
>    "path" : "\/usr\/lib\/system\/libsystem_c.dylib",
>    "name" : "libsystem_c.dylib"
>  },
>  {
>    "source" : "P",
>    "arch" : "x86_64",
>    "base" : 4427026432,
>    "size" : 5705728,
>    "uuid" : "c723812a-f7a5-3001-98d5-e60e8daa6ffb",
>    "path" : "\/Users\/USER\/*\/gui_test.app\/Contents\/Resources\/lib\/python3.10\/PyQt5\/Qt5\/lib\/QtCore.framework\/Versions\/5\/QtCore",
>    "name" : "QtCore"
>  },
>  {
>    "source" : "P",
>    "arch" : "x86_64",
>    "base" : 4446490624,
>    "size" : 5152768,
>    "uuid" : "cbcec35a-ee54-354f-9c2b-188ac6b2790d",
>    "path" : "\/Users\/USER\/*\/gui_test.app\/Contents\/Resources\/lib\/python3.10\/PyQt5\/Qt5\/lib\/QtGui.framework\/Versions\/5\/QtGui",
>    "name" : "QtGui"
>  },
>  {
>    "source" : "P",
>    "arch" : "x86_64",
>    "base" : 4439920640,
>    "size" : 4485120,
>    "uuid" : "b432d666-dcab-320a-8496-78a67f554c0e",
>    "path" : "\/Users\/USER\/*\/gui_test.app\/Contents\/Resources\/lib\/python3.10\/PyQt5\/Qt5\/lib\/QtWidgets.framework\/Versions\/5\/QtWidgets",
>    "name" : "QtWidgets"
>  },
>  {
>    "source" : "P",
>    "arch" : "x86_64",
>    "base" : 4434120704,
>    "size" : 2932736,
>    "uuid" : "47b40141-df86-3d2f-98d5-ee16cb313cd6",
>    "path" : "\/Users\/USER\/*\/gui_test.app\/Contents\/Resources\/lib\/python3.10\/PyQt5\/QtWidgets.abi3.so",
>    "name" : "QtWidgets.abi3.so"
>  },
>  {
>    "source" : "P",
>    "arch" : "x86_64",
>    "base" : 4408209408,
>    "size" : 98304,
>    "uuid" : "62f78d75-6251-3b27-a4b3-a3247d07abe8",
>    "path" : "\/Users\/USER\/*\/gui_test.app\/Contents\/Resources\/lib\/python3.10\/PyQt5\/sip.cpython-310-darwin.so",
>    "name" : "sip.cpython-310-darwin.so"
>  },
>  {
>    "source" : "P",
>    "arch" : "x86_64",
>    "base" : 4411924480,
>    "CFBundleShortVersionString" : "3.10.1, (c) 2001-2021 Python Software Foundation.",
>    "CFBundleIdentifier" : "org.python.python",
>    "size" : 3637248,
>    "uuid" : "1071a8dd-3e3d-3958-95bf-ba33f1f82be5",
>    "path" : "\/Users\/USER\/*\/gui_test.app\/Contents\/Frameworks\/Python.framework\/Versions\/3.10\/Python",
>    "name" : "Python",
>    "CFBundleVersion" : "3.10.1"
>  },
>  {
>    "source" : "P",
>    "arch" : "x86_64",
>    "base" : 4370935808,
>    "CFBundleShortVersionString" : "1.2.3",
>    "CFBundleIdentifier" : "gui_test",
>    "size" : 32768,
>    "uuid" : "abecb05c-e91d-336e-81d6-4a467d071ee8",
>    "path" : "\/Users\/USER\/*\/gui_test.app\/Contents\/MacOS\/gui_test",
>    "name" : "gui_test",
>    "CFBundleVersion" : "1.2.3"
>  },
>  {
>    "source" : "P",
>    "arch" : "x86_64",
>    "base" : 4570005504,
>    "size" : 442368,
>    "uuid" : "cef5a27a-d50b-3020-af03-1734b19bc8c5",
>    "path" : "\/usr\/lib\/dyld",
>    "name" : "dyld"
>  }
> ],
>  "sharedCache" : {
>  "base" : 140703534915584,
>  "size" : 15216738304,
>  "uuid" : "40432a03-88d3-305f-9c0c-e7549e71d927"
> },
>  "vmSummary" : "ReadOnly portion of Libraries: Total=856.8M resident=0K(0%) swapped_out_or_unallocated=856.8M(100%)\nWritable regions: Total=591.6M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=591.6M(100%)\n\n                                VIRTUAL   REGION \nREGION TYPE                        SIZE    COUNT (non-coalesced) \n===========                     =======  ======= \nActivity Tracing                   256K        1 \nKernel Alloc Once                    8K        1 \nMALLOC                           192.1M       30 \nMALLOC guard page                   16K        4 \nMALLOC_LARGE (reserved)            128K        1         reserved VM address space (unallocated)\nMALLOC_NANO (reserved)           384.0M        1         reserved VM address space (unallocated)\nSTACK GUARD                       56.0M        3 \nStack                             9232K        3 \nVM_ALLOCATE                       6156K        9 \n__DATA                            17.4M !
>      265 
> \n__DATA_CONST                      10.9M      152 \n__DATA_DIRTY                       492K       86 \n__FONT_DATA                          4K        1 \n__LINKEDIT                       651.4M       26 \n__OBJC_RO                         81.8M        1 \n__OBJC_RW                         3136K        2 \n__TEXT                           205.4M      280 \n__UNICODE                          588K        1 \ndyld private memory               1024K        1 \nmapped file                       28.3M        2 \nshared memory                      592K        7 \n===========                     =======  ======= \nTOTAL                              1.6G      877 \nTOTAL, minus reserved VM space     1.2G      877 \n",
>  "legacyInfo" : {
>  "threadTriggered" : {
>    "queue" : "com.apple.main-thread"
>  }
> },
>  "trialInfo" : {
>  "rollouts" : [
>    {
>      "rolloutId" : "5ffde50ce2aacd000d47a95f",
>      "factorPackIds" : {
> 
>      },
>      "deploymentId" : 240000090
>    },
>    {
>      "rolloutId" : "5fc94383418129005b4e9ae0",
>      "factorPackIds" : {
> 
>      },
>      "deploymentId" : 240000185
>    },
>    {
>      "rolloutId" : "602ad4dac86151000cf27e46",
>      "factorPackIds" : {
>        "SIRI_DICTATION_ASSETS" : "6193d03f2171a2330e561dfc"
>      },
>      "deploymentId" : 240000290
>    },
>    {
>      "rolloutId" : "60da5e84ab0ca017dace9abf",
>      "factorPackIds" : {
> 
>      },
>      "deploymentId" : 240000008
>    },
>    {
>      "rolloutId" : "607844aa04477260f58a8077",
>      "factorPackIds" : {
>        "SIRI_MORPHUN_ASSETS" : "6103050cbfe6dc472e1c982a"
>      },
>      "deploymentId" : 240000066
>    },
>    {
>      "rolloutId" : "601d9415f79519000ccd4b69",
>      "factorPackIds" : {
>        "SIRI_TEXT_TO_SPEECH" : "6194416f2171a2330e561f05"
>      },
>      "deploymentId" : 240000355
>    }
>  ],
>  "experiments" : [
> 
>  ]
> }
> }
> 
> Model: MacBookPro13,3, BootROM 447.60.3.0.0, 4 processors, Quad-Core Intel Core i7, 2.6 GHz, 16 GB, SMC 2.38f12
> Graphics: Intel HD Graphics 530, Intel HD Graphics 530, Built-In
> Graphics: Radeon Pro 450, AMD Radeon Pro 450, PCIe, 2 GB
> Display: DELL 2408WFP, 1920 x 1200 (WUXGA - Widescreen Ultra eXtended Graphics Array), Main, MirrorOff, Online
> Memory Module: BANK 0/DIMM0, 8 GB, LPDDR3, 2133 MHz, 0x802C, 0x4D5435324C31473332443450472D30393320
> Memory Module: BANK 1/DIMM0, 8 GB, LPDDR3, 2133 MHz, 0x802C, 0x4D5435324C31473332443450472D30393320
> AirPort: spairport_wireless_card_type_wifi (0x14E4, 0x15A), Broadcom BCM43xx 1.0 (7.77.111.1 AirPortDriverBrcmNIC-1710.3)
> Bluetooth: Version (null), 0 services, 0 devices, 0 incoming serial ports
> Network Service: USB 10/100/1000 LAN, Ethernet, en7
> USB Device: Anker USB-C Hub Device
> USB Device: USB3.0 Card Reader
> USB Device: USB 10/100/1000 LAN
> USB Device: USB30Bus
> USB Device: Anker USB-C Hub Device
> USB Device: hub_device
> USB Device: USB Keyboard
> USB Device: hub_device
> USB Device: Microsoft USB Optical Mouse
> USB Device: Flash Card Reader
> USB Device: Anker
> USB Device: Apple T1 Controller
> Thunderbolt Bus: MacBook Pro, Apple Inc., 41.5
> Thunderbolt Bus: MacBook Pro, Apple Inc., 41.5
> 
> 
> Barry
> 
> _______________________________________________
> Pythonmac-SIG maillist  -  Pythonmac-SIG at python.org
> https://mail.python.org/mailman/listinfo/pythonmac-sig
> unsubscribe: https://mail.python.org/mailman/options/Pythonmac-SIG

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/pythonmac-sig/attachments/20211223/d4a19425/attachment-0001.html>


More information about the Pythonmac-SIG mailing list