fix: auto-detect jobspy venv so contributors don't need PYTHON_PATH (#293)

This commit is contained in:
0x1355 2026-03-20 09:18:27 +01:00 committed by GitHub
parent dc2c7ab2df
commit 7f517776df
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 3 deletions

View File

@ -34,6 +34,15 @@ npm --workspace orchestrator run db:migrate
npm --workspace orchestrator run dev npm --workspace orchestrator run dev
``` ```
If you are working with extractors that use Glassdoor, Indeed, or LinkedIn (powered by python-jobspy), set up the Python venv once:
```bash
python3 -m venv extractors/jobspy/.venv
extractors/jobspy/.venv/bin/pip install -r extractors/jobspy/requirements.txt
```
The runner auto-detects the venv — no need to set `PYTHON_PATH`.
If you are editing docs: If you are editing docs:
```bash ```bash

View File

@ -1,4 +1,5 @@
import { spawn } from "node:child_process"; import { spawn } from "node:child_process";
import { existsSync } from "node:fs";
import { mkdir, readFile, unlink } from "node:fs/promises"; import { mkdir, readFile, unlink } from "node:fs/promises";
import { dirname, join } from "node:path"; import { dirname, join } from "node:path";
import { createInterface } from "node:readline"; import { createInterface } from "node:readline";
@ -180,8 +181,19 @@ export async function runJobSpy(
const outputJson = join(OUTPUT_DIR, `jobspy_jobs_${suffix}.json`); const outputJson = join(OUTPUT_DIR, `jobspy_jobs_${suffix}.json`);
await new Promise<void>((resolve, reject) => { await new Promise<void>((resolve, reject) => {
// Auto-detect venv if present, so contributors don't need to set
// PYTHON_PATH manually. The venv is created once with:
// python3 -m venv .venv && .venv/bin/pip install -r requirements.txt
// In Docker, PYTHON_PATH is set explicitly to /usr/bin/python3.
const venvPython = join(
EXTRACTOR_DIR,
".venv",
process.platform === "win32" ? "Scripts/python.exe" : "bin/python3",
);
const pythonPath = process.env.PYTHON_PATH const pythonPath = process.env.PYTHON_PATH
? process.env.PYTHON_PATH ? process.env.PYTHON_PATH
: existsSync(venvPython)
? venvPython
: process.platform === "win32" : process.platform === "win32"
? "python" ? "python"
: "python3"; : "python3";