[PYTHONMAC-SIG] applet question

Jack Jansen Jack.Jansen@cwi.nl
Mon, 09 Sep 1996 17:41:42 +0200


> one quick question:  when an Applet is 'made', is the Python code 
> contained within the applet?  or does it point to the code it needs?  
> primarily, with some of the Python code i'm working on, there is a 
> central Module/Framework i'm using, and a few different 'front ends' 
> that access that Module.  the code in the front ends doesn't change too 
> much, but the Framework is.  Do i have to rebuild the Applets that use 
> that Framework everytime i change it?  It's no huge deal, but i'm just 
> wondering before i start building everything in my excitement over the 
> CFM version of Python :).

Jeffrey,
the compiled code for the main module is incorporated in the applet, nothing 
else. Actually, I use this fact for debugging applets: make your main code do 
nothing else than 'execfile("real_applet_code.py")' and you only have to run 
mkapplet once. Then, when I'm satisfied that the code works I rename 
real_applet_code.py to the real name and run mkapplet once.

There is actually a way to create a fully self-contained applet, but I haven't 
documented it yet since the procedure is a bit involved and I want to 
streamline it (if I find the time).

For the adventurous, here is the procedure:
- Collect *all* modules used by your program into a folder. I really mean
  "all", so including anything from Lib, etc.
- Run compileall.py on that folder.
- Run PackLibDir on the folder, giving you a resource file with PYC resources
  for all your modules.
- Temporarily replace PythonApplet by either PythonStandalone (PPC) or
  Python68K (68k).
- Create your applet. (And don't forget to put PythonApplet back in its place).
- Use ResEdit to copy the PYC resources from your PackLibDir output file to 
your
  applet. PYC resource numbers are not important (names are), so let resedit
  fix the duplicates.
- Drop the applet onto EditPythonPrefs, remove all sys.path components and
  replace them by the single string $(APPLICATION)
- I think you have to use ResEdit to remove the "alis" resource from the
  resulting applet to make it truly portable, but I'm not 100% sure.

You now have a fully standalone application that you can give away to anyone, 
it does not depend on any Python infrastructure anymore, even if the program 
is run on a machine that has python already installed.
--
Jack Jansen             | ++++ stop the execution of Mumia Abu-Jamal ++++
Jack.Jansen@cwi.nl      | ++++ if you agree copy these lines to your sig ++++
http://www.cwi.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm 



=================
PYTHONMAC-SIG  - SIG on Python for the Apple Macintosh

send messages to: pythonmac-sig@python.org
administrivia to: pythonmac-sig-request@python.org
=================