Protect Python Source

TuxTrax TuxTrax at fortress.tuxnet.net
Fri Nov 1 06:20:06 EST 2002


On Fri, 1 Nov 2002 16:35:28 +0800, hope Wrote in
Steve Ballmers hair grease:

> Hi,
> 
> If i am to develop a full fledge commercial application using Python :
> 
> a. Can i compile my python source into binary ? I have read about py2exe for
> windows. Is there one for Linux ?
> 
> b. Can I distribute the bytecode only (.pyo, .pyd) and not the source (.py)
> ? Can the bytecode be 'de-compiled' to source ?
> 
> Please advice.
> 
> Cheers,
> Peter

Hello Peter.

You ask good questions here, and give me an opportunity to present to you
some ideas you may not have yet considered.

First to answer your questions:

As you probably know, python is an interpreted language that does not lend
itself well to compiling. When you use the traditional compiler, you 
convert to binary and link to executable, your source code. Think of it 
this way: The interpreter is a compiled program that runs your code. In order
for your code to run, the interpreter has to be present. Py2exe therefore has
to compile your program, all it's modules, *and* the interpreter into one
package. I don't know from experience, but have read, that this process can
present difficulties and may not work with all programs. Others who have 
real experience can no doubt tell you more on this count. As for whether
or not this type of pseudo-compiler is avaialable for Linux, I am going to
address that question in a bit.

Can you distribute the bytecode and not the source? My friend, you can 
distribute it any old way you want. More on this to come. Can bytecode be
decompiled? Anything can be decompiled. You should know that compiling is
not the security that many believe it to be. Just because a program is
compiled does not mean it is safe from prying eyes. It is trivial to obtain
decompiling software for traditionally compiled languages. 

I want you to read and consider what I am about to write, and I don't want
you to feel that I am in any way attacking you. I'm not. But I feel a few
well placed observations are in order.

Your comments reveal a thoughtful and curious approach that is quite healthy.
It also reveals a world view that has in large part been shaped by the
philosophies of proprietary software companies.

Is a python compiler available for linux? I don't know. I do know that no
Linux users I know would even consider using one. It would never cross our
minds to make our source closed to others. This is where the whole open source
software movement takes a completely different world view. In open source
software, you retain the right to make a profit from your work, while still
granting others the right to copy, distribute, modify and view the source
code. Just a year ago, this whole concept was horrifying to me. I could
not concieve of allowing others to have free access to my source code. As
a Long time windows user, I had some un-learning to do. But unlearn I did.
I started thinking in terms of the advantages of open source. First, it keeps
you honest; you write your best code because you know that your peers are
going to be seeing it all over the world. Second, with open source, once
you release it, other programmers may modify it helping it to become more
than you ever could have made it on your own (unless you choose to forbid
the modification of your code, but that's another subject). Third, the
distribution of your product using the open source community, has no equal,
and will cost you nothing. You can provide support to your users via
that same community at little or no cost to you, and support is the number
one ongoing cost that software developers get saddled with. You can use
the resources of such organizations as the free software foundation to
defend your copyright (don't let the "free" in FSF throw you; you can still
market your product using the GPL licence).

And finally, you get to give something back. This is a philosophical point
for me, but giving something back to the community that you benefit from,
whether it be your local community, or the computer community, is very 
important for us as people. It is a common and refreshing view that you
will find in the open source world, and one reason that I left the
windows world for good. But thats a soapbox for another time. <grin>

Cheers,

Mathew

-- 
My Family is Microsoft Free. Running Mandrake Linux 8.0 kernel 2.4.3-20
I use quality open source software alternatives on my PC.

Yes, I am a Penguin cult high priest. Flipper readings upon request.

ROT13 this email address to mail me:
bar jbeq abg guerr - uvtu qrfreg zna, ng lnubb qbg pbz




More information about the Python-list mailing list