Thread: [Pyobjc-dev] Three issues with PyObjC under Snow Leopard
Brought to you by:
ronaldoussoren
From: David E. <dav...@gm...> - 2009-10-05 03:59:34
|
(1) `http://pyobjc.sourceforge.net/downloads.html tells me that I can update my pyobjc (currently the one that came with the Snow Leopard install DVD) to 2.2b1 with the command line "easy_install pyobjc=2.2b1". But when I try it I get the error message "error: Not a URL, existing file, or requirement spec: 'pyobjc=2.2b1'". Are the update instructions misleading or do I have a misconfiguration somewhere? (2) I have some apps I wrote using pyobjc under Leopard that broke when I moved to Snow Leopard. The simplest is the one in http://www.ics.uci.edu/~eppstein/LaTeX_Unicodifier.dmg.gz (that's the app bundle but because it's Python the source is inside, and is quite short). I don't want to ask anyone to debug my code for me, but I'm at a bit of a loss: when I run it (either the app as I built it for 10.5, or the same xcode project recompiled for a 10.6 intel target) I get a mysterious message "10/4/09 8:28:13 PM LaTeX Unicodifier[13914] <type 'exceptions.TypeError'>: Need 0 arguments, got 1" on the console and it doesn't work: the UI appears, cmd-Q quits, but the actual app that's supposed to be running the UI isn't there. I imagine that somewhere there's a method that needs a signature and doesn't have one, or something simple like that, but I can't seem to figure out how to get xcode to show me who's raising the uncaught exception... (3) In an attempt to get around (2), I tried making a setup.py following the example of http://pyobjc.sourceforge.net/examples/pyobjc-framework-Cocoa/AppKit/CocoaBindings/CurrencyConvBinding/source--setup.py.html in order to create an app using py2app instead of xcode. But this, too, fails, with an error message ... creating build/bdist.macosx-10.6-universal/python2.6-standalone/app/lib-dynload creating build/bdist.macosx-10.6-universal/python2.6-standalone/app/Frameworks error: Multiple targets not currently supported Is there some parameter I need to set to get py2app to work or is this also irredeemably broken? |
From: Ronald O. <ron...@ma...> - 2009-10-06 06:15:53
|
On 5 Oct, 2009, at 5:59, David Eppstein wrote: > (1) `http://pyobjc.sourceforge.net/downloads.html tells me that I can > update my pyobjc (currently the one that came with the Snow Leopard > install DVD) to 2.2b1 with the command line "easy_install > pyobjc=2.2b1". But when I try it I get the error message "error: Not a > URL, existing file, or requirement spec: 'pyobjc=2.2b1'". Are the > update instructions misleading or do I have a misconfiguration > somewhere? Don't upgrade the system version of PyObjC. It is already a fairly recent version, and furthermore I'm unsure it the current version is 100% backwards compatible with the one in the system. > > (2) I have some apps I wrote using pyobjc under Leopard that broke > when I moved to Snow Leopard. The simplest is the one in > http://www.ics.uci.edu/~eppstein/LaTeX_Unicodifier.dmg.gz (that's the > app bundle but because it's Python the source is inside, and is quite > short). I don't want to ask anyone to debug my code for me, but I'm at > a bit of a loss: when I run it (either the app as I built it for 10.5, > or the same xcode project recompiled for a 10.6 intel target) I get a > mysterious message "10/4/09 8:28:13 PM LaTeX Unicodifier[13914] <type > 'exceptions.TypeError'>: Need 0 arguments, got 1" on the console and > it doesn't work: the UI appears, cmd-Q quits, but the actual app > that's supposed to be running the UI isn't there. I imagine that > somewhere there's a method that needs a signature and doesn't have > one, or something simple like that, but I can't seem to figure out how > to get xcode to show me who's raising the uncaught exception... I'll have a look later this week. > > (3) In an attempt to get around (2), I tried making a setup.py > following the example of > http://pyobjc.sourceforge.net/examples/pyobjc-framework-Cocoa/AppKit/CocoaBindings/CurrencyConvBinding/source--setup.py.html > in order to create an app using py2app instead of xcode. But this, > too, fails, with an error message > ... > creating build/bdist.macosx-10.6-universal/python2.6-standalone/app/ > lib-dynload > creating build/bdist.macosx-10.6-universal/python2.6-standalone/app/ > Frameworks > error: Multiple targets not currently supported > > Is there some parameter I need to set to get py2app to work or is this > also irredeemably broken? That's very odd, I haven't seen this error before. Another item on my todo list for the week... Ronald > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry® Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart > your > developing skills, take BlackBerry mobile applications to market and > stay > ahead of the curve. Join us from November 9-12, 2009. Register > now! > http://p.sf.net/sfu/devconf > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |
From: Ronald O. <ron...@ma...> - 2009-10-06 13:04:53
Attachments:
smime.p7s
|
On 5 Oct, 2009, at 5:59, David Eppstein wrote: > > (2) I have some apps I wrote using pyobjc under Leopard that broke > when I moved to Snow Leopard. The simplest is the one in > http://www.ics.uci.edu/~eppstein/LaTeX_Unicodifier.dmg.gz (that's the > app bundle but because it's Python the source is inside, and is quite > short). I don't want to ask anyone to debug my code for me, but I'm at > a bit of a loss: when I run it (either the app as I built it for 10.5, > or the same xcode project recompiled for a 10.6 intel target) I get a > mysterious message "10/4/09 8:28:13 PM LaTeX Unicodifier[13914] <type > 'exceptions.TypeError'>: Need 0 arguments, got 1" on the console and > it doesn't work: the UI appears, cmd-Q quits, but the actual app > that's supposed to be running the UI isn't there. I imagine that > somewhere there's a method that needs a signature and doesn't have > one, or something simple like that, but I can't seem to figure out how > to get xcode to show me who's raising the uncaught exception... There is an easy way to find the source of the exception: add 'objc.setVerbose(1)' to your 'main.py' file, just after the import of 'objc'. This will print exception tracebacks whenever exceptions cross the Python<->ObjC boundary. The problem is in the class Transformer, and in particular in the way you call the superclass initializer. Your code currently is: class Transformer (NSFormatter): def initWithSource_target_(self, source, target): self = NSFormatter.init(self) ... This is bad style, and furthermore doesn't work in 10.6 because 'NSFormatter.init' refers to the init method of the NSTransformer class (that is the classmethod '+init'). It happens to work in 10.5 because NSFormatter (or NSObject) doesn't have a +init method there. The right way to call a superclass method is using the super() function: class Transformer(NSFormatter): def initWithSource_target_(self,source,target): self = super(Transformer, self).init() if self is None: return None The call to super() isn't very pretty, but is the standard Python way of calling superclass methods in new-style classes. In Python 3.x the interface was cleaned up ("self = super().init()"), but until PyObjC supports Python 3.x we'll have to live with the current syntax. BTW. According to Apple the tests for 'self is None' is necesary, the superclass init might fail and return None. Ronald |
From: David E. <dav...@gm...> - 2009-10-06 15:42:21
|
Great, thanks! I very much appreciate your finding the bug in the code, but I suspect your advice to make exceptions verbose will be more useful in the long run. This app is actually more of a test for a larger app that I care more about that also broke when I moved to Snow Leopard (and that I'd happy to share once I get working again — it manages BibTeX databases — but due to the size of the code I didn't want to even hint that anyone else try debugging). So with the verbose exceptions in hand I can have some hope of finding out what's wrong with that one, too, assuming it isn't just the same thing. I've copied the setup.py I was using below, in answer to your other email requesting it — I had a partial plist copied from the text one in my xcode project (was intending to copy of the plist entries eventually until I got stuck), so perhaps something in there is confusing py2app. """ Script for building LaTeX Unicodifier D. Eppstein, October 2009 Usage: python setup.py py2app """ from distutils.core import setup import py2app plist = { 'CFBundleDevelopmentRegion': 'English', 'CFBundleExecutable': 'LaTeX Unicodifier', 'CFBundleIconFile': 'LaTeX Unicodifier.icns', } setup( app = ['Latex.py', 'LaTeX_Unicodifier.py'], data_files = ['English.lproj', 'LaTeX Unicodifier.icns'], options = { 'py2app': {'plist': plist} } ) On Tue, Oct 6, 2009 at 6:04 AM, Ronald Oussoren <ron...@ma...> wrote: > > On 5 Oct, 2009, at 5:59, David Eppstein wrote: >> >> (2) I have some apps I wrote using pyobjc under Leopard that broke >> when I moved to Snow Leopard. The simplest is the one in >> http://www.ics.uci.edu/~eppstein/LaTeX_Unicodifier.dmg.gz (that's the >> app bundle but because it's Python the source is inside, and is quite >> short). I don't want to ask anyone to debug my code for me, but I'm at >> a bit of a loss: when I run it (either the app as I built it for 10.5, >> or the same xcode project recompiled for a 10.6 intel target) I get a >> mysterious message "10/4/09 8:28:13 PM LaTeX Unicodifier[13914] >> <type >> 'exceptions.TypeError'>: Need 0 arguments, got 1" on the console and >> it doesn't work: the UI appears, cmd-Q quits, but the actual app >> that's supposed to be running the UI isn't there. I imagine that >> somewhere there's a method that needs a signature and doesn't have >> one, or something simple like that, but I can't seem to figure out how >> to get xcode to show me who's raising the uncaught exception... > > There is an easy way to find the source of the exception: add > 'objc.setVerbose(1)' to your 'main.py' file, just after the import of > 'objc'. This will print exception tracebacks whenever exceptions cross the > Python<->ObjC boundary. > > The problem is in the class Transformer, and in particular in the way you > call the superclass initializer. Your code currently is: > > class Transformer (NSFormatter): > def initWithSource_target_(self, source, target): > self = NSFormatter.init(self) > ... > > This is bad style, and furthermore doesn't work in 10.6 because > 'NSFormatter.init' refers to the init method of the NSTransformer class > (that is the classmethod '+init'). It happens to work in 10.5 because > NSFormatter (or NSObject) doesn't have a +init method there. > > The right way to call a superclass method is using the super() function: > > class Transformer(NSFormatter): > > def initWithSource_target_(self,source,target): > self = super(Transformer, self).init() > if self is None: > return None > > The call to super() isn't very pretty, but is the standard Python way of > calling superclass methods in new-style classes. In Python 3.x the interface > was cleaned up ("self = super().init()"), but until PyObjC supports Python > 3.x we'll have to live with the current syntax. > > BTW. According to Apple the tests for 'self is None' is necesary, the > superclass init might fail and return None. > > Ronald > > |
From: Ronald O. <ron...@ma...> - 2009-10-06 15:47:01
Attachments:
smime.p7s
|
On 6 Oct, 2009, at 17:42, David Eppstein wrote: > > """ > Script for building LaTeX Unicodifier > D. Eppstein, October 2009 > > Usage: > python setup.py py2app > """ > > from distutils.core import setup > import py2app > > plist = { > 'CFBundleDevelopmentRegion': 'English', > 'CFBundleExecutable': 'LaTeX Unicodifier', > 'CFBundleIconFile': 'LaTeX Unicodifier.icns', > } > > setup( > app = ['Latex.py', 'LaTeX_Unicodifier.py'], Use: app = ['main.py'], > data_files = ['English.lproj', 'LaTeX Unicodifier.icns'], > options = { 'py2app': {'plist': plist} } > ) The interface design for py2app was copied from py2exe, which is why you can list several applications in the 'app' argument. Having more than one application in setup.py is not implemented, and is luckily also not what you need. Ronald |
From: David E. <dav...@gm...> - 2009-10-07 01:10:06
|
Just a follow-up on all this. The fix to the way I was wrongly calling super.init worked and my app is happy again. Because it all works I haven't yet tested the code to tell objc to be more verbose when an exception hits the border, but I assume that works too The XCode version of the app is about 200k and the setup.py version is about 16Mb, I assume because the setup.py version includes its own copy of Python. I haven't yet decided which of these two build styles is preferable; under 10.4 and before I would have definitely wanted the one that included its own Python, because otherwise there was no way of counting on it working on anyone else's computer, but is that still necessary these days? However, I still have one minor hangup that is causing the setup.py version not to work: my source code has a .xib file inside English.lproj which XCode helpfully translates to a .nib while packaging up the app, but setup.py doesn't seem to know to do that translation. If I manually move XCode's nib into the English.lproj of the app created by setup.py, it all works, so I'm pretty sure that's the only problem. Is there a way of doing the xib-to-nib conversion outside of xcode under the control of setup.py? On Tue, Oct 6, 2009 at 8:46 AM, Ronald Oussoren <ron...@ma...> wrote: > > On 6 Oct, 2009, at 17:42, David Eppstein wrote: > >> >> """ >> Script for building LaTeX Unicodifier >> D. Eppstein, October 2009 >> >> Usage: >> python setup.py py2app >> """ >> >> from distutils.core import setup >> import py2app >> >> plist = { >> 'CFBundleDevelopmentRegion': 'English', >> 'CFBundleExecutable': 'LaTeX Unicodifier', >> 'CFBundleIconFile': 'LaTeX Unicodifier.icns', >> } >> >> setup( >> app = ['Latex.py', 'LaTeX_Unicodifier.py'], > > Use: > app = ['main.py'], >> >> data_files = ['English.lproj', 'LaTeX Unicodifier.icns'], >> options = { 'py2app': {'plist': plist} } >> ) > > The interface design for py2app was copied from py2exe, which is why you can > list several applications in the 'app' argument. Having more than one > application in setup.py is not implemented, and is luckily also not what you > need. > > Ronald > > > > |
From: Ronald O. <ron...@ma...> - 2009-10-07 06:10:32
Attachments:
smime.p7s
|
On 7 Oct, 2009, at 3:09, David Eppstein wrote: > Just a follow-up on all this. The fix to the way I was wrongly calling > super.init worked and my app is happy again. Because it all works I > haven't yet tested the code to tell objc to be more verbose when an > exception hits the border, but I assume that works too > > The XCode version of the app is about 200k and the setup.py version is > about 16Mb, I assume because the setup.py version includes its own > copy of Python. I haven't yet decided which of these two build styles > is preferable; under 10.4 and before I would have definitely wanted > the one that included its own Python, because otherwise there was no > way of counting on it working on anyone else's computer, but is that > still necessary these days? The setup.py version is larger because py2app copies more stuff into the application bundle. Are you using Apple's python or do you have a separate python install? > > However, I still have one minor hangup that is causing the setup.py > version not to work: my source code has a .xib file inside > English.lproj which XCode helpfully translates to a .nib while > packaging up the app, but setup.py doesn't seem to know to do that > translation. If I manually move XCode's nib into the English.lproj of > the app created by setup.py, it all works, so I'm pretty sure that's > the only problem. Is there a way of doing the xib-to-nib conversion > outside of xcode under the control of setup.py? The most recent version of py2app has support for compiling .xib files. Ronald > > On Tue, Oct 6, 2009 at 8:46 AM, Ronald Oussoren <ron...@ma... > > wrote: >> >> On 6 Oct, 2009, at 17:42, David Eppstein wrote: >> >>> >>> """ >>> Script for building LaTeX Unicodifier >>> D. Eppstein, October 2009 >>> >>> Usage: >>> python setup.py py2app >>> """ >>> >>> from distutils.core import setup >>> import py2app >>> >>> plist = { >>> 'CFBundleDevelopmentRegion': 'English', >>> 'CFBundleExecutable': 'LaTeX Unicodifier', >>> 'CFBundleIconFile': 'LaTeX Unicodifier.icns', >>> } >>> >>> setup( >>> app = ['Latex.py', 'LaTeX_Unicodifier.py'], >> >> Use: >> app = ['main.py'], >>> >>> data_files = ['English.lproj', 'LaTeX Unicodifier.icns'], >>> options = { 'py2app': {'plist': plist} } >>> ) >> >> The interface design for py2app was copied from py2exe, which is >> why you can >> list several applications in the 'app' argument. Having more than one >> application in setup.py is not implemented, and is luckily also not >> what you >> need. >> >> Ronald >> >> >> >> |
From: David E. <dav...@gm...> - 2009-10-07 06:16:22
|
On Tue, Oct 6, 2009 at 11:10 PM, Ronald Oussoren <ron...@ma...> wrote: > > On 7 Oct, 2009, at 3:09, David Eppstein wrote: > >> Just a follow-up on all this. The fix to the way I was wrongly calling >> super.init worked and my app is happy again. Because it all works I >> haven't yet tested the code to tell objc to be more verbose when an >> exception hits the border, but I assume that works too >> >> The XCode version of the app is about 200k and the setup.py version is >> about 16Mb, I assume because the setup.py version includes its own >> copy of Python. I haven't yet decided which of these two build styles >> is preferable; under 10.4 and before I would have definitely wanted >> the one that included its own Python, because otherwise there was no >> way of counting on it working on anyone else's computer, but is that >> still necessary these days? > > The setup.py version is larger because py2app copies more stuff into the > application bundle. Are you using Apple's python or do you have a separate > python install? Apple's. |