From 9885a3d35bd6665aaffb789b6b7376028ec5173d Mon Sep 17 00:00:00 2001 From: ff Date: Fri, 31 Jul 2026 10:49:06 -0400 Subject: [PATCH] fix: decouple Python venv setup from npm install postinstall MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The three Python services (PatientDataExtractorService, PaymentOCRService, SeleniumService) provisioned their venvs via postinstall, chained into root's own postinstall. A failure in any one of them aborted the whole npm install, which could leave unrelated Node deps (e.g. Backend's sharp) uninstalled — silently breaking the app with no indication why. Renamed each service's postinstall to an explicit "setup" script, added a root "npm run setup:python" to run all three, and documented it as its own step in the README instead of an automatic install-time side effect. Co-Authored-By: Claude Sonnet 5 --- README.md | 10 ++++++++-- apps/PatientDataExtractorService/package.json | 2 +- apps/PaymentOCRService/package.json | 2 +- apps/SeleniumService/package.json | 2 +- package-lock.json | 9 +++------ package.json | 3 ++- 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 7785cc23..225c95b8 100644 --- a/README.md +++ b/README.md @@ -212,9 +212,15 @@ npm install ### Step 11 — Install Python dependencies -Python dependencies are installed automatically by `npm install` (Step 10) via each service's `postinstall` script. Each service creates its own `.venv` virtual environment — no manual pip commands needed. +```sh +npm run setup:python +``` -> This approach is required on Debian 13+ where system-wide pip installs are blocked (PEP 668). +This creates a `.venv` virtual environment inside each Python service (`PatientDataExtractorService`, `PaymentOCRService`, `SeleniumService`) and installs its `requirements.txt` into it — no manual pip commands needed. + +> This venv approach is required on Debian 13+ where system-wide pip installs are blocked (PEP 668). + +This is a separate, explicit step rather than an `npm install` `postinstall` hook on purpose: if Python/pip setup fails on a given machine (missing system Python, no network access, a pip resolution error), it won't also abort or corrupt the Node.js dependency install for the other apps. Re-run `npm run setup:python` any time you need to rebuild these virtual envs (e.g. after moving/renaming the project folder, since venvs bake in absolute paths). ### Step 12 — Set up environment variables diff --git a/apps/PatientDataExtractorService/package.json b/apps/PatientDataExtractorService/package.json index 91916ec2..12d307ec 100755 --- a/apps/PatientDataExtractorService/package.json +++ b/apps/PatientDataExtractorService/package.json @@ -2,7 +2,7 @@ "name": "patientdataextractorservice", "private": true, "scripts": { - "postinstall": "python3 -m venv .venv && .venv/bin/pip install -r requirements.txt", + "setup": "python3 -m venv .venv && .venv/bin/pip install -r requirements.txt", "dev": ".venv/bin/python3 main.py" } } diff --git a/apps/PaymentOCRService/package.json b/apps/PaymentOCRService/package.json index 419bc2c6..d58c146f 100755 --- a/apps/PaymentOCRService/package.json +++ b/apps/PaymentOCRService/package.json @@ -2,7 +2,7 @@ "name": "paymentocrservice", "private": true, "scripts": { - "postinstall": "python3 -m venv .venv && .venv/bin/pip install -r requirements.txt", + "setup": "python3 -m venv .venv && .venv/bin/pip install -r requirements.txt", "dev": ".venv/bin/python3 main.py" } } diff --git a/apps/SeleniumService/package.json b/apps/SeleniumService/package.json index e5271f86..b6dcc530 100755 --- a/apps/SeleniumService/package.json +++ b/apps/SeleniumService/package.json @@ -2,6 +2,6 @@ "name": "seleniumservice", "private": true, "scripts": { - "postinstall": "python3 -m venv .venv && .venv/bin/pip install -r requirements.txt" + "setup": "python3 -m venv .venv && .venv/bin/pip install -r requirements.txt" } } diff --git a/package-lock.json b/package-lock.json index d7d9a0e6..1214378a 100755 --- a/package-lock.json +++ b/package-lock.json @@ -197,16 +197,13 @@ } }, "apps/PatientDataExtractorService": { - "name": "patientdataextractorservice", - "hasInstallScript": true + "name": "patientdataextractorservice" }, "apps/PaymentOCRService": { - "name": "paymentocrservice", - "hasInstallScript": true + "name": "paymentocrservice" }, "apps/SeleniumService": { - "name": "seleniumservice", - "hasInstallScript": true + "name": "seleniumservice" }, "apps/SeleniumServiceold": { "name": "seleniumserviceold", diff --git a/package.json b/package.json index db516e94..f25172dc 100755 --- a/package.json +++ b/package.json @@ -13,7 +13,8 @@ "db:seed": "npx ts-node packages/db/prisma/seed.ts", "db:studio": "npx prisma studio --config=packages/db/prisma/prisma.config.ts", "setup:env": "shx cp packages/db/prisma/.env.example packages/db/prisma/.env && shx cp apps/Frontend/.env.example apps/Frontend/.env && shx cp apps/Backend/.env.example apps/Backend/.env && shx cp apps/PatientDataExtractorService/.env.example apps/PatientDataExtractorService/.env && shx cp apps/SeleniumService/.env.example apps/SeleniumService/.env && shx cp apps/PaymentOCRService/.env.example apps/PaymentOCRService/.env", - "postinstall": "npm --prefix apps/PatientDataExtractorService run postinstall && npm --prefix apps/PaymentOCRService run postinstall && bash scripts/install-rclone.sh" + "setup:python": "npm run setup --workspace=apps/PatientDataExtractorService && npm run setup --workspace=apps/PaymentOCRService && npm run setup --workspace=apps/SeleniumService", + "postinstall": "bash scripts/install-rclone.sh" }, "prisma": { "seed": "ts-node packages/db/prisma/seed.ts"