[Pythonmac-SIG] Building plugins with py2app
Dethe Elza
delza at livingcode.org
Thu Oct 12 06:49:55 CEST 2006
Hi folks,
I'm switching to to a recent py2app and moving to use setuptools-
based builds instead of distutils. I've had several problems, but
since I've been coding here and there in spare moments (including on
the bus in the mornings), I haven't done a very good job of
documenting them, I'm afraid.
I do have one persistent problem building both apps and plugins,
which is that the settings I add to my plist don't appear in the
resulting app/Contents/Info.plist. After much hair-pulling I think
that is the source of many of the weird problems I've been seeing.
For example, with the following setup:
from setuptools import setup
setup(
plugin=['PastelsView.py'],
setup_requires=['py2app'],
options=dict(
py2app=dict(
extension='.saver',
plist = dict(
NSPrincipalClass='PastelsView',
CFBundleShortVersionString = 'Pastels 0.3',
CFBBundleDisplayName = 'Pastels',
CFBundleIdentifier =
'org.livingcode.applications.pastels',
)
)
)
)
I end up with an Info.plist that has the following:
CFBundleIdentifier = org.pythonmac.unspecified.PastelsView
CFBundleDisplayName = PastelsView
CFBundleName = PastelsView
NSPrincipalClass = PastelsView
So it does end up with the right principal class, but other values
are wrong, and the principal class appears to be set correctly more
because that is the name of the script file than because I set it
explicitly. In another program the app failed to pick up its icon
from the plist specifier CFBundleIconFile, but successfully got the
icon when I added iconfile in the py2app options.
When I try to load the above screensaver I get the console messages:
'import site' failed; use -v for traceback
Traceback (most recent call last):
File "/Users/delza/Library/Screen Savers/PastelsView.saver/
Contents/Resources/__boot__.py", line 7, in ?
_disable_linecache()
File "/Users/delza/Library/Screen Savers/PastelsView.saver/
Contents/Resources/__boot__.py", line 2, in _disable_linecache
import linecache
ImportError: No module named linecache
2006-10-11 21:19:00.209 System Preferences[382] PastelsView has
encountered a fatal error, and will now terminate.
2006-10-11 21:19:00.209 System Preferences[382] An uncaught exception
was raised during execution of the main script:
ImportError: No module named linecache
This may mean that an unexpected error has occurred, or that you do
not have all of the dependencies for this bundle.
2006-10-11 21:19:00.210 System Preferences[382] ScreenSaverModules:
can't get principalClass for /Users/delza/Library/Screen Savers/
PastelsView.saver
Details:
Python 2.4.3
PyObjC pyobjc-1.4.1a0 installed with "python setup.py bdist_mpkg --open"
py2app 0.3.4
Setuptools 0.7a1dev_r51485
OS X 10.4.7 (Intel)
Code for the screensaver available from Google Code: http://
code.google.com/p/pastels/source
Code works from the command-line (not built into a bundle) with my
test harness. The linecache module is in place, the message that it
is missing is spurious.
When I change the Info.plist by hand to reflect the desired bundle
name (Pastels) I still see it as PastelsView, and it still fails to
load, so I'm obviously missing something important. If anyone has a
clue as to what I'm doing wrong, please let me know.
If there's any other information that would be helfpul, please let me
know.
Thanks!
--Dethe
All space and matter, organic or inorganic, has some degree of life
in it [...] All matter/space has some degree of "self" in it. If
either of these claims comes, in future, to be considered true, that
would radically change our picture of the universe. --Christopher
Alexander
More information about the Pythonmac-SIG
mailing list