install_local.ps1 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # Installation locale Windows - source unique: requirements.txt
  2. # Overrides Windows: psycopg2 (wheel), python-magic-bin, post-install (spacy, nltk)
  3. param(
  4. [switch]$SkipVenv,
  5. [switch]$SkipPsycopg
  6. )
  7. $ErrorActionPreference = "Stop"
  8. Set-Location $PSScriptRoot
  9. if (-not $SkipVenv) {
  10. Write-Host "Activation du venv..." -ForegroundColor Cyan
  11. & .\venv\Scripts\Activate.ps1
  12. }
  13. # 1. psycopg2 (Windows: wheel obligatoire pour Python 3.13)
  14. if (-not $SkipPsycopg) {
  15. Write-Host "`n1. psycopg2-binary (wheel Windows)..." -ForegroundColor Cyan
  16. pip install "psycopg2-binary>=2.9.9" --only-binary :all:
  17. if ($LASTEXITCODE -ne 0) {
  18. Write-Host " Pas de wheel. Utilisez: .\install_local.ps1 -SkipPsycopg (SQLite)" -ForegroundColor Red
  19. exit 1
  20. }
  21. }
  22. # 2. Dépendances (filtrer psycopg2 si -SkipPsycopg)
  23. Write-Host "`n2. Installation de requirements.txt..." -ForegroundColor Cyan
  24. if ($SkipPsycopg) {
  25. $filtered = Get-Content requirements.txt | Where-Object { $_ -notmatch 'psycopg2' }
  26. $temp = [System.IO.Path]::GetTempFileName()
  27. $filtered | Set-Content $temp
  28. pip install -r $temp
  29. Remove-Item $temp
  30. } else {
  31. pip install -r requirements.txt
  32. }
  33. # 3. Override Windows: python-magic-bin (remplace python-magic qui nécessite libmagic système)
  34. Write-Host "`n3. python-magic-bin (Windows)..." -ForegroundColor Cyan
  35. pip uninstall python-magic -y 2>$null
  36. pip install python-magic-bin
  37. # 4. Post-install: spaCy + NLTK
  38. Write-Host "`n4. Modèle spaCy + NLTK..." -ForegroundColor Cyan
  39. python -m spacy download fr_core_news_sm
  40. python -c "import nltk; nltk.download('punkt')"
  41. Write-Host "`nTerminé. Lancez: .\run_local.ps1" -ForegroundColor Green