Kaydet (Commit) a2139fef authored tarafından Jack Jansen's avatar Jack Jansen

Added (minimal) documentation on how to build standalone applications

with Python.

Updated various things (versions of libraries used, urls).
üst b92dce38
......@@ -2,10 +2,10 @@
:$e"*3e4LFQphFf8ZFR0bB`"bFh*M8P0&4!#3#!'8,V!!N!3"!!!!!6m!!!!r!!!
!9G'"(r!!q[m!!2Vr!!$kf!!!qYJ!!2VB!!$kf!!!q[qJ$e"*3e4LFQphFf8ZFR0
bB`)!!!"bFh*M8P0&4!#3"R*cFQ058d9%!*!BVAAL!`#3"J'8r`!!q[m!!2VB!!$
bB`)!!!"bFh*M8P0&4!#3"R*cFQ058d9%!*!BVPGG(3#3"J'8r`!!q[m!!2VB!!$
kf!!!qYJ!!2VB!!$krk!!q[mJm!$kr`!!q[m!!2VB&3!!qYJ!!2VB!!!6qYJ!!2V
r)!SJ#b!-!D!!)!Da%"6i!2Vr!!$kf!!!qYJ!!2VB!!$kf!!!qYJ!!2Vr!!$kr`!
!q[ri!2Vr%#B!!2Vr`!$krc$i!2Vr!*!%&3"!!"!"&!$&!!!"!!%!N!8#!*!&)J!
"!*!&"3!+!+-!V!#3"l3!2!$)!(B%"&0SEhF!!!%!!!!"2`!!!$m!!!"9!2!Xj"0
i!!!!(!"'!!&%6%p(!!!!%N4*9%`!!!!H!J#3#`)!rrm!!!!C!*!%$N*bEhGcCA)
JGfPZC'phVc!:
JGfPZC'ph%ES:
......@@ -44,10 +44,10 @@ directory <code>Mac/mwerks/projects</code> for the project files and
related stuff.
<LI> You need MetroWerks CodeWarrior. The current distribution has
been built with CodeWarrior Pro 1. Ordering information is
been built with CodeWarrior Pro 2. Ordering information is
available on the <A HREF="http://www.metrowerks.com/">MetroWerks
homepage</A>. You might still be able to build Python with MPW or
Think/Symantec C but you are basically on your own.
homepage</A>. Building Python with MPW or Think/Symantec C is
probably impossible without major surgery.
<LI> You need GUSI, the Grand Unified Socket Interface, by Matthias
Neeracher. The original CWGUSI is
......@@ -61,7 +61,7 @@ these modifications are available in folder <code>Python:Mac:GUSI-mods</code>.
<A NAME="optional">The MacPython project files are configured to
include a plethora of optional modules</A>, and these modules need a
number extra packages. To use the project files as-is you have to
number of extra packages. To use the project files as-is you have to
download these packages too. PPC and CFM68K Python have all such modules as
dynamically loaded modules, so if you don't need a certain package it
suffices to just refrain from builing the extension module. For static 68K
......@@ -81,8 +81,8 @@ below. Get the "full source" distribution, which includes MoreFiles.
<LI> Waste, a TextEdit replacement written by Marco Piovanelli, <A
HREF="mailto:piovanel@kagi.com">&lt;piovanel@kagi.com&gt;</A>. Python
was built using version 1.2, which you can obtain from <A
HREF="ftp://rhino.harvard.edu/pub/dan/WASTE">&lt;ftp://rhino.harvard.edu/pub/dan/WASTE&gt;</A>
was built using version 1.3, which you can obtain from <A
HREF="http://www.boingo.com/waste">&lt;http://www.boingo.com/waste&gt;</A>
and various other places.
<LI> Gdbm library for the Mac. Available from Jack's Mac software page at
......@@ -121,12 +121,12 @@ Top-level-folder:
zlib
libpng
gdbm
MoreFiles 1.4.3 (not needed by Python, only by tcl/tk)
Python
Tcl/Tk Folder
tcl8.0
tk8.0
Waste 1.2 distribution (if you want waste)
MoreFiles 1.4.3
Waste 1.3 distribution (if you want waste)
</PRE>
First build GUSI. If you didn't get the python-specific GUSI you have to
......@@ -137,7 +137,7 @@ platform (ppc, 68k, cfm68k). <p>
Next, in
<code>MoreFiles</code>, <code>libjpeg</code>, <code>pbmplus</code>,
<code>zlib</code>, <code>libpng</code>, <code>gdbm</code>,
and<code>libtiff</code> you build all projects. Sometimes the projects are in "mac"
and<code>libtiff</code> you build all projects. Usually the projects are in "mac"
subfolders, sometimes they are in the main folder. Tcl/tk is a special
case, see below. Of course, if you are only interested in one of
static 68K, CFM68K or PPC you can skip building the other libraries.
......@@ -174,14 +174,7 @@ building Python.
<H2>Building Waste</H2>
You do not need to build the Waste libraries, as Python includes the
source modules themselves. You have to make one modification,
though. In file <code>ICCFMGlue.c</code> in folder <code>Minimal IC
APIs</code>, add the following lines:
<blockquote><pre><code>
#include <Gestalt.h>
#include <Errors.h>
</code></pre></blockquote>
source modules themselves.
<H2>The organization of the Python source tree</H2>
......@@ -190,19 +183,16 @@ the Python source tree. At the top level, we find the following
folders:
<DL>
<DT> build.mac68k.stand
<DD> This is where you build static 68K interpreters.
<DT> build.mac68k.shared
<DD> This is where you build the CFM68K shared library, interpreter
and applet framework.
<DT> build.macppc.shared
<DD> This is where you build the PPC shared library, interpreter and
applet framework. You can also build the fat applet framework here.
<DT> build.macstand
<DD> This is where you build static 68K interpreter, and possibly (if
you want them) static PPC and fat interpreters. There is also a project
here that builds smaller versions of the static interpreter.
<DT> build.macppc.stand
<DD> This is where you build a nonshared PPC interpreter (optional).
<DT> build.mac
<DD> This is where you build the CFM68K, PPC and fat shared library,
interpreter and applet framework. The fat targets are deposited in the
main folder (one level up), the others, which are intermediate results
really, are left here.
<DT> Demo
<DD> Demo programs that are not Mac-specific. Some of these may not
......@@ -211,7 +201,7 @@ work, the file <code>README-Mac</code> has some details.
<DT> Extensions
<DD> Extensions to the interpreter that are not Mac-specific. Contains
only the <code>img</code> extension in this distribution. Extensions
are <em>not</em> built here, as they are on Unix, but incorporated in
are not always built here, as they are on Unix, but sometimes incorporated in
the core interpreter or built as plugin modules.
<DT> Grammar
......
......@@ -79,3 +79,4 @@ http://www.biap.com/datapig/mrwheat/cgi_params.html</a>. <p>
To test the script drop <code>cgitest.cgi.py</code> onto <code>mkapplet</code>,
move the resulting <code>cgitest.cgi</code> to somewhere where it is reachable
by NetPresenz, and point your web browser towards it.
</BODY></HTML>
......@@ -35,7 +35,12 @@ do for applets, by dragging your application to <code>EditPythonPrefs</code>. <p
The most logical way to embed Python is to link it against the shared
library <code>PythonCore</code>. An example project and source can be
found in the <a href="embed">embed</a> folder.
found in the <a href="embed">embed</a> folder. <p>
<b>Note</b>: you may think that you do not have the project file
<code>PythonCore</code> but actually you do: the standard installation
process deposits it in the <code>Extensions</code> folder in the system
folder under the name <code>PythonCore <i>version</i></code>. Add that file
to the project replacing <code>PythonCore</code>. <p>
</BODY>
</HTML>
......@@ -23,8 +23,8 @@ Python program to control and monitor the behaviour of the low-level
driver, and we will create the user interface around that. If you want
to actually run the code, you will obvously need InterSLIP and the
interslip module. The latter is available as a dynamically loadable
extension for PowerPC macs, and may be compiled in your Python
interpreter for 68K macs. As of this writing there is still a slight
extension for PowerPC/cfm68k Pythons, and may be compiled in your static 68K
Python. As of this writing there is still a slight
problem with the Python interslip module causing it to say "file not
found" if the driver is not loaded yet. The workaround is to load the
driver by starting InterSLIP Control and quitting it. <p>
......@@ -50,7 +50,8 @@ NAME="resource-numbering">resource numbering</A>. Because often your
resources will be combined with those that the Python interpreter and
various standard modules need you should give your DLOG and DITL
resources numbers above 512. 128 and below are reserved for Apple,
128-255 for the Python interpreter and 256-511 for standard
128-228 are for extensions like Tk,
228-255 for the Python interpreter and 256-511 for standard
modules. If you are writing a module that you will be distributing for
inclusion in other people's programs you may want to register a number
in the 256-511 range, contact Guido or myself or whoever you think is
......
......@@ -2,7 +2,7 @@
:&dPZG'9bFfaTF%0[ER4bEf`Y-5jbFh*M!(*cFQ058d9%!*!)!LIr03#3"!%!!!!
"``!!!--!!!"NCQBd4$9%-%3a4$*%-a*QCM-c0%8e46"&-88b46-5CQBA5@jdCA*
cE'P`3fpZG(*[E#da,R*cFQ-#!!!!FR0bB`!!FR0bBe*6483!N"LYGH)0!*!'!LF
cE'P`3fpZG(*[E#da,R*cFQ-#!!!!FR0bB`!!FR0bBe*6483!N"LZ9ed#!*!'!LF
cN!3d)!!e)!!`)!!a)!!b)!!c%M-c!!!d)!%e)!%`)!%a)!%b)!%c5b@U5bQU5bU
U5bZU5bbU5bfU5bkU5bp,0kT,1+T,1DT,1UT,1kT,2+T,2DT,2UT,2kT,3+T,3DT
,3UT,3kT,4+T,4DT,4UT,4kT,5+T,5DT,5UT,)!#U5b!!!!!9!'!!-J$!!C)!!3%
......@@ -11,4 +11,4 @@ ZEQ9MG!#3"6`!Y!"3!4F%$99`C'&dC5"cG'&dGA-!N!Bm!5)!8!&@"!44G@Pd!*!
&#J"D!"S"9BJ!N!BH!&S!,J&@L!#3"JS!#J!D!&@)"e0dBA4eFcTK!*!&(J!+!#i
!9BJ)6@9cFf&RC6S!!!%!!!!"``!!!--!!!"N!2!Xe"2@!!!!(!"'!!&%6%p(!!!
!%N4*9%`!!!!H!J#3#2!VV!)!!!m!!!!C!2!VE!j$EfjdFQpX)%4TB@a[C`j$Efj
dFQpX)'4TB@a[Ca4+:
dFQpX)'4TB@a[Cd#e:
......@@ -134,16 +134,20 @@ nothing has changed. <p>
Now let us try to turn the python script into an applet, a standalone
application. This will <em>not</em> work if you have the "classic 68k"
Python distribution, only if you have the cfm68k or PPC distribution.
Python distribution, only if you have the cfm68k or PPC distribution.
<blockquote>
Actually, "standalone" is probably not the correct term here, since an
applet does still depend on a lot of the python environment: the
PythonCore shared library, the Python Preferences file, the python Lib
folder and any other modules that the main module depends on. It is
possible to get rid of all these dependencies except for the dependency
on PythonCore, but at the moment that is still quite difficult so we
will ignore that possibility for now. By standalone we mean here that
possible to get rid of all these dependencies and create true standalone
applications in Python, but this is a bit difficult. See <a href="standalone.html">
Standalone Applications in Python</a> for details. For this
document, by standalone we mean here that
the script has the look-and-feel of an application, including the
ability to have its own document types, be droppable, etc. <p>
ability to have its own document types, be droppable, etc.
</blockquote>
The easiest way to create an applet is to take your source file and
drop it onto "BuildApplet", located in the Python home
......
......@@ -2,7 +2,7 @@
:&dPZG'9bFfaTF%0[ER4bEf`Y-LjbFh*M!(*cFQ058d9%!*!)$2eid3#3"!%!!!!
,T!!!#U3!!!&CCQBd4$9%-%3a4$*%-a*QCM-c0%8e46"&-88b46-5CQBA5@jdCA*
cE'P`3fpZG(*[E#db,R*cFQ-#!!!!FR0bB`!!FR0bBe*6483!N"LYGH)3!*!'$2d
cE'P`3fpZG(*[E#db,R*cFQ-#!!!!FR0bB`!!FR0bBe*6483!N"LZ9ed2!*!'$2d
cN!3d)!!e)!!`)!!a)!!b)!!c%M-c!!!d)!%e)!%`)!%a)!%b)!%c5b@U5bQU5bU
U5bZU5bbU5bfU5bkU5bp,0kT,1+T,1DT,1UT,1kT,2+T,2DT,2UT,2kT,3+T,3DT
,3UT,3kT,4+T,4DT,4UT,4kT,5+T,5DT,5UT,)!#U5b!!!!!9!'B!KJ$&!GB!!!%
......@@ -53,4 +53,4 @@ TBf`i!!!!YQPME$3!!!$#D@0c1!!!!-jTBh-d!!!!fQPMFb-!!!$Q58026J!!!2*
!!!!b!-3$U!#!rrm!!!"5!-3#X!#!rrm!!!"G!-3#Y!#!rrm!!!&K!-3#1!#!rrm
!!!9P!-3$D!#!rrm!!!GT!-3#+!#!rrm!!!KY!-3#2!#!rrm!!!Ma!-3#3!)"!"N
!!!SE!*!(*!!!#Tm!a!)X$N0[ER4bEf`J4'PKE'pR#8&LEh9d)'*[H!T"BQpeG#"
*BfpZ$NphEQ9b)(*PFfpeFQ0P$#`:
*BfpZ$NphEQ9b)(*PFfpeFQ0PX8S:
......@@ -85,6 +85,11 @@ how to build a PPC or 68K interpreter from a source distribution.
<A HREF="embed.html">Embedding Python on the Mac</A> is a minimal example of
how to embed Python in other Mac applications.
<LI>
<a href="standalone.html">Building Standalone applications in Python</a>
explains how you can create real standalone applications in Python. You do
need source (and a C development environment) for this at the moment.
</UL>
The Python distribution contains a few more examples, all unexplained:
......@@ -105,7 +110,9 @@ img modules on the mac.
<LI>
<I>Resources</I>, <I>Sound</I> and <I>Speech</I> have some examples
on using the respective managers.
on using the respective managers. In the <i>Mac:Lib</i> folder you
will also find modules that do useful things with the Communications
Toolbox, the Finder interface, etc.
</UL>
At some point in the (possibly distant) future, I will add chapters on
......@@ -117,12 +124,12 @@ your Python program scriptable, but that will have to wait. <p>
Please let me know if you miss critical information in this
document. I am quite sure that I will never find the time to turn it
into a complete MacPython programmers guide (which would probably be a
400-page book instead of 5 lousy html-files), but it should contain
400-page book instead of 10 lousy html-files), but it should contain
at least the information that is neither in the standard Python
documentation nor in Inside Mac or other Mac programmers
documentation. <p>
<HR>
<A HREF="http://www.cwi.nl/~jack">Jack Jansen</A>,
<A HREF="mailto:jack@cwi.nl">jack@cwi.nl</A>, 27-Aug-97.
<A HREF="mailto:jack@cwi.nl">jack@cwi.nl</A>, 25-Feb-98.
</BODY></HTML>
......@@ -26,8 +26,7 @@ Next, you need a <A
HREF="http://www.python.org/python/Sources.html">python source
distribution</A>. For PowerPC and cfm68k development you can actually
get by without a full source distribution, using the Development
distribution (if I have gotten around to putting it together by the time
you read this). You'll also need a functional python interpreter, and
distribution. You'll also need a functional python interpreter, and
the Modulator program (which lives in <CODE>Tools:Modulator</CODE> in
the standard source distribution). You may also find that Guido's <A
HREF="http://www.python.org/doc/ext/ext.html">Extending and embedding
......@@ -190,9 +189,9 @@ language" section of the MW preferences dialog, it will probably be
Make the new interpreter and check that you can import the module, see
the methods (with "dir(interslip)") and call them. <p>
<H2>Creating a PowerPC plugin module</H2>
<H2>Creating a plugin module</H2>
For PowerPC development you could follow the same path, but it is
For PowerPC or cfm68k development you could follow the same path, but it is
actually a better idea to use a dynamically loadable module. The
advantage of dynamically loadable modules is that they are not loaded
until a python program actually uses them (resulting in less memory
......@@ -211,6 +210,12 @@ of adjustments to the preferences:
<UL>
<LI> in PPC target, set the output file name to "interslipmodule.pcc.slb",
<LI> in cfm68k target set the output file name to "interslipmodule.cfm68k.slb".
<LI> if you are working without a source distribution (i.e. with a normal
binary distribution plus a development distribution) you will not have
a file <code>PythonCore</code>. The installation process has deposited this
file in the System <code>Extensions</code> folder under the name
<code>PythonCore <i>version</i></code>. Add that file to the project, replacing
<code>PythonCore</code>.
</UL>
Next, compile and link your module, fire up python and do the same
tests as for 68K python. <p>
......
<HTML><HEAD><TITLE>Creating true standalone applications in Python</TITLE></HEAD>
<BODY>
<H1>Creating true standalone applications in Python</H1>
<HR>
You can use Python to create true standalone macintosh applications: applications
that you can distribute to other people as a single file, without dependencies
on Python being installed, etc. The process is not easy, however, and at the
moment you need a source distribution (and a C development environment, CodeWarrior
most preferred). You should first familiarize yourself with the sections
<a href="building.html">building Python from source</a> and
<a href="example2.html">building applets</a>. <p>
The application we are going to build will contain a complete interpreter,
plus <code>'PYC '</code> resources for all the Python modules the program uses.
We start by creating a resource file that contains all the modules we need,
in PYC-resource form. There are two ways to do this:
<UL>
<LI> Modify the standard <code>freeze.py</code> module to print the names of
all modules used. Copy these to a single folder, run <code>compileall.py</code>
on that folder and then run <code>PackLibDir.py</code> from the scripts folder
to create the resourcefile. This has one disadvantage: freeze finds the modules
used by parsing your Python code, so modules you don't use (for instance because
they are system-dependent and not used on the mac) are also included. You
may also have problems with dynamically loaded modules. You will also have to rename
your main module to __main__.py.
<LI> Another way to find the modules used is by option-starting your script
and setting the "interactive mode after script" flag. Exercise every corner of
your program so all your modules have been imported, and when you exit your
program and get back to the interpreter use <code>findmodulefiles.findmodulefiles</code>
to get a list of all modules used. You can now use
<code>findmodulefiles.mkpycresourcefile</code> to create your resourcefile.
</UL>
Next we create the application project. Copy the <code>PythonStandalone.prj</code>
project, replace <code>macapplication.c</code> by <code>macapplet.c</code> and
replace <code>bundle.rsrc</code> by <code>appletbundle.rsrc</code>. Also
add the PYC resource file you made in the previous step and any other resource
files you need. Set the target output file names (for all three of ppc/68k/fat).
Build your application. <p>
Finally we have to give the application the right <code>sys.path</code> initialisation.
We do this by dropping the application on <code>EditPythonPrefs</code> and removing
all path components replacing them with a single <code>$(APPLICATION)</code>. You
may have to use ResEdit after this step to remove an "alis" resource from your application,
I am not sure why this is sometimes created. <p>
If you want to get fancy you may be able to make your application smaller by removing
all unused builtin modules. If you used the findmodulefiles method above to find
your modules you can start a standalone interpreter and use
<code>findmodulefiles.findunusedbuiltins</code> to get the names of all builtin
modules your program doesn't use. You can then create a private copy of
<code>config.c</code> from which you remove all unused modules.
</BODY></HTML>
......@@ -11,7 +11,7 @@ and is therefore easier integrated in Python. <p>
WASTE is written by Marco Piovanelli, <A HREF="mailto:piovanel@kagi.com">&lt;piovanel@kagi.com&gt;</A>,
and copyrighted by him. You can always obtain the latest version (for use in C
or Pascal programs) and the documentation from
<A HREF="ftp://ftp.dsi.unimi.it/DSI/piovanel/WASTE">&lt;ftp://ftp.dsi.unimi.it/DSI/piovanel/WASTE&gt;</A>.
<A HREF="http://www.boingo.com/waste/">&lt;http://www.boingo.com/waste/&gt;</A>.
We explain the useage of waste here by showing how to modify the TextEdit based
<A HREF="textedit/ped.py">ped.py</A> of the
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment