diff --git a/compilation/installer_client.iss b/compilation/installer_client.iss index 0a4ef43..fc65770 100644 --- a/compilation/installer_client.iss +++ b/compilation/installer_client.iss @@ -1,4 +1,4 @@ -#ifFileExists("version.iss") +#ifexist "version.iss" #include "version.iss" #endif diff --git a/compilation/installer_server.iss b/compilation/installer_server.iss index 41ebe4b..5065aa4 100644 --- a/compilation/installer_server.iss +++ b/compilation/installer_server.iss @@ -1,4 +1,4 @@ -#ifFileExists("version.iss") +#ifexist "version.iss" #include "version.iss" #endif diff --git a/compilation/package_dist.py b/compilation/package_dist.py index a65b0a7..d05e83f 100644 --- a/compilation/package_dist.py +++ b/compilation/package_dist.py @@ -61,12 +61,16 @@ def write_checksum_file(filename, digest, binary_filename): def build_pyinstaller_binary(script_path, binary_name): print(f"[*] Compiling {binary_name} with PyInstaller (Bytecode optimized & stripped)...") + sep = ";" if platform.system() == "Windows" else ":" cmd = [ sys.executable, "-m", "PyInstaller", "--onefile", "--clean", "--strip", "--optimize", "2", + "--paths", ROOT_DIR, + "--add-data", f"{SRC_DIR}{sep}src", + "--collect-all", "src", "--distpath", DIST_DIR, "--workpath", os.path.join(BUILD_TEMP, f"work_{binary_name}"), "--specpath", os.path.join(BUILD_TEMP, f"spec_{binary_name}"), @@ -84,10 +88,14 @@ def build_linux_zipapp_fallback(): print("[*] Packaging Linux standalone zipapp fallback binaries...") # Linux Client zipapp app_dir = os.path.join(BUILD_TEMP, "linux_app") + if os.path.exists(app_dir): + shutil.rmtree(app_dir) os.makedirs(app_dir, exist_ok=True) + shutil.copytree(SRC_DIR, os.path.join(app_dir, "src"), ignore=shutil.ignore_patterns("__pycache__", "*.pyc")) for f in os.listdir(SRC_DIR): - if f.endswith(".py"): - shutil.copy(os.path.join(SRC_DIR, f), os.path.join(app_dir, f)) + src_f = os.path.join(SRC_DIR, f) + if os.path.isfile(src_f) and f.endswith(".py"): + shutil.copy(src_f, os.path.join(app_dir, f)) client_out = os.path.join(DIST_DIR, "Linux_Client.bin") zipapp.create_archive( source=app_dir, @@ -97,10 +105,14 @@ def build_linux_zipapp_fallback(): ) # Server zipapp srv_dir = os.path.join(BUILD_TEMP, "linux_srv") + if os.path.exists(srv_dir): + shutil.rmtree(srv_dir) os.makedirs(srv_dir, exist_ok=True) + shutil.copytree(SRC_DIR, os.path.join(srv_dir, "src"), ignore=shutil.ignore_patterns("__pycache__", "*.pyc")) for f in os.listdir(SRC_DIR): - if f.endswith(".py"): - shutil.copy(os.path.join(SRC_DIR, f), os.path.join(srv_dir, f)) + src_f = os.path.join(SRC_DIR, f) + if os.path.isfile(src_f) and f.endswith(".py"): + shutil.copy(src_f, os.path.join(srv_dir, f)) server_out = os.path.join(DIST_DIR, "Server.bin") zipapp.create_archive( source=srv_dir, @@ -197,11 +209,15 @@ def create_windows_exe_zipapp(script_name, exe_name): the standard Python Windows 64-bit PE launcher stub (t64.exe) to a compiled zipapp archive. """ app_temp_dir = os.path.join(BUILD_TEMP, f"win_app_{exe_name}") + if os.path.exists(app_temp_dir): + shutil.rmtree(app_temp_dir) os.makedirs(app_temp_dir, exist_ok=True) + shutil.copytree(SRC_DIR, os.path.join(app_temp_dir, "src"), ignore=shutil.ignore_patterns("__pycache__", "*.pyc")) for f in os.listdir(SRC_DIR): - if f.endswith(".py"): - shutil.copy(os.path.join(SRC_DIR, f), os.path.join(app_temp_dir, f)) + src_f = os.path.join(SRC_DIR, f) + if os.path.isfile(src_f) and f.endswith(".py"): + shutil.copy(src_f, os.path.join(app_temp_dir, f)) module_name = os.path.splitext(script_name)[0] zipapp_temp = os.path.join(BUILD_TEMP, f"{exe_name}.zip") diff --git a/src/Linux_Client.py b/src/Linux_Client.py index 408ebce..7fc8873 100644 --- a/src/Linux_Client.py +++ b/src/Linux_Client.py @@ -1,9 +1,12 @@ import os import sys -_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) -if _ROOT not in sys.path: - sys.path.insert(0, _ROOT) +_CUR = os.path.dirname(__file__) +_ROOT = os.path.abspath(os.path.join(_CUR, "..")) + +for _p in [_CUR, _ROOT]: + if _p and _p not in sys.path: + sys.path.insert(0, _p) from src.clients.Linux_Client import * diff --git a/src/Server.py b/src/Server.py index 2875ee7..0c63882 100644 --- a/src/Server.py +++ b/src/Server.py @@ -1,9 +1,12 @@ import os import sys -_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) -if _ROOT not in sys.path: - sys.path.insert(0, _ROOT) +_CUR = os.path.dirname(__file__) +_ROOT = os.path.abspath(os.path.join(_CUR, "..")) + +for _p in [_CUR, _ROOT]: + if _p and _p not in sys.path: + sys.path.insert(0, _p) from src.hub.Server import * diff --git a/src/Win_Client.py b/src/Win_Client.py index 5021200..8cba6e1 100644 --- a/src/Win_Client.py +++ b/src/Win_Client.py @@ -1,9 +1,12 @@ import os import sys -_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) -if _ROOT not in sys.path: - sys.path.insert(0, _ROOT) +_CUR = os.path.dirname(__file__) +_ROOT = os.path.abspath(os.path.join(_CUR, "..")) + +for _p in [_CUR, _ROOT]: + if _p and _p not in sys.path: + sys.path.insert(0, _p) from src.clients.Win_Client import * diff --git a/src/auth_manager.py b/src/auth_manager.py index 61c52df..1dd55be 100644 --- a/src/auth_manager.py +++ b/src/auth_manager.py @@ -1,8 +1,11 @@ import os import sys -_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) -if _ROOT not in sys.path: - sys.path.insert(0, _ROOT) +_CUR = os.path.dirname(__file__) +_ROOT = os.path.abspath(os.path.join(_CUR, "..")) + +for _p in [_CUR, _ROOT]: + if _p and _p not in sys.path: + sys.path.insert(0, _p) from src.hub.auth_manager import * \ No newline at end of file diff --git a/src/client_transport.py b/src/client_transport.py index 226afad..123fcc9 100644 --- a/src/client_transport.py +++ b/src/client_transport.py @@ -1,8 +1,11 @@ import os import sys -_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) -if _ROOT not in sys.path: - sys.path.insert(0, _ROOT) +_CUR = os.path.dirname(__file__) +_ROOT = os.path.abspath(os.path.join(_CUR, "..")) + +for _p in [_CUR, _ROOT]: + if _p and _p not in sys.path: + sys.path.insert(0, _p) from src.clients.client_transport import * \ No newline at end of file diff --git a/src/client_updater.py b/src/client_updater.py index f56d492..c28e5b1 100644 --- a/src/client_updater.py +++ b/src/client_updater.py @@ -1,8 +1,11 @@ import os import sys -_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) -if _ROOT not in sys.path: - sys.path.insert(0, _ROOT) +_CUR = os.path.dirname(__file__) +_ROOT = os.path.abspath(os.path.join(_CUR, "..")) + +for _p in [_CUR, _ROOT]: + if _p and _p not in sys.path: + sys.path.insert(0, _p) from src.clients.client_updater import * \ No newline at end of file diff --git a/src/ingest_queue.py b/src/ingest_queue.py index 4db3841..036ae23 100644 --- a/src/ingest_queue.py +++ b/src/ingest_queue.py @@ -1,8 +1,11 @@ import os import sys -_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) -if _ROOT not in sys.path: - sys.path.insert(0, _ROOT) +_CUR = os.path.dirname(__file__) +_ROOT = os.path.abspath(os.path.join(_CUR, "..")) + +for _p in [_CUR, _ROOT]: + if _p and _p not in sys.path: + sys.path.insert(0, _p) from src.hub.ingest_queue import * \ No newline at end of file diff --git a/src/license_manager.py b/src/license_manager.py index 427c526..5e4d1b3 100644 --- a/src/license_manager.py +++ b/src/license_manager.py @@ -1,8 +1,11 @@ import os import sys -_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) -if _ROOT not in sys.path: - sys.path.insert(0, _ROOT) +_CUR = os.path.dirname(__file__) +_ROOT = os.path.abspath(os.path.join(_CUR, "..")) + +for _p in [_CUR, _ROOT]: + if _p and _p not in sys.path: + sys.path.insert(0, _p) from src.hub.license_manager import * \ No newline at end of file diff --git a/src/log_collector.py b/src/log_collector.py index fbe2b07..cf884d4 100644 --- a/src/log_collector.py +++ b/src/log_collector.py @@ -1,8 +1,11 @@ import os import sys -_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) -if _ROOT not in sys.path: - sys.path.insert(0, _ROOT) +_CUR = os.path.dirname(__file__) +_ROOT = os.path.abspath(os.path.join(_CUR, "..")) + +for _p in [_CUR, _ROOT]: + if _p and _p not in sys.path: + sys.path.insert(0, _p) from src.clients.log_collector import * \ No newline at end of file diff --git a/src/pki_manager.py b/src/pki_manager.py index edcd2ab..db107f5 100644 --- a/src/pki_manager.py +++ b/src/pki_manager.py @@ -1,8 +1,11 @@ import os import sys -_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) -if _ROOT not in sys.path: - sys.path.insert(0, _ROOT) +_CUR = os.path.dirname(__file__) +_ROOT = os.path.abspath(os.path.join(_CUR, "..")) + +for _p in [_CUR, _ROOT]: + if _p and _p not in sys.path: + sys.path.insert(0, _p) from src.hub.pki_manager import * \ No newline at end of file diff --git a/src/server_enrollment.py b/src/server_enrollment.py index b46a4bb..15fdad0 100644 --- a/src/server_enrollment.py +++ b/src/server_enrollment.py @@ -1,8 +1,11 @@ import os import sys -_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) -if _ROOT not in sys.path: - sys.path.insert(0, _ROOT) +_CUR = os.path.dirname(__file__) +_ROOT = os.path.abspath(os.path.join(_CUR, "..")) + +for _p in [_CUR, _ROOT]: + if _p and _p not in sys.path: + sys.path.insert(0, _p) from src.hub.server_enrollment import * \ No newline at end of file diff --git a/src/server_models.py b/src/server_models.py index adc8e69..35fc936 100644 --- a/src/server_models.py +++ b/src/server_models.py @@ -1,8 +1,11 @@ import os import sys -_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) -if _ROOT not in sys.path: - sys.path.insert(0, _ROOT) +_CUR = os.path.dirname(__file__) +_ROOT = os.path.abspath(os.path.join(_CUR, "..")) + +for _p in [_CUR, _ROOT]: + if _p and _p not in sys.path: + sys.path.insert(0, _p) from src.hub.server_models import * \ No newline at end of file diff --git a/src/storage_engine.py b/src/storage_engine.py index 58a22df..ea19c75 100644 --- a/src/storage_engine.py +++ b/src/storage_engine.py @@ -1,8 +1,11 @@ import os import sys -_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) -if _ROOT not in sys.path: - sys.path.insert(0, _ROOT) +_CUR = os.path.dirname(__file__) +_ROOT = os.path.abspath(os.path.join(_CUR, "..")) + +for _p in [_CUR, _ROOT]: + if _p and _p not in sys.path: + sys.path.insert(0, _p) from src.hub.storage_engine import * \ No newline at end of file diff --git a/src/update_manager.py b/src/update_manager.py index 3366ebe..f8a94e1 100644 --- a/src/update_manager.py +++ b/src/update_manager.py @@ -1,8 +1,11 @@ import os import sys -_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) -if _ROOT not in sys.path: - sys.path.insert(0, _ROOT) +_CUR = os.path.dirname(__file__) +_ROOT = os.path.abspath(os.path.join(_CUR, "..")) + +for _p in [_CUR, _ROOT]: + if _p and _p not in sys.path: + sys.path.insert(0, _p) from src.hub.update_manager import * \ No newline at end of file diff --git a/src/version.py b/src/version.py index 7b80a2f..634191d 100644 --- a/src/version.py +++ b/src/version.py @@ -1,8 +1,11 @@ import os import sys -_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) -if _ROOT not in sys.path: - sys.path.insert(0, _ROOT) +_CUR = os.path.dirname(__file__) +_ROOT = os.path.abspath(os.path.join(_CUR, "..")) + +for _p in [_CUR, _ROOT]: + if _p and _p not in sys.path: + sys.path.insert(0, _p) from src.common.version import * \ No newline at end of file diff --git a/src/web_ui.py b/src/web_ui.py index ac2b603..23e1b66 100644 --- a/src/web_ui.py +++ b/src/web_ui.py @@ -1,8 +1,11 @@ import os import sys -_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) -if _ROOT not in sys.path: - sys.path.insert(0, _ROOT) +_CUR = os.path.dirname(__file__) +_ROOT = os.path.abspath(os.path.join(_CUR, "..")) + +for _p in [_CUR, _ROOT]: + if _p and _p not in sys.path: + sys.path.insert(0, _p) from src.hub.web_ui import * \ No newline at end of file