4

I am trying to build an app bundle with py2app on Mac OS X 10.6. The app uses some libraries which are only compiled for 32-bit, so when the app is run there is an ImportError "no appropriate 64-bit architecture". How can I tell py2app to force the app to run in 32-bit mode?

Luke McCarthy
  • 879
  • 2
  • 9
  • 21

5 Answers5

6

If you want to run only in 32 bit mode, then you don't need the 64 bit architecture. So you can just strip out all the non-i386 architectures from your resulting application bundle using the ditto utility.

Example:

ditto --rsrc --arch i386 YourApplication.app YourApplicationStripped.app

Your application bundle will be smaller and will run as a 32 bit application for sure, even on 64 bit Intel systems.

Manual: http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/ditto.1.html

Or just run in a terminal: man ditto

fviktor
  • 2,861
  • 20
  • 24
5

One way is to use a 32-bit-only Python, such as the 32-bit-only versions downloadable from python.org, with py2app. Another is to set the LSArchitecturePriority to i386 and possibly ppc in the generated app bundle's Info.plist. See here for more info.

Ned Deily
  • 83,389
  • 16
  • 128
  • 151
  • Thanks, I ended up using the 32-bit build on python.org. – Luke McCarthy Sep 23 '11 at 13:10
  • This didn't work for me. I had to use [the ditto solution](http://stackoverflow.com/a/8320517/17498). – Vebjorn Ljosa Aug 28 '12 at 19:14
  • on 1.6.8 once I have made an app for dist, then I have edited info.plist in Property List Editor by adding in the root of the tree a set (offered in popup) which is called "Architecture Priority". I was amazed that default setting immediately offered i386. Saved. After this intervention app started without 32bit error. – ljgww Jan 08 '13 at 05:34
  • I'll take that back: it _does_ work. My mistake was making the value a string rather than an array of strings. – Vebjorn Ljosa Apr 26 '13 at 19:11
4

After lots of pain and trying to get wx working I managed to get it to work using this method, I have also included the versions I installed
This was the only one that worked for me, I hope it helps others..

py2applet --arch=i386 -i (includes here) --make-setup (pythonfiles, icon)

Mine looks a bit like this

py2applet --arch=i386 -i wx, platform --make-setup print.py print.icns convert.py

I installed python2.7 with
wxPython2.8-osx-unicode-py2.7
setuptools-0.6c11-py2.7.egg
and then

sudo easy_install-2.7 py2app

This installed version 0.6.4 of py2applet

Hovo
  • 455
  • 4
  • 9
1

OK, seeing as I work one office over from Vebjorn, possibly this is the best place to post an answer so we will find it again. Given a dictionary of py2app options:

options = {}
...
options['plist'] = { "LSArchitecturePriority": [ "i386" ] }
...
setup(options={'py2app':options})

This creates an array of one string value for the LSArchitecturePriority key.

Lee Kamentsky
  • 631
  • 5
  • 6
0

You need to force python to run in 32-bit mode.

jermenkoo
  • 643
  • 5
  • 20