Skip to content

Commit 7d59f5c

Browse files
author
shadeform
committed
fix(setup): auto pip-install DB deps for Steps 8–9 subprocess scripts
Venv from Step 3 may exist without asyncpg/psycopg. Probe imports via project venv python; on failure run pip install minimal packages before create_default_users and demo data scripts. Made-with: Cursor
1 parent bc13496 commit 7d59f5c

1 file changed

Lines changed: 52 additions & 1 deletion

File tree

notebooks/setup/complete_setup_guide.ipynb

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3475,7 +3475,32 @@
34753475
" print(f\"❌ Python not found at: {python_path}\")\n",
34763476
" print(\" Make sure virtual environment is set up (Step 3)\")\n",
34773477
" return False\n",
3478-
" \n",
3478+
"\n",
3479+
" chk = subprocess.run(\n",
3480+
" [str(python_path), \"-c\", \"import asyncpg, bcrypt, dotenv\"],\n",
3481+
" capture_output=True,\n",
3482+
" text=True,\n",
3483+
" cwd=str(project_root),\n",
3484+
" )\n",
3485+
" if chk.returncode != 0:\n",
3486+
" print(\"📦 Project venv missing packages for user script; installing asyncpg, bcrypt, python-dotenv...\")\n",
3487+
" ins = subprocess.run(\n",
3488+
" [\n",
3489+
" str(python_path),\n",
3490+
" \"-m\",\n",
3491+
" \"pip\",\n",
3492+
" \"install\",\n",
3493+
" \"asyncpg>=0.29\",\n",
3494+
" \"bcrypt\",\n",
3495+
" \"python-dotenv\",\n",
3496+
" ],\n",
3497+
" cwd=str(project_root),\n",
3498+
" )\n",
3499+
" if ins.returncode != 0:\n",
3500+
" print(f\"❌ pip install failed (need network). Try: {python_path} -m pip install -r requirements.txt\")\n",
3501+
" return False\n",
3502+
" print(\" ✅ Installed\")\n",
3503+
"\n",
34793504
" print(\"\\n🔄 Running user creation script...\")\n",
34803505
" result = subprocess.run(\n",
34813506
" [str(python_path), str(script_path)],\n",
@@ -3590,6 +3615,32 @@
35903615
" print(\" Make sure virtual environment is set up (Step 3)\")\n",
35913616
" return False\n",
35923617
"\n",
3618+
" chk = subprocess.run(\n",
3619+
" [str(python_path), \"-c\", \"import asyncpg, psycopg, bcrypt, numpy\"],\n",
3620+
" capture_output=True,\n",
3621+
" text=True,\n",
3622+
" cwd=str(project_root),\n",
3623+
" )\n",
3624+
" if chk.returncode != 0:\n",
3625+
" print(\"📦 Project venv missing packages for demo scripts; installing asyncpg, psycopg, bcrypt, numpy...\")\n",
3626+
" ins = subprocess.run(\n",
3627+
" [\n",
3628+
" str(python_path),\n",
3629+
" \"-m\",\n",
3630+
" \"pip\",\n",
3631+
" \"install\",\n",
3632+
" \"asyncpg>=0.29\",\n",
3633+
" \"psycopg[binary]>=3\",\n",
3634+
" \"bcrypt\",\n",
3635+
" \"numpy>=1.24\",\n",
3636+
" ],\n",
3637+
" cwd=str(project_root),\n",
3638+
" )\n",
3639+
" if ins.returncode != 0:\n",
3640+
" print(f\"❌ pip install failed (need network). Try: {python_path} -m pip install -r requirements.txt\")\n",
3641+
" return False\n",
3642+
" print(\" ✅ Installed\")\n",
3643+
"\n",
35933644
" scripts = [\n",
35943645
" (\"scripts/data/quick_demo_data.py\", \"Quick demo data (equipment, inventory)\"),\n",
35953646
" (\"scripts/data/generate_historical_demand.py\", \"Historical demand data (for forecasting)\"),\n",

0 commit comments

Comments
 (0)