0

Greetings!

So contrary to my last question I think I was pursuing the wrong method. Basically I need to be able to compile a Python script without fear of any common leecher to obtain my source code and begin usage of it themselves. Now I know Python is a open source language not meant for being protected but there must be a way?

For example Py2Exe asks you to leave your source code in a plain text file for it then to be compiled. Which is exactly not what I'm wanting. The whole reason for this is that compilation will be happening not just on my own PC. My project is going to be compiled to PE executable form and is intended for public use and I can't have them simply opening and viewing my source.

Can anyone aid me?

mtrw
  • 34,200
  • 7
  • 63
  • 71
Morphine
  • 643
  • 2
  • 6
  • 11

4 Answers4

3

You can search for a Python obfuscator or scrumbler but there will be no solution that will protect you intellectual property anyway. If you have developed something completely new go for a patent and try to control it.

In the meantime continue reading at How do I protect python code?.

Community
  • 1
  • 1
Raphael Bossek
  • 1,904
  • 14
  • 25
  • Yes, read the linked question, and particularly the highest-voted answer: http://stackoverflow.com/questions/261638/how-do-i-protect-python-code/261727#261727 – Fred Larson Jan 04 '11 at 23:35
2

There's no way to protect anything completely against reverse engineering. Some things you can do:

  • distribute the .pyc files. This requires slightly more effort to reverse engineer
  • Use an obfuscator (there aren't a lot of these out there and I haven't found any I would call first class)
  • Write critical sections (maybe license checks, etc.) in c and call into them
  • Write critical sections as web services

If you distribute .pyc or py2exe, most people will probably never look at your code. IF someone reverses engineers your code from the byte code, what's the big deal? If they're determined enough, they could just write their own application. Don't worry about it so much and ship your application if it's great enough to be protective of the source.

marr75
  • 5,666
  • 1
  • 27
  • 41
1

Well, its not very likely to happen anytime soon - Python simply is an interpreted language that is not readily fit for compilation to native code. What you could do, however, is to use Cython to create a Python extension using Cython's Python-like syntax, compile this to native code and bundle it with a "harmless" application that makes use of your extension module while at the same time making your IP harder to obtain.

You might also try ShedSkin, a native Python to C++ compiler, but you will soon find it very limited.

Still, you might consider if all that is really worth the effort - most of the time it is not.

Jim Brissom
  • 31,821
  • 4
  • 39
  • 33
1

You could contact the author of Nuitka to see if it could help with distribution of non-readable code.

Edit: Try the Google cache...

TryPyPy
  • 6,214
  • 5
  • 35
  • 63