Skip to content

Support deactivating virtual environments without user intervention #22405

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

Merged
merged 24 commits into from
Nov 10, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Restore all env vars directly for powershell (to keep things simple)
  • Loading branch information
Kartik Raj committed Nov 8, 2023
commit 03b45670af70b42a20a96e90a8e5a25d106ed26e
24 changes: 1 addition & 23 deletions pythonFiles/deactivate/powershell/deactivate.ps1
Original file line number Diff line number Diff line change
@@ -1,26 +1,4 @@
# Same as deactivate in "Activate.ps1"
function global:deactivate ([switch]$NonDestructive) {
if (Test-Path function:_OLD_VIRTUAL_PROMPT) {
copy-item function:_OLD_VIRTUAL_PROMPT function:prompt
remove-item function:_OLD_VIRTUAL_PROMPT
}
if (Test-Path env:_OLD_VIRTUAL_PYTHONHOME) {
copy-item env:_OLD_VIRTUAL_PYTHONHOME env:PYTHONHOME
remove-item env:_OLD_VIRTUAL_PYTHONHOME
}
if (Test-Path env:_OLD_VIRTUAL_PATH) {
copy-item env:_OLD_VIRTUAL_PATH env:PATH
remove-item env:_OLD_VIRTUAL_PATH
}
if (Test-Path env:VIRTUAL_ENV) {
remove-item env:VIRTUAL_ENV
}
if (!$NonDestructive) {
remove-item function:deactivate
}
}

# Load dotenv-style file and set environment variables
# Load dotenv-style file and restore environment variables
Get-Content -Path "$PSScriptRoot\envVars.txt" | ForEach-Object {
# Split each line into key and value at the first '='
$parts = $_ -split '=', 2
Expand Down