Those of you who know Python know that Pyinstaller can package.py files into.exe files that can be executed on Windows, but it can’t do that if you don’t want someone to decompile the source code, you can look at.pdy files.
PYD
Pyc is a binary file generated by the Python compiler. It is fast to load. Pyo is an optimized compiled binary that can be generated using python -o file.py. Pyd is a dynamically linked library for Python, written in other languages.
Can. Pyd be decompiled?
Pyd is made up of C or C++ compilations. Whether it is completely undecompilable or not, I believe, is impossible. It just makes decompilation more difficult.
packaging
You need to install Cython and PyInstaller as dependencies. Docs
- Write the primary agent to
main_code.py
In the document, it is recommended to provide entry functionsmain()
- write
build.py
Agent and type the following:from distutils.core import setup from Cython.Build import cythonize setup( name="Write whatever you want.", ext_modules=cythonize([ "main_code.py".# Your main code encapsulates the filename]))Copy the code
- perform
python3 build.py build_ext --inplace
generate.pyd
file - Rename generated
.pyd
为main_code.pyd
- Create an execution script file
run.py
And type the following:from main_code import * if __name__ == '__main__': main() Copy the code
At this point you can try to modify
main_code.py
Change the name to something else and runrun.py
The file you will find works fine. - perform
pyinstaller -D -i xxx.ico -w run.py
Eventually you will find that the main logic for.pyc is missing from your code.
instructions
To use -d instead of -f for packaging?
It is too slow after generating a unique.exe file, of course I only recommend that you use any custom way to compile the effect you want.
Give it a thumbs up