[Tutor] How do we make a program to be executed...

Kirby Urner urnerk@qwest.net
Thu, 21 Feb 2002 00:51:15 -0800


At 10:04 AM 2/21/2002 +0200, Thanos wrote:

>Win98, and the python 2.1.2 version.
>Thanks,
>Thanos

The short answer is Python doesn't compile, as it's an
interpreted language and needs a runtime library (as
the Microsoft people call it).

This is similar to Visual Basic and Visual FoxPro and
others, which also need runtimes (sometimes several
megabytes of .dll files).

And even C/C++ usually relies on external libraries such
as msvcr70.dll and numerous other msvcr*.dll you'll find
in your c:\windows\system.  So the whole idea of a true
"standalone" exe file is a bit of a myth -- they exist of
course, but are less common that one might suppose.

In any case, there's a minimal set of files a target computer
needs, to run anything you've written in Python.  If you
don't want to share source code, you can just transfer
the .pyc files.  If you're using Tk or another widget tool,
then there's that whole business to worry about.

There's a utility out there that'll bundle your python program
with the necessary dll runtime stuff into a big exe file
(sorry, I've never used it).  But you don't want each little
python script to get that whole big add-on bundled with it
each time.  A better approach is to keep the dll stuff
unbundled, so everything you write can share it.

But in my opinion, really the best solution is to install a
full Python x.x on any target machine on which you plan to
run .pyc or .py (or .pyd) files.

That's not the "Microsoft way" of course, as MSFT charges
money for the developer platform, and then makes the runtime
piece royalty free (distributable by the developer).  But
all of core Python is free, so you might just as well set
up any target machine as an optional development platform,
even if the user never intends to use it that way.  It takes
an adjustment in thinking:  welcome to open source.

OK, so that turned out to be the long answer.  And I probably
missed what you really wanted.  Maybe others will do better
on that score (so far, I've always followed my own advice
and just put a full Python on any target).

Kirby