Can .py be complied?

Maurice LING mauriceling at acm.org
Tue Apr 26 21:32:13 EDT 2005


monkey wrote:
> Hi all, I am new to programming, already have a glace on introduction of
> c++, java and finally decided on python. But I found that the .py file is
> just like the source file, how can I make a program without revealing its
> source? (may be my question is a little bit stupid)
> 
> 

It is generally not very easy or straight-forward. The developers of 
CPython had generally intended that the source codes be the actual 
distribution, and is not likely to change. (see the thread on "bytecode 
non-backcompatibility")

For now, you can use pyfreeze to snap the application, which is to 
bundle your application to a python interpreter (bootstrapping) as a 
package but this will not create a portable application. You can only 
run the application on the native system that it is frozen on. For 
example, if i freeze my application on Mac OSX, I won't be able to run 
that on MS Windows. Freezing bootstraps the system's python onto the 
application.

If your application does not use any C modules, you can try to use 
Jython instead. Program in python but use jythonc to convert it into 
Java source files and package it into Java JAR files, then you will only 
need to release the JAR files without needing to release your codes.

Cheers
Maurice



More information about the Python-list mailing list