Compilation python script

I am trying to send a python script that I wrote on my Mac to my friends. The problem is that I do not want to send them code that they can edit. How can I change my script from an editable text file to the program that you click to run?

+4
source share
5 answers

There is an equivalent py2exe called py2app . I have never tried, but there are a lot of good comments. It is available on macport , and the tutorial seems pretty simple (for simple cases at least :)).

+2
source

if you import it (from a shell or from another python application), it should create a .pyc file that python compiled. You cannot edit it using a text editor.

Example:

#test.py print "Hello, world." # python shell >>>import test 
+2
source

If your friends are on windows, you can use py2exe, but if they are on a Mac, I'm not sure if there is an equivalent. In any case, compilation like this violates cross-platform compatibility, which is actually the point of the interpreted language ...

Python is simply not configured to hide such code; it is against it, as far as I can tell.

0
source

Well, since you are on a Mac, you can compile with py2app , it will compile your code similar to py2exe, but for OSX.

Otherwise, you can always transfer it to a Windows computer and just use py2exe .

0
source

You can try py2exe (http://www.py2exe.org/), since it compiles your code into an exe file, they should have some time trying to decompose it.

-one
source

Source: https://habr.com/ru/post/1399504/


All Articles