Files
build-python/README.md
2025-11-02 12:33:15 -03:00

4.3 KiB

🚀 PyInstaller Automation Tool

A powerful and interactive Python script that automates the process of creating executables from Python scripts using PyInstaller. This tool provides a user-friendly menu-driven interface to configure and build your applications with ease.

📋 Features

  • 🖥️ Interactive Menu - Easy-to-use terminal interface
  • Quick Configuration - Set all PyInstaller options through simple prompts
  • 📦 Multiple Build Modes - Choose between one-file or one-directory compilation
  • 🎯 Platform-Specific - Builds for your current operating system
  • 🔧 Customizable Options - Icon, console mode, optimization levels, and more
  • 📁 Additional Files Support - Include extra files and directories in your build
  • Build Summary - Review your configuration before compiling
  • 🛡️ Error Handling - Comprehensive error checking and feedback

🚀 Quick Start

Prerequisites

  • Python 3.6 or higher
  • PyInstaller (will be installed automatically if missing)

Installation

  1. Download the script:

    wget https://git.opentty.xyz/fetuber4095/build-python/raw/branch/master/build.py
    
  2. Make it executable (Linux/Mac):

    chmod +x build.py
    

Usage

  1. Run the script:

    python build.py
    
  2. Follow the interactive prompts:

    • 📜 Script Path - Enter the full path to your Python file
    • 📦 Compilation Mode - Choose between single executable or directory with dependencies
    • 🖥️ Console Mode - Select whether to show console window or run as GUI application
    • Optimization - Choose Python optimization level
    • 🎨 Custom Icon - Add a custom icon to your executable
    • 📁 Additional Files - Include extra files needed by your application
  3. Review and confirm the build summary

  4. Wait for compilation - The tool will automatically run PyInstaller with your selected options

🛠️ Configuration Options

Build Modes

  • One-file: Creates a single executable containing all dependencies
  • One-directory: Creates a folder with the executable and all dependency files

Console Options

  • With console: Shows terminal window (ideal for CLI applications)
  • Without console: Runs as background process (ideal for GUI applications)

Optimization Levels

  • No optimization: Standard compilation
  • Basic optimization (-O): Removes assert statements and debug code
  • Maximum optimization (-OO): Additional bytecode optimization

Additional Features

  • Custom icons (.ico for Windows, .png for Linux/Mac)
  • File inclusion - Add data files, images, or configuration files
  • UPX compression - Reduce executable size (enabled by default)

📁 Output Structure

After successful compilation, your files will be organized as follows:

project/
├── build.py
├── your_script.py
├── dist/
│   ├── your_script          # Linux executable
│   ├── your_script.exe      # Windows executable
│   └── your_script/         # Directory mode output
├── build/
│   └── temporary_files/
└── your_script.spec         # PyInstaller specification file

💡 Usage Examples

Basic GUI Application

python build.py
# Select: One-file, Without console, Add icon

Command Line Tool

python build.py
# Select: One-file, With console, No optimization

Application with Data Files

python build.py
# Select: One-directory, Add additional files (config, images, etc.)

🐛 Troubleshooting

Common Issues

  1. PyInstaller not found

    • The script will automatically offer to install it
    • Or install manually: pip install pyinstaller
  2. Missing dependencies

    • Ensure all Python imports in your script are available
    • The tool will show PyInstaller's error messages for debugging
  3. Large executable size

    • Use UPX compression (enabled by default)
    • Consider one-directory mode for very large applications
  4. Anti-virus false positives

    • Some anti-virus software may flag PyInstaller executables

📄 License

This project is open source and available under the MIT License.

🙏 Acknowledgments

  • Built with PyInstaller
  • Inspired by the need for simpler executable creation workflows