diff --git a/agent-node/VERSION b/agent-node/VERSION index 238d6e8..b0f3d96 100644 --- a/agent-node/VERSION +++ b/agent-node/VERSION @@ -1 +1 @@ -1.0.7 +1.0.8 diff --git a/agent-node/bootstrap_installer.py b/agent-node/bootstrap_installer.py index 8275c9e..d1bfde5 100644 --- a/agent-node/bootstrap_installer.py +++ b/agent-node/bootstrap_installer.py @@ -111,13 +111,39 @@ if not os.path.exists(req_file): _print("No requirements.txt found — skipping dependency install.") return + + _print("Checking for pip...") + pip_found = False + try: + subprocess.check_call([sys.executable, "-m", "pip", "--version"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + pip_found = True + except subprocess.CalledProcessError: + _print("pip not found. Attempting to bootstrap pip via ensurepip...") + try: + subprocess.check_call([sys.executable, "-m", "ensurepip", "--default-pip"], stdout=subprocess.DEVNULL) + pip_found = True + _print("pip bootstrapped successfully.") + except Exception as e: + _print(f"Warning: Failed to bootstrap pip: {e}. If dependencies fail, please install python3-pip manually.") + _print("Installing Python dependencies (resilient mode) ...") - # Using --ignore-installed to bypass "no RECORD file found" metadata errors common on Mac/Anaconda - subprocess.check_call( - [sys.executable, "-m", "pip", "install", "-r", req_file, "--quiet", "--ignore-installed"], - cwd=install_dir - ) - _print("Dependencies installed.") + try: + # Using --ignore-installed to bypass "no RECORD file found" metadata errors common on Mac/Anaconda + # and --user if we don't have root (though usually we do on NAS) + args = [sys.executable, "-m", "pip", "install", "-r", req_file, "--quiet", "--ignore-installed"] + + # Try a quick check for root/write access to site-packages + try: + subprocess.check_call(args, cwd=install_dir) + except subprocess.CalledProcessError: + _print("Standard install failed. Trying --user install...") + args.append("--user") + subprocess.check_call(args, cwd=install_dir) + + _print("Dependencies installed.") + except Exception as e: + _print(f"ERROR: Failed to install dependencies: {e}") + _print("The agent might fail to start if core libraries (grpcio, psutil) are missing.") def _write_config(install_dir: str, node_id: str, hub_url: str, token: str, grpc_endpoint: str, secret_key: str = None):