Building the POS Executable
Relevant source files
The following files were used as context for generating this wiki page:This document outlines the process for building the standalone Windows executables for the POS Tio Adan project. The project consists of two primary applications, each with its own build script: the main Point of Sale (POS) GUI application and a background Telegram notification service. Both are built using PyInstaller, which packages the Python scripts and their dependencies into single .exe files.
The build process is managed by batch scripts (.bat) that automate cleaning previous builds, invoking PyInstaller with specific configurations, and summarizing the output. This allows for consistent and repeatable builds for deployment.
Build Architecture Overview
The project generates two distinct executables from two different Python source files. The following diagram illustrates the relationship between the source files, build scripts, and the final distributable artifacts.
This diagram shows that install_dependencies.bat prepares the environment for both Python scripts. Each script is then packaged by its corresponding build script into a final executable.
Sources: build_exe.bat, build_notification_exe.bat, install_dependencies.bat
Build Environment Setup
Before building the executables, the development environment must be set up with the necessary Python dependencies. The install_dependencies.bat script automates this process.
The script performs the following actions:
- Checks for Python: It verifies that Python is installed and accessible from the system's PATH.
- Installs Dependencies: It uses
pipto install the packages listed inrequirements.txt. The key dependencies arerequestsandpytz. - Creates Directories: It ensures the
logs/directory exists, which is used by the notification service. - Configuration Check: It warns the user if
config.jsonis missing, as it is required for the notification service to run.
Sources: install_dependencies.bat:8-49
Main POS Application (POS_TioAdan.exe)
The primary graphical user interface for the point-of-sale system is built from pos_app.py using the build_exe.bat script.
Build Process
The build_exe.bat script follows a three-step process to generate the executable.
This flowchart illustrates the execution flow of the build_exe.bat script.
Sources: build_exe.bat:11-45
PyInstaller Configuration
The build script invokes PyInstaller with a specific set of options to create a single, windowed executable.
| Option | Value | Description |
|---|---|---|
--onefile | - | Packages the entire application and its dependencies into a single .exe file. |
--windowed | - | Creates a GUI application that runs without a visible console window. |
--name | "POS_TioAdan" | Sets the name of the output executable to POS_TioAdan.exe. |
--hidden-import | openpyxl | Explicitly includes the openpyxl library, which is used for importing from XLSX files. |
--hidden-import | fpdf | Explicitly includes the fpdf library, used for generating PDF receipts and reports. |
Sources: build_exe.bat:20-23, pos_app.py:5, 6, 1718, 1852
Output and Runtime Behavior
The build process generates a single file: dist\POS_TioAdan.exe.
When run for the first time, the executable will create several files and folders in its directory or on the user's Desktop to store application data:
pos_inventory.db: The SQLite database for inventory and sales.recibos/(on Desktop): A folder to store generated PDF receipts. A fallbackreceipts/folder is created in the application directory if the Desktop is not accessible.reports/: A folder to store daily sales reports in PDF format.error_logs/: A folder for logs related to errors during XLSX imports.
Sources: build_exe.bat:34-41, [pos_app.py:680-698, 1708-1711, 2038-2041]
Telegram Notification Service (TelegramNotifications.exe)
A separate background service is built from notification_service.py using the build_notification_exe.bat script. This service monitors the POS database for out-of-stock products and sends alerts via Telegram.
Build Process
The build_notification_exe.bat script is similar to the main POS build script but is tailored for a background console application.
This flowchart shows the execution flow of the build_notification_exe.bat script.
Sources: build_notification_exe.bat:11-30
PyInstaller Configuration
The configuration for the notification service differs slightly, most notably using the --console flag instead of --windowed.
| Option | Value | Description |
|---|---|---|
--onefile | - | Packages the service into a single .exe file. |
--console | - | Creates a console application. A command window will be visible while the service is running. |
--name | "TelegramNotifications" | Sets the name of the output executable to TelegramNotifications.exe. |
--hidden-import | requests | Explicitly includes the requests library for making API calls to Telegram. |
--hidden-import | pytz | Explicitly includes the pytz library for timezone handling in the daily report scheduler. |
Sources: build_notification_exe.bat:20-23, notification_service.py:16, 17
Output and Deployment
The build process generates dist\TelegramNotifications.exe. For the service to function correctly, it must be deployed with additional files in the same directory:
config.json: Contains the Telegram bot token and chat ID.pos_inventory.db: The main POS database that the service monitors.
Upon first run, the service executable will also create:
notification_state.db: An SQLite database to track sent notifications and prevent duplicates.logs/: A directory for service and error logs.
Sources: build_notification_exe.bat:34-46, README_Notifications.txt:8-12, 22-23, [notification_service.py:31, 542]
Summary
The project's build system is designed to produce two independent, distributable executables from the Python source code. build_exe.bat creates the main POS_TioAdan.exe, a graphical application for daily sales and inventory management. build_notification_exe.bat creates TelegramNotifications.exe, a background console service for automated alerts. Both rely on PyInstaller and are configured through dedicated batch scripts to ensure all necessary dependencies are included.