All posts

How I Automated Building Multiple Games with Python

Building a lightweight Python build system to scan projects, compile sources, organize outputs, and generate metadata — without the manual busywork.

#python#automation#build-tools

Introduction

When working on multiple small game projects, I noticed that repeating the same setup and build steps quickly became inefficient. Copying folders, compiling files manually, renaming directories, and organizing builds was repetitive and easy to mess up.

To solve this, I built a Python automation script that handled the process automatically. The goal was to create a lightweight build system capable of scanning projects, compiling files, organizing outputs, and generating metadata with minimal manual work.

The Problem

Managing several small game projects manually created a few issues:

  • repetitive build workflows
  • inconsistent naming
  • unnecessary time spent preparing releases
  • difficulty keeping project structures organized

Even with smaller projects, these tasks added friction every time I wanted to update or rebuild something.

Building the Automation Script

The script was designed to:

  • scan project folders automatically
  • identify valid game projects
  • compile source files
  • copy builds into release folders
  • generate metadata dynamically

I used Python modules such as os, shutil, subprocess, and json.

The script recursively searched directories using os.walk():

for root, dirs, files in os.walk(projects_dir):
    if "main.py" in files:
        build_project(root)

Once a project folder was detected, the build process started automatically.

Automating the Build Process

The automation handled several steps:

  1. deleting old build directories
  2. creating clean release folders
  3. compiling source files
  4. copying required assets
  5. renaming folders into cleaner output names

To compile projects, I used subprocess.run(), which let Python execute shell commands directly from the script:

subprocess.run(
    ["pyinstaller", "--onefile", "main.py"],
    cwd=project_dir,
    check=True,
)

Dynamic Metadata Generation

One feature I wanted was automatic metadata generation. The script created a metadata.json file containing game names, the number of projects, and release information.

{
  "gameNames": ["snake", "space_invaders"],
  "numberOfGames": 2
}

This removed the need to manually update configuration files whenever new projects were added.

Problems I Encountered

During development, I ran into several issues:

  • incorrect path handling
  • recursion problems
  • inconsistent file naming
  • builds targeting the wrong files

Some bugs only appeared when working with nested folders or multiple projects at once, which forced me to improve how the script handled paths and directory structures.

Debugging these problems helped me better understand filesystem operations, automation workflows, subprocess management, and scalable scripting design.

What I Learned

This project improved my understanding of Python automation, build workflows, recursive file handling, JSON generation, and process management. It also showed me how much time automation can save, even on smaller personal projects.

In the future, I would like to expand the system with:

  • parallel builds
  • structured logging
  • external configuration files
  • CI/CD integration