Skip to content

Build a binary version of Python code

123


Step 1: Install PyInstaller

On your local machine, run:

pip install pyinstaller

Step 2: Build the Binary

Assuming your main entry point is src/main.py, from your repo root run:

python -m PyInstaller --onefile main.py --name <projectname>

This will create a single binary called (or .exe on Windows) in the dist/ folder.

Step 3: Test the Binary

Go to dist/ and run the binary to ensure it works.

Step 4: Add Binary to GitHub (Best Practice)

You should not commit binaries directly to your repo! Instead, binaries should go in GitHub Releases so your repo stays clean and versioned.

A. Add a Release

Push your code changes (if you haven’t already):

git add .
git commit -m "Add PyInstaller build guide"
git push
  • Go to your repo on GitHub
  • Click "Releases" > "Create a new release"
  • Fill in the release info:
    • Tag version (e.g. v1.1.0)
    • Title (e.g. "Binary Release v1.1.0")
    • Description: explain what’s new.
  • Upload your binary
    • Drag the dist/.exe (Windows)
  • Publish the release.

B. Add Build Instructions to README

Add a section to your README.md explaining how to build the binary, e.g.: