Skip to content

Commit

Permalink
sanitize the PATH env in virtual environment
Browse files Browse the repository at this point in the history
  • Loading branch information
th3w1zard1 committed Feb 24, 2024
1 parent e5bd30e commit 85dd750
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion install_python_venv.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ param(
[switch]$noprompt
)

if (-not $venv_name -or $venv_name.Trim() -eq '') {
$venv_name = ".venv"
}

$repoRootPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
function Get-OS {
if ($IsWindows) {
Expand Down Expand Up @@ -656,13 +660,18 @@ if ( $findVenvExecutable -eq $true) {


Write-Host "Activating venv at '$venvPath'"
$originalPath = $env:PATH -split ';'
if ((Get-OS) -eq "Windows") {
. $venvPath\Scripts\Activate.ps1
} else {
. $venvPath/bin/Activate.ps1
}
# sanitize $PATH, otherwise pyinstaller will act up...
$modifiedPath = $env:PATH -split ';'
$addedPaths = $modifiedPath | Where-Object { $originalPath -notcontains $_ }
$env:PATH = $addedPaths -join ';'

Initialize-Python $pythonExePath
Write-Output "Sanitized PATH env: $env:PATH"

# Set environment variables from .env file
$dotenv_path = "$repoRootPath$pathSep.env"
Expand Down

0 comments on commit 85dd750

Please sign in to comment.