crazedsuirlz
crazedsuirlz

Reputation: 75

"Compiling" python script

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?

Upvotes: 4

Views: 4736

Answers (5)

Zenon
Zenon

Reputation: 1509

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

Upvotes: 3

Symon
Symon

Reputation: 2220

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.

Upvotes: 0

analystic
analystic

Reputation: 351

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.

Upvotes: 0

AI Generated Response
AI Generated Response

Reputation: 8835

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.

Upvotes: -1

ntaggart
ntaggart

Reputation: 577

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

Upvotes: 2

Related Questions