Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proprietary codec support with alternative macOS/Linux PyQt packages #4127

Open
The-Compiler opened this issue Aug 11, 2018 · 7 comments
Open
Labels
component: infrastructure Issues related to development scripts, CI, servers, etc. os: macOS Issues which only happen on macOS. priority: 2 - low Issues which are currently not very important.

Comments

@The-Compiler
Copy link
Member

The-Compiler commented Aug 11, 2018

build_release.py should have the possibility to use Homebrew's (or possibly another system-wide) PyQt instead of the one from PyPI.

At least when the stars align properly during a release*, this would allow to release builds with proprietary codec supports for macOS.

* meaning Homebrew does have everything in the proper versions

@The-Compiler The-Compiler added component: infrastructure Issues related to development scripts, CI, servers, etc. priority: 2 - low Issues which are currently not very important. os: macOS Issues which only happen on macOS. labels Aug 11, 2018
@The-Compiler The-Compiler changed the title Make it possible to build dmg with Homebrew's PyQt Proprietary codec support with alternative macOS/Linux PyQt packages Aug 12, 2020
@The-Compiler
Copy link
Member Author

Additionally, I wonder if we could use pyqt-bundle to build a Linux wheel which contains a Qt build from e.g. Debian sid packages. That'd allow for proprietary codec support but still be installable easily on older Ubuntu/Debian versions.

Unlikely to actually work though, as probably some other libraries (ICU?) had an incompatible upgrade in the meantime...

@tidux
Copy link

tidux commented Jan 10, 2021

Is there a licensing problem with just shipping bundled Qt with the codecs? That seems to be the most straightforward option.

@The-Compiler
Copy link
Member Author

Qt itself doesn't ship them - and as far as I can tell, yes, there's probably a reason why they are called proprietary.

@ktprograms
Copy link
Contributor

Here's what I have currently working on this.

