views:

165

answers:

4

This is mostly just because I'm curious, but how would one distribute a closed source python program since python is run from source and its bytecode is easily decompiled? I'm mostly asking for linux since I don't care about windows, but any answers are great.

Edit: Thanks for the answers guys. I was just curious since I just got my first job as a software engineer and my first project I'm working on is in python. Personally I'm all for open source, I was just curious how proprietary python programs could be distributed.

+5  A: 

You can only make it harder to get at the source code, e.g. by using Py2Exe (for Windows) or Freeze for Linux. There are also obfuscators available for python. But you're only making it a bit harder to understand what you're doing in your code, not impossible.

Ask yourself if it is really worth your effort to try to prevent reverse engineering your code.

Fabian
I think the important part is to realize that nobody cares about your precious source code. Locking it up only makes it hard to debug and fix it. If somebody wants to steal your ideas, they will write their own version anyways -- reading code is harder than writing it, so adopting your code and understanding it so that it can be maintained and enhanced is much more work than reimplementing the whole thing.
Radomir Dopieralski
I generally agree with that. There are some exceptions like licensing/copy protection code, but you usually won't implement those in python.
Fabian
+2  A: 

I think one "think-outside-the-box" solution would be to put important parts of the application on a server and let the distributed program talk to the server. This solution will only work for a (small?) subset of programs of course, since it always needs an Internet connection*, but it might be worth looking into.

*) sometimes it might be possible to combine with a caching solution, when new data is needed only now and then.

Peter Jaric
+2  A: 

There are a number of ways to "protect" your code if you really think this is necessary:

  • You can add C or Pyrex based binary code to your project containing critical (algorithmic) code or licensing checks.
  • Implement your software as some sort of webservice / ASP / SaaS. Either provide a web application on top of it or distribute a client application (as .pyc or not).

But is it really worth the trouble? What are the chances your expected customers will care about the source code. And if they do, isn't it an advantage / selling point to provide this source code?

Ivo van der Wijk
+1  A: 

The question of whether a program is open source or closed source is a legal question, not a technical one. So, the way to make a Python program closed source is to simply not put an open source license on it, since closed source is the default by law. In other words: just do nothing at all.

Jörg W Mittag