tags:

views:

99

answers:

2

With Python2.6, the Evt module (from Carbon import Evt) does not have seem to respond to TickCount() on OSX. But Python2.5 is fine:

from Carbon import Evt
s = Evt.TickCount()

On Python2.5 I get a returned integer. On Python2.6 I get:

AttributeError: 'module' object has no attribute 'TickCount'

This is on Snow Leopard. Is there some library that needs to be updated on OSX to allow for TickCount() to work? I'm actually having this problem due to using py2app.

Update for Barry's answer: The problem is that the application that py2app creates, when launched, gives me:

  File "/Users/cybertoast/Projects/scripts/dist/fixcatalystlibs.app/Contents/Resources/__boot__.py", line 40, in mainloop
  [0x0-0x913913].org.pythonmac.unspecified.fixcatalystlibs[11722]       stoptime = Evt.TickCount() + timeout
  [0x0-0x913913].org.pythonmac.unspecified.fixcatalystlibs[11722]   AttributeError: 'module' object has no attribute 'TickCount'

I added VERSIONER_PYTHON_PREFER_32_BIT=yes to my .bash_profile, but the app that py2app creates still has the same problem. The python interpreter, however is happy with the 32-bit fix. But still need a solution to py2app.

A: 

Python runs in 64-bit mode by default in Snow Leopard. It appears that Carbon.Evt hasn't made the transition to full 64-bit compatibility. You can confirm this by trying to run in 32-bit mode (see man python):

oso:~ barry$ export VERSIONER_PYTHON_PREFER_32_BIT=yes
oso:~ barry$ python
Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29) 
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import Carbon.Evt as evt
>>> evt.TickCount()
2973070
>>> 

So, either run py2app in 32-bit mode, or tell us what you're trying to do and perhaps we can provide a 64-bit compatible alternative.

Barry Wark
Updated the problem based on your answer. It's helpful for the interpreter, but not for py2app.
cybertoast
I think you can specify environment variables in a app's Info.plist. You may be able to set the `VERSIONER_PYTHON_PREFER_32_BIT` in the app's plist. If not, start digging into how py2app chooses the interpreter.
Barry Wark
This is not really a solution as much as a work-around, but I finally ended up using Platypus, which did not have this problem. I was able to specify the libraries that I wanted, and the bundle created works fine on other machines (but I have not tested this extensively so it's possible that there will still be version issues).
cybertoast
A: 

Probably the easiest solution is to use another, 32-bit-only Python instead of the Apple-supplied one in 10.6 - for example, install Python 2.6 using the python.org installer. If you want to distribute your app as a standalone app that can be used on multiple OS X versions, you'll need to do that anyway.

Ned Deily