Python & Linux ?

Magnus Lycka magnus at thinkware.se
Tue May 22 11:53:46 CEST 2001


Niklas Frykholm wrote:

> Not all wrong, but not all right either. Python is interpreted, this means
> that you need the Python interpreter to run your programs.

To be picky, Python programs are not interpreted (like shell scripts),
they are runtime compiled (like java). You compile a python program
as soon as you import it. That leads to the creation of a .pyc file,
which corresponds to a .class file in java.

Just as in Java, this is not a platform specific executable, but
byte-code which needs a particular run-time system to support it. In
difference from Java, Python byte-code is not completely portable
(I think). AFAIK 64 bit and 32 bit machines use integers of different
size, and maybe big-endian and little-endian matters as well? This
is rarely a problem, and it might well be fixed in the future.

The python program, python.exe or pythonw.exe in Windows, is both
a compiler and a provider of the "virtual machine". Just as in any
other language, your program will also rely on a number of external
libraries that needs to be provided.

So, comparing Python to Java is probably a better analogy than comparing
to shell scripts. Whether scripts are programs or not, is a semantic
issue I won't go into. You are right in understanding that you can't
simply take a .py or .pyc file and run it in a computer which is not
prepared for running python programs.

On the other hand, that is true for VB as well. You certainly need
the right set of DLLs to run your VB programs, and if your target
computer doesn't have Windows...you're in trouble. (I guess you can
run some VB programs in Linux with Wine etc.)

Most modern Linux machines run python out of the box. If you don't
want to disclose your source code, distribute .pyc files. These
files can be disassembled, but for a large application, this is
still much more cumbersome than reading source. The best way to
protect your intellectual property is probably through copyright
though.

Unfortunately, there is not one, simple way to ship Python apps.
The Python community usually frowns on the Perl motto: "There is
more than one way to do it", and tries to make things as straight
forward as possible. In the case of installing and distribution,
there is a number of soultions, although the one and only true
solution--distutils is improving gradually...but it might still
not quite fit your purposes...

There are some info on programs to help you install python programs
at http://www.thinkware.se/cgi-bin/thinki.cgi/PythonSoftware

/Magnus

-- 
Magnus Lyckå | Älvans väg 99 | magnus at thinkware.se | tel: 070-582 80 65
Thinkware AB | 907 50  UMEÅ  | www.thinkware.se    | fax: 070-612 80 65



More information about the Python-list mailing list