91 lines
2.4 KiB
Python
91 lines
2.4 KiB
Python
# -*- mode: python ; coding: utf-8 -*-
|
|
|
|
import os
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
project_root = (
|
|
os.path.abspath(os.path.dirname(__file__))
|
|
if "__file__" in globals()
|
|
else os.path.abspath(os.getcwd())
|
|
)
|
|
|
|
|
|
def find_tcl_runtime_directory(environment_name, directory_prefix, marker_file):
|
|
configured_path = os.environ.get(environment_name)
|
|
if configured_path and os.path.isfile(os.path.join(configured_path, marker_file)):
|
|
return os.path.abspath(configured_path)
|
|
|
|
tcl_root = Path(sys.base_prefix) / "tcl"
|
|
for candidate in sorted(tcl_root.glob(f"{directory_prefix}*"), reverse=True):
|
|
if (candidate / marker_file).is_file():
|
|
return str(candidate.resolve())
|
|
|
|
return None
|
|
|
|
|
|
datas = [
|
|
(os.path.join(project_root, "picture", "ICON", "icon_client.png"), "picture/ICON"),
|
|
(os.path.join(project_root, "picture", "Client", "Connect", "connected.png"), "picture/Client/Connect"),
|
|
(os.path.join(project_root, "picture", "Client", "Connect", "no-connection.png"), "picture/Client/Connect"),
|
|
]
|
|
|
|
if os.name == "nt":
|
|
tcl_library = find_tcl_runtime_directory("TCL_LIBRARY", "tcl", "init.tcl")
|
|
tk_library = find_tcl_runtime_directory("TK_LIBRARY", "tk", "tk.tcl")
|
|
if not tcl_library or not tk_library:
|
|
raise RuntimeError(
|
|
"Tcl/Tk data directories were not found. "
|
|
"Install Python with Tcl/Tk support or set TCL_LIBRARY and TK_LIBRARY."
|
|
)
|
|
datas.extend([
|
|
(tcl_library, "_tcl_data"),
|
|
(tk_library, "_tk_data"),
|
|
])
|
|
|
|
a = Analysis(
|
|
["client_agent_v2.py"],
|
|
pathex=[project_root],
|
|
binaries=[],
|
|
datas=datas,
|
|
hiddenimports=["pystray", "pystray._win32", "PIL.Image", "PIL.ImageTk"],
|
|
hookspath=[],
|
|
hooksconfig={},
|
|
runtime_hooks=[],
|
|
excludes=[],
|
|
win_no_prefer_redirects=False,
|
|
win_private_assemblies=False,
|
|
noarchive=False,
|
|
)
|
|
|
|
pyz = PYZ(a.pure)
|
|
|
|
exe = EXE(
|
|
pyz,
|
|
a.scripts,
|
|
[],
|
|
exclude_binaries=True,
|
|
name="Inv_web Client",
|
|
debug=False,
|
|
bootloader_ignore_signals=False,
|
|
strip=False,
|
|
upx=False,
|
|
console=False,
|
|
disable_windowed_traceback=False,
|
|
argv_emulation=False,
|
|
target_arch=None,
|
|
codesign_identity=None,
|
|
entitlements_file=None,
|
|
icon=os.path.join(project_root, "picture", "ICON", "icon_client.ico"),
|
|
)
|
|
|
|
coll = COLLECT(
|
|
exe,
|
|
a.binaries,
|
|
a.datas,
|
|
strip=False,
|
|
upx=False,
|
|
upx_exclude=[],
|
|
name="Inv_web Client",
|
|
)
|