-
-
Notifications
You must be signed in to change notification settings - Fork 597
Use Conda for backend & sync-microservice setup on Windows #1076
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
0b553ac
f44ee30
68f6ae7
a2f24d7
eb0b5af
b8c28ac
95722dd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -112,6 +112,38 @@ if (-not (Test-Command cmake)) { | |
| Write-Host "CMake is already installed. Version: $(cmake --version)" -ForegroundColor Green | ||
| } | ||
|
|
||
| # -------------------------------------------------- | ||
| # Miniconda | ||
| # -------------------------------------------------- | ||
| $condaRoot = "$env:USERPROFILE\miniconda3" | ||
| $condaExe = "$condaRoot\Scripts\conda.exe" | ||
|
|
||
| if (-not (Test-Path $condaExe)) { | ||
| Write-Host "Installing Miniconda..." -ForegroundColor Yellow | ||
| $installer = "$env:TEMP\miniconda.exe" | ||
| Invoke-WebRequest ` | ||
| -Uri "https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe" ` | ||
| -OutFile $installer | ||
|
|
||
| Start-Process -Wait -FilePath $installer -ArgumentList ` | ||
| "/InstallationType=JustMe", | ||
| "/AddToPath=0", | ||
| "/RegisterPython=0", | ||
| "/S", | ||
| "/D=$condaRoot" | ||
|
|
||
| Remove-Item $installer | ||
| } | ||
|
|
||
| # -------------------------------------------------- | ||
| # Initialize Conda (THIS WAS MISSING BEFORE) | ||
| # -------------------------------------------------- | ||
| $env:Path = "$condaRoot;$condaRoot\Scripts;$condaRoot\condabin;$env:Path" | ||
|
|
||
| $condaBase = & $condaExe info --base | ||
| & "$condaBase\shell\condabin\conda-hook.ps1" | ||
|
|
||
|
|
||
| # ---- Set up the frontend ---- | ||
| Write-Host "Setting up frontend..." -ForegroundColor Yellow | ||
| try { | ||
|
|
@@ -131,19 +163,37 @@ try { | |
| # ---- Set up the backend using Python 3.12 ---- | ||
| Write-Host "Setting up backend..." -ForegroundColor Yellow | ||
| try { | ||
| Set-Location .\backend\ | ||
|
|
||
| # Create virtual environment | ||
| python -m venv .env | ||
|
|
||
| # Activate virtual environment and install dependencies | ||
| .\.env\Scripts\Activate.ps1 | ||
| python -m pip install --upgrade pip | ||
| python -m pip install -r requirements.txt | ||
| deactivate | ||
|
|
||
|
|
||
| Set-Location .\backend\ | ||
|
|
||
| Write-Host "Setting up backend Conda environment..." -ForegroundColor Cyan | ||
|
|
||
| # Remove existing environment (ignore if it does not exist) | ||
| conda remove -n backend_env --all -y | ||
| if ($LASTEXITCODE -ne 0) { | ||
| Write-Host "Environment did not exist or could not be removed, continuing..." -ForegroundColor Yellow | ||
| } | ||
|
|
||
| # Create fresh environment | ||
| conda create -n backend_env python=3.12 -y | ||
|
||
| if ($LASTEXITCODE -ne 0) { | ||
| throw "Failed to create Conda environment" | ||
| } | ||
|
|
||
| # Upgrade pip inside the environment | ||
| conda run -n backend_env python -m pip install --upgrade pip | ||
| if ($LASTEXITCODE -ne 0) { | ||
| throw "Failed to upgrade pip inside Conda environment" | ||
| } | ||
|
|
||
| # Install backend dependencies | ||
| conda run -n backend_env python -m pip install -r requirements.txt | ||
| if ($LASTEXITCODE -ne 0) { | ||
| throw "Failed to install backend dependencies" | ||
| } | ||
|
|
||
| Set-Location .. | ||
|
|
||
| Write-Host "Backend setup completed successfully." -ForegroundColor Green | ||
| } catch { | ||
| Write-Host "Error setting up backend: $_" -ForegroundColor Red | ||
|
|
@@ -155,17 +205,34 @@ Write-Host "Setting up sync-microservice..." -ForegroundColor Yellow | |
| try { | ||
| Set-Location .\sync-microservice\ | ||
|
|
||
| # Create virtual environment | ||
| python -m venv .sync-env | ||
|
|
||
| # Activate virtual environment and install dependencies | ||
| .\.sync-env\Scripts\Activate.ps1 | ||
| python -m pip install --upgrade pip | ||
| python -m pip install -r requirements.txt | ||
| deactivate | ||
|
|
||
| Write-Host "Setting up sync-microservice Conda environment..." -ForegroundColor Cyan | ||
|
|
||
| # Remove existing environment (ignore if it does not exist) | ||
| conda remove -n sync_env --all -y | ||
| if ($LASTEXITCODE -ne 0) { | ||
| Write-Host "Environment did not exist or could not be removed, continuing..." -ForegroundColor Yellow | ||
| } | ||
|
|
||
| # Create fresh environment | ||
| conda create -n sync_env python=3.12 -y | ||
rahul-vyas-dev marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if ($LASTEXITCODE -ne 0) { | ||
| throw "Failed to create Conda environment for sync-microservice" | ||
| } | ||
|
|
||
| # Upgrade pip inside the environment | ||
| conda run -n sync_env python -m pip install --upgrade pip | ||
|
||
| if ($LASTEXITCODE -ne 0) { | ||
| throw "Failed to upgrade pip in sync_env" | ||
| } | ||
|
|
||
| # Install dependencies inside the environment | ||
| conda run -n sync_env python -m pip install -r requirements.txt | ||
| if ($LASTEXITCODE -ne 0) { | ||
| throw "Failed to install sync-microservice dependencies" | ||
| } | ||
|
Comment on lines
233
to
251
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Line 248 uses Also, the same Proposed fix (sync-microservice block)- conda create -p .sync-env python=3.12
+ conda create -p .sync-env python=3.12 -y
if ($LASTEXITCODE -ne 0) {
throw "Failed to create Conda environment for sync-microservice"
}
- conda activate .\.sync-env
-
- # Upgrade pip inside the environment
- python -m pip install --upgrade pip
+ conda run -p .sync-env python -m pip install --upgrade pip
if ($LASTEXITCODE -ne 0) {
throw "Failed to upgrade pip in sync_env"
}
- # Install dependencies inside the environment
- conda install -r requirements.txt
+ conda run -p .sync-env pip install -r requirements.txt
if ($LASTEXITCODE -ne 0) {
throw "Failed to install sync-microservice dependencies"
}
- # Deactivate environment after setup
- conda deactivate
Set-Location ..🤖 Prompt for AI Agents |
||
|
|
||
| Set-Location .. | ||
|
|
||
| Write-Host "Sync-microservice setup completed successfully." -ForegroundColor Green | ||
| } catch { | ||
| Write-Host "Error setting up sync-microservice: $_" -ForegroundColor Red | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.