Use Nuitka to compile Python Codes to Binary file

pip install nuitka patchelf ordered-set zstandard

python3 -m nuitka --follow-imports --standalone --onefile  --remove-output --output-filename="program.run" main.py

# or

python3 -m nuitka --follow-imports --standalone --output-dir="excutable" main.py



Why I say Python is better than C/C++

  1. Python is made for human (codes writing like English speaking)
  2. Python can be running at every platform after you compile it to binary file by using Cython or Nuitka
  3. Python has countless packages also was intended for humans

How to compile Python codes to binary?

1. Let’s say you have a package in this structure:

└── auto_everything
    ├── __init__.py
    ├── base.py
    ├── video.py
    └── web.py

2. After Nuitka was installed, run the following commands:

cd ..
python3 -m nuitka --module auto_everything --output-dir=outputs

or

cd ..
python3 -m nuitka --module auto_everything --include-package=auto_everything.base,auto_everything.video,auto_everything.web --output-dir=outputs

3. Then you will found you can use auto_everything.so like this:

# cd outputs && python3
import auto_everything

or

# cd outputs && python3
from auto_everything.base import Terminal
t = Terminal()
print(t.run_command("echo hi"))