···136136 command: |
137137 echo "=== Creating virtualenv ==="
138138 python3 -m venv .venv
139139+ .venv/bin/pip install --quiet --upgrade pip
139140140141 # -----------------------------------------------------------------
141141- # psycopg build strategy
142142+ # psycopg-c build fix
142143 #
143143- # pg_config is not present in the postgresql_15 package in the
144144- # Nixery nixpkgs snapshot used here — it was split into a separate
145145- # output that Nixery's dependency syntax can't address (dotted
146146- # attribute paths like postgresql_15.pg_config silently do nothing).
144144+ # pg_config is absent from this Nixery nixpkgs snapshot entirely.
145145+ # psycopg-c is listed as an explicit package in Pipfile.lock, so
146146+ # pipenv always tries to build it from source regardless of what's
147147+ # already installed.
147148 #
148148- # Fix: pre-install psycopg[binary] (a self-contained wheel that
149149- # bundles its own libpq — no pg_config, no compilation required).
150150- # Pipenv will then see psycopg as already satisfied and skip the
151151- # source build for psycopg_c.
149149+ # Fix:
150150+ # 1. Remove psycopg-c from Pipfile.lock (JSON edit via Python)
151151+ # 2. Pre-install psycopg[binary] which provides the same runtime
152152+ # driver with a bundled libpq — no pg_config needed
153153+ # 3. Run pipenv normally; psycopg is satisfied, psycopg-c is gone
152154 # -----------------------------------------------------------------
153153- echo "=== Pre-installing psycopg binary wheel ==="
154154- .venv/bin/pip install --upgrade pip
155155- .venv/bin/pip install "psycopg[binary]"
156156- echo "psycopg binary install: OK"
155155+ echo "=== Patching Pipfile.lock: removing psycopg-c ==="
156156+ python3 - <<'EOF'
157157+ import json, sys
158158+159159+ with open("Pipfile.lock") as f:
160160+ lock = json.load(f)
161161+162162+ removed = []
163163+ for category, pkgs in lock.items():
164164+ if not isinstance(pkgs, dict):
165165+ continue
166166+ for key in ("psycopg-c", "psycopg_c"):
167167+ if key in pkgs:
168168+ del pkgs[key]
169169+ removed.append(f"{category}/{key}")
170170+171171+ with open("Pipfile.lock", "w") as f:
172172+ json.dump(lock, f, indent=4)
173173+174174+ if removed:
175175+ print(f" Removed from lock: {', '.join(removed)}")
176176+ else:
177177+ print(" psycopg-c not found in lock file — nothing to remove")
178178+ EOF
179179+180180+ echo "=== Pre-installing psycopg[binary] ==="
181181+ .venv/bin/pip install --quiet "psycopg[binary]==3.3.1"
182182+ echo " psycopg[binary] installed: OK"
157183 echo ""
158184159185 echo "=== Installing production dependencies ==="