43 lines
1.1 KiB
Python
Executable File
43 lines
1.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
Script per creare un eseguibile standalone (Windows .exe, Linux binary, macOS binary)
|
|
con PyInstaller in un singolo file.
|
|
"""
|
|
|
|
import os
|
|
import platform
|
|
import subprocess
|
|
import sys
|
|
|
|
|
|
def build():
|
|
print(f"[+] Compilazione eseguibile per {platform.system()}...")
|
|
try:
|
|
import PyInstaller
|
|
except ImportError:
|
|
print("[!] PyInstaller non installato. Installazione in corso...")
|
|
subprocess.check_call([sys.executable, "-m", "pip", "install", "pyinstaller"])
|
|
|
|
cmd = [
|
|
sys.executable,
|
|
"-m",
|
|
"PyInstaller",
|
|
"--name=barcode_server",
|
|
"--onefile",
|
|
"--clean",
|
|
"--hidden-import=pystray",
|
|
"--hidden-import=PIL",
|
|
"--hidden-import=qrcode",
|
|
"--hidden-import=aiohttp",
|
|
"main.py",
|
|
]
|
|
|
|
print(f"[+] Comando: {' '.join(cmd)}")
|
|
subprocess.check_call(cmd)
|
|
print("\n[✔] Compilazione completata con successo!")
|
|
print(f"[✔] L'eseguibile si trova nella cartella: {os.path.abspath('dist')}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
build()
|