Repository navigation
Conversation
|
This was talked about in the discord before and wasn't done due to the build being something like 300mb, is this still the case? Also your targeting main, and you should be targeting development branch. |
shoot it is pretty huge in size hmm |
|
looks like most of the size comes from python in the libs folder ? interesting.. |
|
I'm currently trying some stuff out, seeing what we can do about it, I have a couple of theory's to fix it, |
|
The issue seems to be with Qt being the bulk of the build, been trying to see what i can do but so far running into dead ends |
|
TLDR before reading: DO NOT MERGE THIS YET After pushing this more and trying to see if I can get it to work, I'm not seeing an easy way around this, as this has already broken my MacOS's python pretty heavily attempting multiple things and getting nowhere but ill leave my notes explaining that at least for now, I really don't think this is a good move.
Now the main issue here, is the file size, this seems to be an issue with around py2app, python and Qt 5 & 6 causing a massive mess with the finished build. Their seems to be a lot of junk included by the py2app build, such as below phoenix@phoenixs-iMac-Pro lib % du -hs * | sort -rh | head -5
208M python3.10
43M python310.zip
2.5M tcl8.6
1.8M tk8.6
292K tcl8
phoenix@phoenixs-iMac-Pro lib % python310.zip is included in the build for seemingly no reason, now yes its 43M but 43M that from what i can tell, is just leftover. However you will also notice python3.10 is 208M phoenix@phoenixs-iMac-Pro python3.10 % du -hs * | sort -rh | head -5
193M PyQt6
15M lib-dynload
304K certifi
232K qtwidgets
104K config-3.10-darwin
phoenix@phoenixs-iMac-Pro python3.10 % As I mentioned before, theirs an issue with Qt5 & 6 being included in the build. and this is one of the big issues phoenix@phoenixs-iMac-Pro python3.10 % find . -type f -size +5M -exec du -ah {} + | sort -hr | head -10
19M ./PyQt6/Qt6/plugins/multimedia/libffmpegmediaplugin.dylib
10M ./PyQt6/QtWidgets.abi3.so
8.6M ./PyQt6/Qt6/lib/QtPdf.framework/Versions/A/QtPdf
8.1M ./PyQt6/Qt6/lib/QtGui.framework/Versions/A/QtGui
6.1M ./PyQt6/Qt6/lib/QtWidgets.framework/Versions/A/QtWidgets
5.8M ./PyQt6/QtCore.abi3.so
5.8M ./PyQt6/Qt6/lib/QtCore.framework/Versions/A/QtCore
5.5M ./PyQt6/Qt6/lib/QtQuick.framework/Versions/A/QtQuick
5.2M ./PyQt6/QtGui.abi3.so
phoenix@phoenixs-iMac-Pro python3.10 % phoenix@phoenixs-iMac-Pro python3.10 % find PyQt6 -type f | wc -l
2559Theirs a lot of files included here, that quickly add up over time, What makes matters worse is a lot of these included files aren't actually used. Trying to exclude all of these via py2app didn't seem to work, and we may have to start cleaning up the build before uploading it, however that seems pretty hacky, as well as it seemed to cause issues for me with breaking signing that py2app seemed to be doing. |
|
Yeah I could see how about building for just arm64 under a build-arm64 script, the question is if it would work under an intel mac environment which is what github actions uses (for now) |
|
Github Actions does not actually support building on M1 mac at this time, so yeah if we'd want to have a image close it would need to be universal2 |
|
if you were willing to switch i know cirrus ci uses an m1 environment , then we could just build both |
|
To be honest, we may just need to figure out a way to fix Universal2, as x64 can build it, just cant test it. But we'd need a debloater or figure out where its breaking, as trying to lock down py2app didnt work, and Trying to use PyInstaller on macOS causes a segmentation fault 11 |
|
Just wanted to chime in: Despite PyQt6 itself supporting universal wheels, Qt itself does not (as provided by the dependency PyQt6_Qt6). In this PR's current state the resulting launcher is universal, but it will play mix-and-match with framework architectures, and Qt will remain the native built architecture. It appears that py2applet and pip both recognize the special One potential approach may be to manually create a universal version of Example wheel build script# Download and unpack
pip3 download --only-binary=:all: --platform=macosx_13_0_x86_64 PyQt6_Qt6
pip3 download --only-binary=:all: --platform=macosx_13_0_arm64 PyQt6_Qt6
wheel unpack PyQt6_*arm64.whl --dest arm64
wheel unpack PyQt6_*x86_64.whl --dest x86_64
# We'll use x86_64 as our basis.
# As of writing, PyQt6_Qt6 specifies a minimum of 10.14 for x86_64, and 11.0 for arm64.
# We'll reuse this tag; it should be updated if this ever changes in the future.
wheel tags --platform-tag macosx_10_14_universal2 PyQt6_*x86_64.whl
wheel unpack PyQt6_*universal2.whl --dest universal
# https://stackoverflow.com/a/46020381
merge_frameworks() {
# Remove the leading universal/ from this path.
binary_path="${1##universal/}"
lipo -create -arch x86_64 "x86_64/$binary_path" "arm64/$binary_path" -output "universal/$binary_path"
}
export -f merge_frameworks
# Iterate through all frameworks and libraries, and lipo together
find universal -perm +111 -type f -exec sh -c 'merge_frameworks "$1"' _ {} \;
wheel pack universal/PyQt6_*
# Finally, install our universal wheel.
pip3 install PyQt6_*universal2.whlIf this is desired, I would be happy to help out finding a way to integrate this - perhaps vendoring PyQt6 and publishing universal wheels via GitHub Package Registry. The resulting app binary is 341.4 MB via this method (❗) in which ~49 MB are PyQt6 and ~259 MB are from Qt itself. (This could surely be slimmed down, by removing i.e. QtPdf). I was unable to reproduce having a large zip. If not, it may make sense to do per-architecture builds, given how large Qt unfortunately can be 😅 Via |
|
the only problem is with github actions , per architecture builds cant be automated |
|
I think part of the issue is that the universal version of Qt, does not seem to get trimmed unlike x64, maybe py2app does not understand what to do with the universal build? My only issue with the universal build is the size, if we can figure out a fix for that, then we can deal with the rest of the issues. We also use a very small collection of qt modules |
|
Interesting, i dont know why i didnt decide to look into this, Compressing the build like we usually do, Results in a ~110MB zip file. This is slightly over x2 however its not as big as initially suspected |
|
PS: The supplied .sh script provided as this PR does not work and would break CI, your removing name=NSO-RPC, that'd break Github Actions, aswell as |
|
Update: I just discovered a build bug around MacOS and Qt for NSO-RPC, investigating it now to see if i can figure out whats going on, |
hmm dang ill need to look into this more |
|
hopefully this is the better method |
Odd. I cant get it to replicate, something was overriding the QtPy imports for app.py, replacing it with Qt6 versions, but doing it wrong, causing a build to fail on execution, however I cant get it to happen again. |
You didnt update codesign, it still refrences app.app. it should be NSO-RPC.app |
|
oh whoops lol |
|
OK, So update, Gives me a working universal2 app at 402.3 MB (At least working on x64). Now yes that's quite big, however when zipped up, it becomes 168 MB, So it compresses pretty well considering. Note this also includes all the junk mentioned before about being included in Qt6 Edit: I however I need to get some sleep now, so I wont be able to check up on this more until later on. |
|
This does sound better though so thats good! |
This improves performance and battery life on apple silicon macs as it doesn't need to emulate x86_64, also it still is compatible with intel macs
431927e to
668cf19
Compare
|
squashed my commits |
|
Would you be able to compress a build of universal2 for me, and reply with the file size of the folder itself as well as the zip. |
|
Sure ill do it when i can |
|
for me with just running the script i get a 1.22 GB .app (using python3.9) |
|
Testing out the debloating idea, I've been able to shave off some of the size, however I haven't tried moving these steps over to Github Actions yet. So the size isn't final. |
|
Very nice! |
|
I've submitted a PR with some of the details provided here and submitted the final PR for it here: #89 I've also Co-Signed the commit, giving both @DarthMDev and @spotlightishere credit for their help! o7 |





This improves performance and battery life on apple silicon macs as it doesn't need to emulate x86_64, also it still is compatible with intel macs