diff --git a/scripts/dev/build_release.py b/scripts/dev/build_release.py
index c175c68a7..1a7d7114c 100755
--- a/scripts/dev/build_release.py
+++ b/scripts/dev/build_release.py
@@ -328,10 +328,10 @@ def build_mac(
 
     utils.print_title("Building .app via pyinstaller")
     call_tox('pyinstaller-64', '-r', debug=debug)
-    utils.print_title("Patching .app")
-    patch_mac_app()
-    utils.print_title("Re-signing .app")
-    sign_mac_app()
+    #utils.print_title("Patching .app")
+    #patch_mac_app()
+    #utils.print_title("Re-signing .app")
+    #sign_mac_app()
 
     dist_path = pathlib.Path("dist")
 
diff --git a/tox.ini b/tox.ini
index 8d33750f3..5baf104a0 100644
--- a/tox.ini
+++ b/tox.ini
@@ -158,8 +158,8 @@ passenv = APPDATA HOME PYINSTALLER_DEBUG
 deps =
     -r{toxinidir}/requirements.txt
     -r{toxinidir}/misc/requirements/requirements-pyinstaller.txt
-    -r{toxinidir}/misc/requirements/requirements-pyqt.txt
 commands =
+    {envpython} {toxinidir}/scripts/link_pyqt.py --tox {envdir}
     {envbindir}/pyinstaller --noconfirm misc/qutebrowser.spec
 
 [testenv:eslint]
@@ -231,3 +231,16 @@ deps =
     -r{toxinidir}/misc/requirements/requirements-pyinstaller.txt
 commands =
     {envpython} {toxinidir}/scripts/dev/build_release.py {posargs}
+
+[testenv:build-release-pyqtlink]
+basepython = {env:PYTHON:python3}
+passenv = *
+usedevelop = true
+deps =
+    -r{toxinidir}/requirements.txt
+    -r{toxinidir}/misc/requirements/requirements-tox.txt
+    -r{toxinidir}/misc/requirements/requirements-dev.txt
+    -r{toxinidir}/misc/requirements/requirements-pyinstaller.txt
+commands =
+    {envpython} {toxinidir}/scripts/link_pyqt.py --tox {envdir}
+    {envpython} {toxinidir}/scripts/dev/build_release.py {posargs}

It builds (with tox -e build-release-pyqtlink), but segfaults when running here:

library_path = pathlib.Path(QLibraryInfo.location(QLibraryInfo.LibrariesPath))

@ktprograms
Copy link
Contributor

macOS crash log:

-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Process:               qutebrowser [32316]
Path:                  /Users/USER/*/qutebrowser.app/Contents/MacOS/qutebrowser
Identifier:            org.qt-project.Qt.QtWebEngineCore
Version:               2.5.2 (2.5.2)
Code Type:             ARM-64 (Native)
Parent Process:        fish [4597]
Responsible:           Terminal [360]
User ID:               501

Date/Time:             2022-09-16 19:43:37.5485 +0800
OS Version:            macOS 12.4 (21F79)
Report Version:        12
Anonymous UUID:        13FBAFD6-11F5-43D0-92BC-2C09F16829C7


Time Awake Since Boot: 14000 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000008
Exception Codes:       0x0000000000000001, 0x0000000000000008
Exception Note:        EXC_CORPSE_NOTIFY

VM Region Info: 0x8 is not in any region.  Bytes before following region: 105553518919672
      REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      UNUSED SPACE AT START
--->  
      MALLOC_NANO (reserved)   600018000000-600020000000 [128.0M] rw-/rwx SM=NUL  ...(unallocated)

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib        	       0x1c0926d98 __pthread_kill + 8
1   libsystem_pthread.dylib       	       0x1c095bee0 pthread_kill + 288
2   libsystem_c.dylib             	       0x1c085e680 raise + 32
3   libsystem_platform.dylib      	       0x1c09734a4 _sigtramp + 56
4   ???                           	0xffff8001c09cbbf8 ???
5   CoreFoundation                	       0x1c09cbbf8 CFBundleCopyBundleURL + 24
6   QtCore                        	       0x1045aeba8 QLibraryInfo::location(QLibraryInfo::LibraryLocation) + 1280
7   QtCore                        	       0x1045aee60 QLibraryInfo::location(QLibraryInfo::LibraryLocation) + 1976
8   QtCore.abi3.so                	       0x103da3ca8 meth_QLibraryInfo_location(_object*, _object*) + 112
9   Python                        	       0x103039f78 cfunction_call + 96
10  Python                        	       0x102fe7aec _PyObject_MakeTpCall + 136
11  Python                        	       0x1030e2b60 call_function + 272
12  Python                        	       0x1030e02fc _PyEval_EvalFrameDefault + 43144
13  Python                        	       0x1030d481c _PyEval_Vector + 376
14  Python                        	       0x1030e2ad0 call_function + 128
15  Python                        	       0x1030e02fc _PyEval_EvalFrameDefault + 43144
16  Python                        	       0x1030d481c _PyEval_Vector + 376
17  Python                        	       0x1030e2ad0 call_function + 128
18  Python                        	       0x1030e03b0 _PyEval_EvalFrameDefault + 43324
19  Python                        	       0x1030d481c _PyEval_Vector + 376
20  Python                        	       0x1030e2ad0 call_function + 128
21  Python                        	       0x1030e0280 _PyEval_EvalFrameDefault + 43020
22  Python                        	       0x1030d481c _PyEval_Vector + 376
23  Python                        	       0x1030e2ad0 call_function + 128
24  Python                        	       0x1030e0280 _PyEval_EvalFrameDefault + 43020
25  Python                        	       0x1030d481c _PyEval_Vector + 376
26  Python                        	       0x102fe7d54 _PyObject_FastCallDictTstate + 96
27  Python                        	       0x10305e8d4 slot_tp_init + 196
28  Python                        	       0x1030568f8 type_call + 288
29  Python                        	       0x102fe7aec _PyObject_MakeTpCall + 136
30  Python                        	       0x1030e2b60 call_function + 272
31  Python                        	       0x1030e0324 _PyEval_EvalFrameDefault + 43184
32  Python                        	       0x1030d481c _PyEval_Vector + 376
33  Python                        	       0x1030e2ad0 call_function + 128
34  Python                        	       0x1030e02fc _PyEval_EvalFrameDefault + 43144
35  Python                        	       0x1030d481c _PyEval_Vector + 376
36  Python                        	       0x1030e2ad0 call_function + 128
37  Python                        	       0x1030e02fc _PyEval_EvalFrameDefault + 43144
38  Python                        	       0x1030d481c _PyEval_Vector + 376
39  Python                        	       0x1030e2ad0 call_function + 128
40  Python                        	       0x1030e02fc _PyEval_EvalFrameDefault + 43144
41  Python                        	       0x1030d481c _PyEval_Vector + 376
42  Python                        	       0x1030e2ad0 call_function + 128
43  Python                        	       0x1030e02fc _PyEval_EvalFrameDefault + 43144
44  Python                        	       0x1030d481c _PyEval_Vector + 376
45  Python                        	       0x1030d4690 PyEval_EvalCode + 104
46  qutebrowser                   	       0x1023049f4 0x102300000 + 18932
47  qutebrowser                   	       0x102305018 0x102300000 + 20504
48  dyld                          	       0x102b4908c start + 520

Thread 1:
0   libsystem_pthread.dylib       	       0x1c0957078 start_wqthread + 0

Thread 2:
0   libsystem_pthread.dylib       	       0x1c0957078 start_wqthread + 0


Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x0000000000000000   x1: 0x0000000000000000   x2: 0x0000000000000001   x3: 0x0000000000000000
    x4: 0x0000000000000050   x5: 0x0000000000000063   x6: 0x0000000000000000   x7: 0x0000000000000000
    x8: 0xfabcfbe84c13e257   x9: 0xfabcfbe94ea827d7  x10: 0xcccccccccccccccd  x11: 0x00000000fffffff6
   x12: 0x000000012014fa82  x13: 0x0000000000000000  x14: 0x0000000000000032  x15: 0x00000000000000a3
   x16: 0x0000000000000148  x17: 0x000000021a9e7680  x18: 0x0000000000000000  x19: 0x000000000000000b
   x20: 0x0000000102bbc580  x21: 0x0000000000000103  x22: 0x0000000102bbc660  x23: 0x0000000000000166
   x24: 0x0000000000000000  x25: 0x0000000104a59420  x26: 0x00006000002ec1e0  x27: 0x00006000002ec0c0
   x28: 0x0000000000000000   fp: 0x000000012014fb50   lr: 0x00000001c095bee0
    sp: 0x000000012014fb30   pc: 0x00000001c0926d98 cpsr: 0x40001000
   far: 0x0000000109cc56f8  esr: 0x56000080  Address size fault

Binary Images:
       0x1c091d000 -        0x1c0954fff libsystem_kernel.dylib (*) <03f48dc5-caa7-3678-af61-1a3c7fa8b06e> /usr/lib/system/libsystem_kernel.dylib
       0x1c0955000 -        0x1c0961fff libsystem_pthread.dylib (*) <42166a2c-89a9-3c38-a215-f028544cea23> /usr/lib/system/libsystem_pthread.dylib
       0x1c081c000 -        0x1c089dfff libsystem_c.dylib (*) <86746b94-88e3-342d-b2b2-54303404e492> /usr/lib/system/libsystem_c.dylib
       0x1c096f000 -        0x1c0976fff libsystem_platform.dylib (*) <d7aba99f-ba00-36e9-945d-48acf57fc568> /usr/lib/system/libsystem_platform.dylib
               0x0 - 0xffffffffffffffff ??? (*) <00000000-0000-0000-0000-000000000000> ???
       0x1c09a4000 -        0x1c0eeafff com.apple.CoreFoundation (6.9) <994db908-11a1-3e43-b7df-25c09d51368a> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
       0x104594000 -        0x104a4bfff QtCore (*) <7fbd546e-9e17-3d25-a6bf-2aa7c0e87bc5> /Users/USER/*/qutebrowser.app/Contents/MacOS/QtCore
       0x103cf4000 -        0x103e8bfff QtCore.abi3.so (*) <e8a79a4d-f614-349c-a6cf-bc3d70d66f4c> /Users/USER/*/qutebrowser.app/Contents/MacOS/PyQt5/QtCore.abi3.so
       0x102f78000 -        0x103253fff Python (*) <91e76b08-df8e-3d3d-9871-d34bf181cda0> /Users/USER/*/qutebrowser.app/Contents/MacOS/Python
       0x102300000 -        0x10230bfff org.qt-project.Qt.QtWebEngineCore (2.5.2) <2be368c0-abf9-36e8-80c2-dfd971a6e901> /Users/USER/*/qutebrowser.app/Contents/MacOS/qutebrowser
       0x102b44000 -        0x102ba3fff dyld (*) <d9c2a46e-8dc4-3950-9d6a-f799e8ccb683> /usr/lib/dyld

External Modification Summary:
  Calls made by other processes targeting this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by all processes on this machine:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0

VM Region Summary:
ReadOnly portion of Libraries: Total=1.2G resident=0K(0%) swapped_out_or_unallocated=1.2G(100%)
Writable regions: Total=719.6M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=719.6M(100%)

                                VIRTUAL   REGION 
REGION TYPE                        SIZE    COUNT (non-coalesced) 
===========                     =======  ======= 
Activity Tracing                   256K        1 
Kernel Alloc Once                   32K        1 
MALLOC                           177.2M       23 
MALLOC guard page                   96K        5 
MALLOC_MEDIUM (reserved)         120.0M        1         reserved VM address space (unallocated)
MALLOC_NANO (reserved)           384.0M        1         reserved VM address space (unallocated)
STACK GUARD                         32K        2 
Stack                             9264K        3 
Stack Guard                       56.0M        1 
VM_ALLOCATE                       27.0M       28 
__AUTH                            2586K      302 
__AUTH_CONST                      20.2M      496 
__CTF                               756        1 
__DATA                            20.8M      567 
__DATA_CONST                      25.3M      578 
__DATA_DIRTY                      1792K      213 
__FONT_DATA                          4K        1 
__LINKEDIT                       598.1M       81 
__OBJC_CONST                      3624K      274 
__OBJC_RO                         83.0M        1 
__OBJC_RW                         3152K        1 
__TEXT                           631.8M      596 
__UNICODE                          592K        1 
dyld private memory               1024K        1 
mapped file                       29.1M        3 
shared memory                       64K        4 
===========                     =======  ======= 
TOTAL                              2.1G     3186 
TOTAL, minus reserved VM space     1.7G     3186 



-----------
Full Report
-----------

{"app_name":"qutebrowser","timestamp":"2022-09-16 19:43:37.00 +0800","app_version":"2.5.2","slice_uuid":"2be368c0-abf9-36e8-80c2-dfd971a6e901","build_version":"2.5.2","platform":1,"bundleID":"org.qt-project.Qt.QtWebEngineCore","share_with_app_devs":0,"is_first_party":0,"bug_type":"309","os_version":"macOS 12.4 (21F79)","incident_id":"3038862A-93A7-4AB6-A7DA-EFC4ACE213E1","name":"qutebrowser"}
{
  "uptime" : 14000,
  "procLaunch" : "2022-09-16 19:43:37.0479 +0800",
  "procRole" : "Unspecified",
  "version" : 2,
  "userID" : 501,
  "deployVersion" : 210,
  "modelCode" : "VirtualMac2,1",
  "procStartAbsTime" : 342973716672,
  "coalitionID" : 383,
  "osVersion" : {
    "train" : "macOS 12.4",
    "build" : "21F79",
    "releaseType" : "User"
  },
  "captureTime" : "2022-09-16 19:43:37.5485 +0800",
  "incident" : "3038862A-93A7-4AB6-A7DA-EFC4ACE213E1",
  "bug_type" : "309",
  "pid" : 32316,
  "procExitAbsTime" : 342985704828,
  "translated" : false,
  "cpuType" : "ARM-64",
  "procName" : "qutebrowser",
  "procPath" : "\/Users\/USER\/*\/qutebrowser.app\/Contents\/MacOS\/qutebrowser",
  "bundleInfo" : {"CFBundleShortVersionString":"2.5.2","CFBundleVersion":"2.5.2","CFBundleIdentifier":"org.qt-project.Qt.QtWebEngineCore"},
  "storeInfo" : {"deviceIdentifierForVendor":"29F5A8BC-D0F1-5B3A-BE2F-381257287523","thirdParty":true},
  "parentProc" : "fish",
  "parentPid" : 4597,
  "coalitionName" : "com.apple.Terminal",
  "crashReporterKey" : "13FBAFD6-11F5-43D0-92BC-2C09F16829C7",
  "responsiblePid" : 360,
  "responsibleProc" : "Terminal",
  "sip" : "enabled",
  "vmRegionInfo" : "0x8 is not in any region.  Bytes before following region: 105553518919672\n      REGION TYPE                    START - END         [ VSIZE] PRT\/MAX SHRMOD  REGION DETAIL\n      UNUSED SPACE AT START\n--->  \n      MALLOC_NANO (reserved)   600018000000-600020000000 [128.0M] rw-\/rwx SM=NUL  ...(unallocated)",
  "isCorpse" : 1,
  "exception" : {"codes":"0x0000000000000001, 0x0000000000000008","rawCodes":[1,8],"type":"EXC_BAD_ACCESS","signal":"SIGSEGV","subtype":"KERN_INVALID_ADDRESS at 0x0000000000000008"},
  "vmregioninfo" : "0x8 is not in any region.  Bytes before following region: 105553518919672\n      REGION TYPE                    START - END         [ VSIZE] PRT\/MAX SHRMOD  REGION DETAIL\n      UNUSED SPACE AT START\n--->  \n      MALLOC_NANO (reserved)   600018000000-600020000000 [128.0M] rw-\/rwx SM=NUL  ...(unallocated)",
  "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":188078,"threadState":{"x":[{"value":0},{"value":0},{"value":1},{"value":0},{"value":80},{"value":99},{"value":0},{"value":0},{"value":18067592780230943319},{"value":18067592784569182167},{"value":14757395258967641293},{"value":4294967286},{"value":4833213058},{"value":0},{"value":50},{"value":163},{"value":328},{"value":9036527232},{"value":0},{"value":11},{"value":4340827520,"symbolLocation":0,"symbol":"_main_thread"},{"value":259},{"value":4340827744,"symbolLocation":224,"symbol":"_main_thread"},{"value":358},{"value":0},{"value":4372927520},{"value":105553119330784},{"value":105553119330496},{"value":0}],"flavor":"ARM_THREAD_STATE64","lr":{"value":7526006496},"cpsr":{"value":1073745920},"fp":{"value":4833213264},"sp":{"value":4833213232},"esr":{"value":1442840704,"description":" Address size fault"},"pc":{"value":7525789080,"matchesCrashFrame":1},"far":{"value":4459353848}},"queue":"com.apple.main-thread","frames":[{"imageOffset":40344,"symbol":"__pthread_kill","symbolLocation":8,"imageIndex":0},{"imageOffset":28384,"symbol":"pthread_kill","symbolLocation":288,"imageIndex":1},{"imageOffset":272000,"symbol":"raise","symbolLocation":32,"imageIndex":2},{"imageOffset":17572,"symbol":"_sigtramp","symbolLocation":56,"imageIndex":3},{"imageOffset":18446603343747660792,"imageIndex":4},{"imageOffset":162808,"symbol":"CFBundleCopyBundleURL","symbolLocation":24,"imageIndex":5},{"imageOffset":109480,"symbol":"QLibraryInfo::location(QLibraryInfo::LibraryLocation)","symbolLocation":1280,"imageIndex":6},{"imageOffset":110176,"symbol":"QLibraryInfo::location(QLibraryInfo::LibraryLocation)","symbolLocation":1976,"imageIndex":6},{"imageOffset":720040,"symbol":"meth_QLibraryInfo_location(_object*, _object*)","symbolLocation":112,"imageIndex":7},{"imageOffset":794488,"symbol":"cfunction_call","symbolLocation":96,"imageIndex":8},{"imageOffset":457452,"symbol":"_PyObject_MakeTpCall","symbolLocation":136,"imageIndex":8},{"imageOffset":1485664,"symbol":"call_function","symbolLocation":272,"imageIndex":8},{"imageOffset":1475324,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":43144,"imageIndex":8},{"imageOffset":1427484,"symbol":"_PyEval_Vector","symbolLocation":376,"imageIndex":8},{"imageOffset":1485520,"symbol":"call_function","symbolLocation":128,"imageIndex":8},{"imageOffset":1475324,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":43144,"imageIndex":8},{"imageOffset":1427484,"symbol":"_PyEval_Vector","symbolLocation":376,"imageIndex":8},{"imageOffset":1485520,"symbol":"call_function","symbolLocation":128,"imageIndex":8},{"imageOffset":1475504,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":43324,"imageIndex":8},{"imageOffset":1427484,"symbol":"_PyEval_Vector","symbolLocation":376,"imageIndex":8},{"imageOffset":1485520,"symbol":"call_function","symbolLocation":128,"imageIndex":8},{"imageOffset":1475200,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":43020,"imageIndex":8},{"imageOffset":1427484,"symbol":"_PyEval_Vector","symbolLocation":376,"imageIndex":8},{"imageOffset":1485520,"symbol":"call_function","symbolLocation":128,"imageIndex":8},{"imageOffset":1475200,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":43020,"imageIndex":8},{"imageOffset":1427484,"symbol":"_PyEval_Vector","symbolLocation":376,"imageIndex":8},{"imageOffset":458068,"symbol":"_PyObject_FastCallDictTstate","symbolLocation":96,"imageIndex":8},{"imageOffset":944340,"symbol":"slot_tp_init","symbolLocation":196,"imageIndex":8},{"imageOffset":911608,"symbol":"type_call","symbolLocation":288,"imageIndex":8},{"imageOffset":457452,"symbol":"_PyObject_MakeTpCall","symbolLocation":136,"imageIndex":8},{"imageOffset":1485664,"symbol":"call_function","symbolLocation":272,"imageIndex":8},{"imageOffset":1475364,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":43184,"imageIndex":8},{"imageOffset":1427484,"symbol":"_PyEval_Vector","symbolLocation":376,"imageIndex":8},{"imageOffset":1485520,"symbol":"call_function","symbolLocation":128,"imageIndex":8},{"imageOffset":1475324,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":43144,"imageIndex":8},{"imageOffset":1427484,"symbol":"_PyEval_Vector","symbolLocation":376,"imageIndex":8},{"imageOffset":1485520,"symbol":"call_function","symbolLocation":128,"imageIndex":8},{"imageOffset":1475324,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":43144,"imageIndex":8},{"imageOffset":1427484,"symbol":"_PyEval_Vector","symbolLocation":376,"imageIndex":8},{"imageOffset":1485520,"symbol":"call_function","symbolLocation":128,"imageIndex":8},{"imageOffset":1475324,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":43144,"imageIndex":8},{"imageOffset":1427484,"symbol":"_PyEval_Vector","symbolLocation":376,"imageIndex":8},{"imageOffset":1485520,"symbol":"call_function","symbolLocation":128,"imageIndex":8},{"imageOffset":1475324,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":43144,"imageIndex":8},{"imageOffset":1427484,"symbol":"_PyEval_Vector","symbolLocation":376,"imageIndex":8},{"imageOffset":1427088,"symbol":"PyEval_EvalCode","symbolLocation":104,"imageIndex":8},{"imageOffset":18932,"imageIndex":9},{"imageOffset":20504,"imageIndex":9},{"imageOffset":20620,"symbol":"start","symbolLocation":520,"imageIndex":10}]},{"id":188080,"frames":[{"imageOffset":8312,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":1}]},{"id":188081,"frames":[{"imageOffset":8312,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":1}]}],
  "usedImages" : [
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 7525748736,
    "size" : 229376,
    "uuid" : "03f48dc5-caa7-3678-af61-1a3c7fa8b06e",
    "path" : "\/usr\/lib\/system\/libsystem_kernel.dylib",
    "name" : "libsystem_kernel.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 7525978112,
    "size" : 53248,
    "uuid" : "42166a2c-89a9-3c38-a215-f028544cea23",
    "path" : "\/usr\/lib\/system\/libsystem_pthread.dylib",
    "name" : "libsystem_pthread.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 7524696064,
    "size" : 532480,
    "uuid" : "86746b94-88e3-342d-b2b2-54303404e492",
    "path" : "\/usr\/lib\/system\/libsystem_c.dylib",
    "name" : "libsystem_c.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 7526084608,
    "size" : 32768,
    "uuid" : "d7aba99f-ba00-36e9-945d-48acf57fc568",
    "path" : "\/usr\/lib\/system\/libsystem_platform.dylib",
    "name" : "libsystem_platform.dylib"
  },
  {
    "size" : 0,
    "source" : "A",
    "base" : 0,
    "uuid" : "00000000-0000-0000-0000-000000000000"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 7526301696,
    "CFBundleShortVersionString" : "6.9",
    "CFBundleIdentifier" : "com.apple.CoreFoundation",
    "size" : 5533696,
    "uuid" : "994db908-11a1-3e43-b7df-25c09d51368a",
    "path" : "\/System\/Library\/Frameworks\/CoreFoundation.framework\/Versions\/A\/CoreFoundation",
    "name" : "CoreFoundation",
    "CFBundleVersion" : "1863"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4367925248,
    "size" : 4947968,
    "uuid" : "7fbd546e-9e17-3d25-a6bf-2aa7c0e87bc5",
    "path" : "\/Users\/USER\/*\/qutebrowser.app\/Contents\/MacOS\/QtCore",
    "name" : "QtCore"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4358881280,
    "size" : 1671168,
    "uuid" : "e8a79a4d-f614-349c-a6cf-bc3d70d66f4c",
    "path" : "\/Users\/USER\/*\/qutebrowser.app\/Contents\/MacOS\/PyQt5\/QtCore.abi3.so",
    "name" : "QtCore.abi3.so"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4344741888,
    "size" : 2998272,
    "uuid" : "91e76b08-df8e-3d3d-9871-d34bf181cda0",
    "path" : "\/Users\/USER\/*\/qutebrowser.app\/Contents\/MacOS\/Python",
    "name" : "Python"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4331667456,
    "CFBundleShortVersionString" : "2.5.2",
    "CFBundleIdentifier" : "org.qt-project.Qt.QtWebEngineCore",
    "size" : 49152,
    "uuid" : "2be368c0-abf9-36e8-80c2-dfd971a6e901",
    "path" : "\/Users\/USER\/*\/qutebrowser.app\/Contents\/MacOS\/qutebrowser",
    "name" : "qutebrowser",
    "CFBundleVersion" : "2.5.2"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 4340334592,
    "size" : 393216,
    "uuid" : "d9c2a46e-8dc4-3950-9d6a-f799e8ccb683",
    "path" : "\/usr\/lib\/dyld",
    "name" : "dyld"
  }
],
  "sharedCache" : {
  "base" : 7522680832,
  "size" : 3136077824,
  "uuid" : "513553bb-5ca5-3b9e-a613-b0603ffe3038"
},
  "vmSummary" : "ReadOnly portion of Libraries: Total=1.2G resident=0K(0%) swapped_out_or_unallocated=1.2G(100%)\nWritable regions: Total=719.6M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=719.6M(100%)\n\n                                VIRTUAL   REGION \nREGION TYPE                        SIZE    COUNT (non-coalesced) \n===========                     =======  ======= \nActivity Tracing                   256K        1 \nKernel Alloc Once                   32K        1 \nMALLOC                           177.2M       23 \nMALLOC guard page                   96K        5 \nMALLOC_MEDIUM (reserved)         120.0M        1         reserved VM address space (unallocated)\nMALLOC_NANO (reserved)           384.0M        1         reserved VM address space (unallocated)\nSTACK GUARD                         32K        2 \nStack                             9264K        3 \nStack Guard                       56.0M        1 \nVM_ALLOCATE                       27.0M       28 \n__AUTH                            2586K      302 \n__AUTH_CONST                      20.2M      496 \n__CTF                               756        1 \n__DATA                            20.8M      567 \n__DATA_CONST                      25.3M      578 \n__DATA_DIRTY                      1792K      213 \n__FONT_DATA                          4K        1 \n__LINKEDIT                       598.1M       81 \n__OBJC_CONST                      3624K      274 \n__OBJC_RO                         83.0M        1 \n__OBJC_RW                         3152K        1 \n__TEXT                           631.8M      596 \n__UNICODE                          592K        1 \ndyld private memory               1024K        1 \nmapped file                       29.1M        3 \nshared memory                       64K        4 \n===========                     =======  ======= \nTOTAL                              2.1G     3186 \nTOTAL, minus reserved VM space     1.7G     3186 \n",
  "legacyInfo" : {
  "threadTriggered" : {
    "queue" : "com.apple.main-thread"
  }
},
  "trialInfo" : {
  "rollouts" : [
    {
      "rolloutId" : "60f8ddccefea4203d95cbeef",
      "factorPackIds" : {

      },
      "deploymentId" : 240000020
    },
    {
      "rolloutId" : "5ffde50ce2aacd000d47a95f",
      "factorPackIds" : {

      },
      "deploymentId" : 240000198
    }
  ],
  "experiments" : [

  ]
}
}

Model: VirtualMac2,1, BootROM 7459.121.3, 8 processors, 8 GB, SMC 
Memory Module: unknown
Bluetooth: Version (null), 0 services, 0 devices, 0 incoming serial ports
Network Service: Ethernet, Ethernet, en0
USB Device: USB31Bus
USB Device: Virtual USB Digitizer
USB Device: Virtual USB Keyboard
Thunderbolt Bus: 

@ktprograms
Copy link
Contributor

I got something working! 🎉

Here's the diff:

diff --git a/scripts/dev/build_release.py b/scripts/dev/build_release.py
index c175c68a7..23efe2348 100755
--- a/scripts/dev/build_release.py
+++ b/scripts/dev/build_release.py
@@ -278,6 +278,20 @@ def patch_mac_app() -> None:
         link_path.symlink_to(target_path)
 
 
+def the_patch() -> None:
+    """HACK the symlinks"""
+    macos_path = pathlib.Path('dist/qutebrowser.app/Contents/MacOS')
+    for qt in macos_path.glob('Qt*'):
+        brew_path = pathlib.Path(f'/opt/homebrew/Cellar/qt@5/5.15.5_2/lib/{qt.name}.framework/{qt.name}')
+        qt.unlink()
+        qt.symlink_to(brew_path)
+    pyqt_path = macos_path / 'PyQt5'
+    for abi3so in pyqt_path.glob("*.abi3.so"):
+        brew_path = pathlib.Path('/opt/homebrew/Cellar/pyqt@5/5.15.7_1/lib/python3.10/site-packages/PyQt5')
+        abi3so.unlink()
+        abi3so.symlink_to(brew_path / abi3so.name)
+
+
 def sign_mac_app() -> None:
     """Re-sign and verify the Mac .app."""
     app_path = pathlib.Path('dist') / 'qutebrowser.app'
@@ -329,9 +343,10 @@ def build_mac(
     utils.print_title("Building .app via pyinstaller")
     call_tox('pyinstaller-64', '-r', debug=debug)
     utils.print_title("Patching .app")
-    patch_mac_app()
-    utils.print_title("Re-signing .app")
-    sign_mac_app()
+    the_patch()
+    #patch_mac_app()
+    #utils.print_title("Re-signing .app")
+    #sign_mac_app()
 
     dist_path = pathlib.Path("dist")
 
diff --git a/tox.ini b/tox.ini
index 8d33750f3..5baf104a0 100644
--- a/tox.ini
+++ b/tox.ini
@@ -158,8 +158,8 @@ passenv = APPDATA HOME PYINSTALLER_DEBUG
 deps =
     -r{toxinidir}/requirements.txt
     -r{toxinidir}/misc/requirements/requirements-pyinstaller.txt
-    -r{toxinidir}/misc/requirements/requirements-pyqt.txt
 commands =
+    {envpython} {toxinidir}/scripts/link_pyqt.py --tox {envdir}
     {envbindir}/pyinstaller --noconfirm misc/qutebrowser.spec
 
 [testenv:eslint]
@@ -231,3 +231,16 @@ deps =
     -r{toxinidir}/misc/requirements/requirements-pyinstaller.txt
 commands =
     {envpython} {toxinidir}/scripts/dev/build_release.py {posargs}
+
+[testenv:build-release-pyqtlink]
+basepython = {env:PYTHON:python3}
+passenv = *
+usedevelop = true
+deps =
+    -r{toxinidir}/requirements.txt
+    -r{toxinidir}/misc/requirements/requirements-tox.txt
+    -r{toxinidir}/misc/requirements/requirements-dev.txt
+    -r{toxinidir}/misc/requirements/requirements-pyinstaller.txt
+commands =
+    {envpython} {toxinidir}/scripts/link_pyqt.py --tox {envdir}
+    {envpython} {toxinidir}/scripts/dev/build_release.py {posargs}

It needs to be run as QT_DEBUG_PLUGINS=1 QTWEBENGINEPROCESS_PATH=dist/qutebrowser.app/Contents/MacOS/PyQt5/Qt/lib/QtWebEngineCore.framework/Versions/5/Helpers/QtWebEngineProcess.app/Contents/MacOS/QtWebEngineProcess ./dist/qutebrowser.app/Contents/MacOS/qutebrowser currently, but it works!

@ktprograms
Copy link
Contributor

Update: Got codesigning to work. Here's the new diff:

diff --git a/scripts/dev/build_release.py b/scripts/dev/build_release.py
index c175c68a7..faaa771a2 100755
--- a/scripts/dev/build_release.py
+++ b/scripts/dev/build_release.py
@@ -278,6 +278,36 @@ def patch_mac_app() -> None:
         link_path.symlink_to(target_path)
 
 
+def the_patch() -> None:
+    """HACK the symlinks"""
+    contents_path = pathlib.Path('dist/qutebrowser.app/Contents')
+    macos_path = contents_path / 'MacOS'
+    resources_path = contents_path / 'Resources'
+    pyqt_path = macos_path / 'PyQt5'
+
+    for path in macos_path.glob('Qt*'):
+        brew_path = pathlib.Path(f'/opt/homebrew/Cellar/qt@5/5.15.5_2/lib/{path.name}.framework/{path.name}')
+        path.unlink()
+        path.symlink_to(brew_path)
+    for abi3so in pyqt_path.glob("*.abi3.so"):
+        brew_path = pathlib.Path('/opt/homebrew/Cellar/pyqt@5/5.15.7_1/lib/python3.10/site-packages/PyQt5')
+        abi3so.unlink()
+        abi3so.symlink_to(brew_path / abi3so.name)
+
+    # Move stuff around to make things signable on macOS
+    pyqt_path_dest = resources_path / pyqt_path.name
+    shutil.move(pyqt_path, pyqt_path_dest)
+    pyqt_path_target = pathlib.Path('..') / pyqt_path_dest.relative_to(contents_path)
+    pyqt_path.symlink_to(pyqt_path_target)
+
+    for path in macos_path.glob('Qt*'):
+        if path.name == 'QtWebEngineCore.prl':
+            continue
+        link_path = resources_path / path.name
+        target_path = pathlib.Path('..') / path.relative_to(contents_path)
+        link_path.symlink_to(target_path)
+
+
 def sign_mac_app() -> None:
     """Re-sign and verify the Mac .app."""
     app_path = pathlib.Path('dist') / 'qutebrowser.app'
@@ -293,7 +323,7 @@ def sign_mac_app() -> None:
     subprocess.run([
         'codesign',
         '--verify',
-        '--strict',
+        #'--strict', See manpage, don't error on symlinks
         '--deep',
         '--verbose',
         app_path,
@@ -329,7 +359,8 @@ def build_mac(
     utils.print_title("Building .app via pyinstaller")
     call_tox('pyinstaller-64', '-r', debug=debug)
     utils.print_title("Patching .app")
-    patch_mac_app()
+    the_patch()
+    #patch_mac_app()
     utils.print_title("Re-signing .app")
     sign_mac_app()
 
diff --git a/tox.ini b/tox.ini
index 8d33750f3..5baf104a0 100644
--- a/tox.ini
+++ b/tox.ini
@@ -158,8 +158,8 @@ passenv = APPDATA HOME PYINSTALLER_DEBUG
 deps =
     -r{toxinidir}/requirements.txt
     -r{toxinidir}/misc/requirements/requirements-pyinstaller.txt
-    -r{toxinidir}/misc/requirements/requirements-pyqt.txt
 commands =
+    {envpython} {toxinidir}/scripts/link_pyqt.py --tox {envdir}
     {envbindir}/pyinstaller --noconfirm misc/qutebrowser.spec
 
 [testenv:eslint]
@@ -231,3 +231,16 @@ deps =
     -r{toxinidir}/misc/requirements/requirements-pyinstaller.txt
 commands =
     {envpython} {toxinidir}/scripts/dev/build_release.py {posargs}
+
+[testenv:build-release-pyqtlink]
+basepython = {env:PYTHON:python3}
+passenv = *
+usedevelop = true
+deps =
+    -r{toxinidir}/requirements.txt
+    -r{toxinidir}/misc/requirements/requirements-tox.txt
+    -r{toxinidir}/misc/requirements/requirements-dev.txt
+    -r{toxinidir}/misc/requirements/requirements-pyinstaller.txt
+commands =
+    {envpython} {toxinidir}/scripts/link_pyqt.py --tox {envdir}
+    {envpython} {toxinidir}/scripts/dev/build_release.py {posargs}

This actually shows how broken this is currently, since it doesn't find libfreetype.6.dylib because pyinstaller is copying it from Homebrew into Contents/MacOS. I wasn't able to find how to get pyinstaller to just copy symlinks.

This can be ran with DYLD_LIBRARY_PATH=/opt/homebrew/lib/ QT_DEBUG_PLUGINS=1 QTWEBENGINEPROCESS_PATH=dist/qutebrowser.app/Contents/MacOS/PyQt5/Qt/lib/QtWebEngineCore.framework/Versions/5/Helpers/QtWebEngineProcess.app/Contents/MacOS/QtWebEngineProcess ./dist/qutebrowser.app/Contents/MacOS/qutebrowser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: infrastructure Issues related to development scripts, CI, servers, etc. os: macOS Issues which only happen on macOS. priority: 2 - low Issues which are currently not very important.
Projects
None yet
Development

No branches or pull requests

3 participants