I'm trying to send a python script I wrote on my Mac to my friends. Problem is, I don't want to send them the code that they can edit. How can I have my script change from an editable text file, to a program that you click to run?
-
1Do your friends have Windows, Mac, or Linux machines?Adam Mihalcin– Adam Mihalcin2012-03-03 02:38:58 +00:00Commented Mar 3, 2012 at 2:38
-
You can wrap up the interpreter and the source code into an executable. But they will still be able to access the source code if they want to!wim– wim2012-03-03 06:05:16 +00:00Commented Mar 3, 2012 at 6:05
5 Answers
There is an equivalent to py2exe called py2app. I never tried it but there is a lot of good comments. It is available on macport and the tutorial seems pretty simple (for simple cases at least :) ).
Comments
if you import it (from the shell, or from another python app), it should create a .pyc file, which is compiled python. You shouldn't be able to edit it through a text editor.
Example:
#test.py
print "Hello, world."
# python shell
>>>import test
If your friends are on windows you could use py2exe, but if they're on Mac I'm not sure there's an equivalent. Either way, compiling like that breaks cross platform compatability, which is the whole point of an interpreted language really...
Python just isn't really set up to hide code like that, it's against it's philosophy as far as I can tell.
Comments
You could try py2exe (http://www.py2exe.org/) since it compiles your code into an exe file, they should have a hell of a time trying to decompose it.