-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_exe.py
More file actions
75 lines (60 loc) · 2.4 KB
/
build_exe.py
File metadata and controls
75 lines (60 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import os
import subprocess
import shutil
def build_pos_exe():
"""Build POS system into executable"""
# Clean previous builds
if os.path.exists('dist'):
shutil.rmtree('dist')
if os.path.exists('build'):
shutil.rmtree('build')
if os.path.exists('main.spec'):
os.remove('main.spec')
# PyInstaller command
cmd = [
'pyinstaller',
'--onefile', # Single exe file
'--windowed', # No console window
'--name=POS_System', # Custom exe name
'--icon=icon.ico', # Add icon if you have one
'--add-data=pos_database.db;.', # Include database
'--hidden-import=tkinter', # Ensure tkinter is included
'--hidden-import=sqlite3', # Ensure sqlite3 is included
'main.py'
]
try:
print("Building POS System executable...")
result = subprocess.run(cmd, capture_output=True, text=True)
if result.returncode == 0:
print("✅ Build successful!")
print(f"📁 Executable location: {os.path.abspath('dist/POS_System.exe')}")
# Create a simple installer folder
installer_dir = "POS_Installer"
if os.path.exists(installer_dir):
shutil.rmtree(installer_dir)
os.makedirs(installer_dir)
# Copy exe and create sample database
shutil.copy('dist/POS_System.exe', installer_dir)
# Create README
with open(f'{installer_dir}/README.txt', 'w') as f:
f.write("""POS System Installation
=====================
1. Run POS_System.exe to start the application
2. Default admin password: admin123
3. The system will create a database automatically on first run
Features:
- Barcode scanning and product search
- Inventory management
- Sales tracking
- Receipt generation
- Automatic backups
Support: Check the source code for customization options.
""")
print(f"📦 Installer package created: {os.path.abspath(installer_dir)}")
else:
print("❌ Build failed!")
print("Error:", result.stderr)
except Exception as e:
print(f"❌ Build error: {e}")
if __name__ == "__main__":
build_pos_exe()