4

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?

Jonas
131k103 gold badges330 silver badges408 bronze badges
asked Mar 3, 2012 at 2:18
2
  • 1
    Do your friends have Windows, Mac, or Linux machines? Commented 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! Commented Mar 3, 2012 at 6:05

5 Answers 5

3

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 :) ).

answered Mar 3, 2012 at 3:11
Sign up to request clarification or add additional context in comments.

Comments

2

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
answered Mar 3, 2012 at 2:25

2 Comments

Provided everybody has identical versions of things. Otherwise the compiled file may or may not work.
True, but this is the best solution. Have any other ideas?
0

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.

answered Mar 3, 2012 at 3:05

Comments

0

Well since you're on a mac you could compile using py2app it will compile your code in a similar way to py2exe but for OSX.

Otherwise you could always transfer it to a windows computer and just use py2exe.

answered Mar 3, 2012 at 3:11

Comments

-1

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.

answered Mar 3, 2012 at 2:37

1 Comment

I'm on a mac. Would be great if I had a PC. Heard some nice things about that.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.