|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
What is the command that will compile a python code to binary ?
1) What is the command that will compile a python code to binary ?
2) Is is true that a compiled Python code can be easily converted back to source code much easier than C code ? |
|
#2
|
||||
|
||||
|
Windows - You need an application called py2exe.
http://forums.devshed.com/t137769/s...ighlight=py2exe Linux - you could try cxFreeze Because python compiled code is stored in a form that is closer to the original script (bytecode) it is easier in theory to reverse engineer than the machine code generated by a C compiler. You can use a command line optimization -o to reduce the amount of human readable info stored in the bytecode to make the task harder. grim ![]()
__________________
*** Experimental Python Markup CGI V2 *** |
|
#3
|
||||
|
||||
|
You can also use the -OO option on the command line to further reduce the chances though this results in docstrings being removed from your program which you might want to avoid
![]() Mark. |
|
#4
|
|||
|
|||
|
It's not only easier in theory to reverse-engineer Python code, it's easier due to the fact that there exists a tool that can reliably do it. Google for "decompyle" for more info.
|
|
#5
|
|||
|
|||
|
Thank you everyone for your help.
|
|
#6
|
|||
|
|||
|
Hi netytan, thank you for your help.
You said "You can also use the -OO option on the command line to further reduce the chances though this results in docstrings being removed from your program which you might want to avoid " Do you mean ./python_program -OO If not the above then please specify the exact command. |
|
#7
|
||||
|
||||
|
Python command like arguments follow the interpreter, so something like this, assuming you have python in you PATH variable...
python -OO program.py Hope this helps, Mark. |
|
#8
|
|||
|
|||
|
Thank you netytan for your help.
|
|
#9
|
|||
|
|||
|
Hi again netytan.
I ran the command below, but no binary file was created, and the file python_1.py remains as text. python -OO python_1.py |
|
#10
|
||||
|
||||
|
Please read Section 6.1.2 of the Python Tutorial that ships with Python. It explains the -O and -OO options.
grim. ![]() |
|
#11
|
|||
|
|||
|
Python source code ( my_prog.py ) is always text.
When you run it through the interpreter (Python.exe) it converts the text to a "byte-code" that it can read. These end in .pyc - my_prog.pyc If you use python.exe -OO it will remove the comments from the byte-code file. Python.exe can not create Windows or Linux executable binaries though. For that you need a tool like py2exe which Grim_Archon linked to. |
|
#12
|
|||
|
|||
|
Thank you sfb for your help.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > What is the command that will compile a python code to binary ? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|