From ad04f2b785efe40d0794603b9a5d38c98163f2cc Mon Sep 17 00:00:00 2001 From: aitbc Date: Tue, 26 May 2026 10:32:43 +0200 Subject: [PATCH] feat: add PostgreSQL client library support for psycopg2 - Added libpq-dev to apt-get prerequisites for psycopg2 compilation - Added postgresql-devel to yum prerequisites for psycopg2 compilation - Added fallback installation of psycopg2-binary when Poetry fails - Added fallback installation of critical packages (fastapi, uvicorn, sqlmodel) - Prevents service crashes due to missing psycopg2 module - Ensures PostgreSQL database connectivity for services --- scripts/setup.sh | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/scripts/setup.sh b/scripts/setup.sh index e0462450..c2d94f12 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -88,10 +88,13 @@ check_prerequisites() { redis-cli) apt-get install -y redis-tools ;; + libpq-dev) + apt-get install -y libpq-dev + ;; esac done elif command -v yum >/dev/null 2>&1; then - yum install -y python3 python3-pip python3-venv git systemd postgresql postgresql-server postgresql-contrib redis + yum install -y python3 python3-pip python3-venv git systemd postgresql postgresql-server postgresql-contrib redis postgresql-devel # Install Node.js 24.x curl -fsSL https://rpm.nodesource.com/setup_24.x | bash - yum install -y nodejs @@ -494,12 +497,29 @@ setup_venvs() { log "Running poetry install..." if ! poetry install; then warning "Poetry install failed" + warning "Installing critical dependencies manually..." + + # Install critical dependencies that services need + log "Installing psycopg2 for PostgreSQL support..." + pip install psycopg2-binary || warning "Failed to install psycopg2-binary" + + log "Installing other critical packages..." + pip install fastapi uvicorn sqlmodel || warning "Failed to install core packages" + warning "Dependencies may need to be installed manually" warning "Manual install: cd /opt/aitbc && source venv/bin/activate && pip install -e cli/ apps/blockchain-node/" fi fi else warning "pyproject.toml not found, skipping Poetry installation" + warning "Installing critical dependencies manually..." + + # Install critical dependencies without Poetry + log "Installing psycopg2 for PostgreSQL support..." + pip install psycopg2-binary || warning "Failed to install psycopg2-binary" + + log "Installing other critical packages..." + pip install fastapi uvicorn sqlmodel || warning "Failed to install core packages" fi success "Virtual environments setup completed"