Re: [Pyobjc-dev] standalone-related questions
Brought to you by:
ronaldoussoren
|
From: <bb...@ma...> - 2002-10-31 13:20:16
|
On Thursday, October 31, 2002, at 01:34 AM, Steven D. Arnold wrote:
> A couple questions related to the standalone nature of
> double-clickable apps
> created using pyobjc.
>
> 1. Is the app truly standalone in the sense of not requiring a previous
> Python installation? (My guess is no, at least not out-of-the-box)
The Cocoa-Python project template creates a Project Builder project
that will build a completely standalone, double-click-to-launch,
drag-and-drop-to-install application when the install target is used on
a developer's machine that has PyObjC installed against the Apple
supplied Python.
To the end user, there is absolutely no difference between an
application built using PyObjC and an application built using
Java-Cocoa, Objective-C, Carbon, or Swing other than a slightly long
launch time for Cocoa-Python apps (which goes away once Apple ships an
embeddable python).
> 2. If not, how could this be implemented?
It is is implemented by:
- using a series of copy file phases to copy the PyObjC module into
the 'pyobjc' subdirectory of the Resources directory of the application
when the 'install' target is used ('pbxbuild install' from the command
line).
- the main.m uses execve() to transfer control to /usr/bin/python
and exec Main.py in a fashion where OS X thinks that /usr/bin/python is
the executable within the app wrapper (otherwise, mainBundle breaks).
Unfortunately, this is what breaks gdb. Fortunately, this will go away
when Apple ships a new build of Python that includes a library for
embedding.
- the Main.py adds the pyobjc directory to sys.path and loads the
PyObjC module before bootstrapping into the AppKit.
End result: Standalone, double-clickable Python apps. Grab the Web
Services Tool disk image from http://www.friday.com/software/ and try
it out. Should just work without having a prior copy of pyobjc
installed. Requires 10.2
> We may want to consider this in light of people who use different
> versions
> of Python for a program. My app might need a feature available only in
> Python 2.3 for example. Also, my app might use third-party modules
> that are
> set up for a specific version of Python, which the end user may or may
> not
> have.
Third party modules can be dropped into the pyobjc directory within
Resources (or directly into the Resources) using a "copy files" phase.
Those two directories are on sys.path and, therefore, modules within
the directories will be found via the standard 'import' mechanism.
If you need to ship a custom build of Python (or a later build than the
version supplied by Apple), you can use the framework build or ship the
built python distribution [unix style] within the app wrapper. Your
app will jump from a minimum of 500k to a minimum of 5 to 9 megabytes
(depending on build style).
b.bum
|