ronaldoussoren / py2app

py2app is a Python setuptools command which will allow you to make standalone Mac OS X application bundles and plugins from Python scripts.
Other
340 stars 36 forks source link

I have Mac M2. It works fine for Mac M2. But not universal #523

Open SutirthaChakraborty opened 5 months ago

SutirthaChakraborty commented 5 months ago

I can't work with intel mac processors

passiomatic commented 3 months ago

I've experienced the same issue: successfully compiled on Apple M1 with macOS 14.2.1 using "universal2" (https://github.com/passiomatic/videobox/blob/main/pyproject.toml#L49) but when moved on Apple intel the app crashes. From the docs it seems that "universal2" is the correct arch value to use.

thanatas commented 3 months ago

I have a same problem. On M3 I can build and run. When I tried to Intel mac while using universal2. The Os gives the error it is corrupted. On the other hand, When I build on intel mac, I can run on my M3!!

How can fix this PS: venv : I am using universal python release!!

ronaldoussoren commented 2 months ago

What's the error you're getting?

One thing to check is if all libraries you use are universal2 as well, one way to do this is the following shell command (assuming the app is named MyApp.app):


find dist/MyApp.app -name '*.so' -exec file \{\} \+;

This will list all C extensions in the app bundle and their CPU architecture. For Universal binaries there should be multiple lines for every extension (one each for arm64 and x86_64 as well as third line with information about both variants).

Sadly a fairly large number of wheels on PyPI are not universal2 but only include a single architecture due to size concerns with the maintainers of those packages.

passiomatic commented 2 months ago

I run your find command and in my case there are a lot of modules in the lib-dynload folder that have this line, even in the standard Python library :

dist/videobox.app/Contents/Resources/lib/python3.12/lib-dynload/_codecs_kr.so:   Mach-O 64-bit bundle arm64

While very few have these lines:

dist/videobox.app/Contents/Resources/lib/python3.12/lib-dynload/objc/_objc.so:  Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit bundle x86_64] [arm64:Mach-O 64-bit bundle arm64]

So I guess this is my issue. In my case it is not really an issue: I intend to make the Python wheel the main distribution for the project, so building the app is left to end user.