1

Possible Duplicate:
How do I protect python code?

How do I hide my python code, I don't want the code to be available to everyone to see.

I know python is interpreted, but is there a way, tool .. etc to allow someone to use the software without being able to see the code?

6
  • 2
    Short answer: You don't. Commented Jun 20, 2012 at 14:28
  • py2exe will compile it into a windows exe Commented Jun 20, 2012 at 14:28
  • Where is your code located? Is it on a server, if so what type of server? Commented Jun 20, 2012 at 14:28
  • 1
    @corn3lius no it won't. It will put the code with an interpreter inside an exe. You can still unzip it and get the code. Duplicate: programmers.stackexchange.com/questions/152920/… and stackoverflow.com/questions/11121764/hiding-python-code Commented Jun 20, 2012 at 14:29
  • @danseery its a desktop app ... so the code would be with the client. Commented Jun 20, 2012 at 14:45

4 Answers 4

8

You can reduce it to pyc files, but that's not really like full compilation. Python isn't really designed to be able to 'hide' code. The only way to fully hide implementation details that I know of is to deploy all your core logic on a server and expose it as services to your distributed app.

Sign up to request clarification or add additional context in comments.

Comments

3

Maybe Pyrex might help you. It is a python to C compiler ; it is intended to let you make modules available to python. That way, you could choose what to hide from the user (as it would be in an opaque module) and what to show.

2 Comments

(I think) Cython would do the same thing here (just another option). This is a pretty good suggestion though.
Although I don't believe that all python code is valid cython/pyrex code.
0

You could probably (after talking with some lawyers) plaster your code with license info (legally) preventing 3rd parties from using your code in ways that you don't want...but as other have said, if the user can run your code on their machines, they can "see" it (if they're determined enough at least) -- even if bundled in an exe or in pyc files...

Comments

-1

Compile it and/or create an executable file with it?

http://www.py2exe.org/

3 Comments

It won't help. User can still unzip the exe and get the code.
I was just thinking more for the average user who doesn't know how to do so. More often than not the end user won't know such or care.
The average user never cares. Usually you want to protect yourself against people who have at least some motivation. Python does not allow this level of protection. You have to use legal protection and offer a service which useful and complex enough for people to pay you for the support. If stealing you costs more than paying you, then you win.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.