Lines Matching +full:remove +full:- +full:item
26 Activate.ps1 -Verbose
31 Activate.ps1 -VenvDir C:\Users\MyUser\Common\.venv
35 Activate.ps1 -Prompt "MyPython"
45 PS C:\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
60 <# Function declarations --------------------------------------------------- #>
64 Remove all shell session elements added by the Activate script, including the
69 If present, do not remove this function from the global namespace for the
77 if (Test-Path -Path Function:_OLD_VIRTUAL_PROMPT) { in global:deactivate()
78 Copy-Item -Path Function:_OLD_VIRTUAL_PROMPT -Destination Function:prompt in global:deactivate()
79 Remove-Item -Path Function:_OLD_VIRTUAL_PROMPT in global:deactivate()
83 if (Test-Path -Path Env:_OLD_VIRTUAL_PYTHONHOME) { in global:deactivate()
84 Copy-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME -Destination Env:PYTHONHOME in global:deactivate()
85 Remove-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME in global:deactivate()
89 if (Test-Path -Path Env:_OLD_VIRTUAL_PATH) { in global:deactivate()
90 Copy-Item -Path Env:_OLD_VIRTUAL_PATH -Destination Env:PATH in global:deactivate()
91 Remove-Item -Path Env:_OLD_VIRTUAL_PATH in global:deactivate()
94 # Just remove the VIRTUAL_ENV altogether: in global:deactivate()
95 if (Test-Path -Path Env:VIRTUAL_ENV) { in global:deactivate()
96 Remove-Item -Path env:VIRTUAL_ENV in global:deactivate()
99 # Just remove VIRTUAL_ENV_PROMPT altogether. in global:deactivate()
100 if (Test-Path -Path Env:VIRTUAL_ENV_PROMPT) { in global:deactivate()
101 Remove-Item -Path env:VIRTUAL_ENV_PROMPT in global:deactivate()
104 # Just remove the _PYTHON_VENV_PROMPT_PREFIX altogether: in global:deactivate()
105 if (Get-Variable -Name "_PYTHON_VENV_PROMPT_PREFIX" -ErrorAction SilentlyContinue) { in global:deactivate()
106 Remove-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Scope Global -Force in global:deactivate()
110 if (-not $NonDestructive) { in global:deactivate()
111 Remove-Item -Path function:deactivate in global:deactivate()
117 Get-PyVenvConfig parses the values from the pyvenv.cfg file located in the
131 function Get-PyVenvConfig( in Get-PyVenvConfig()
135 Write-Verbose "Given ConfigDir=$ConfigDir, obtain values in pyvenv.cfg" in Get-PyVenvConfig()
138 …$pyvenvConfigPath = Join-Path -Resolve -Path $ConfigDir -ChildPath 'pyvenv.cfg' -ErrorAction Conti… in Get-PyVenvConfig()
145 Write-Verbose "File exists, parse `key = value` lines" in Get-PyVenvConfig()
146 $pyvenvConfigContent = Get-Content -Path $pyvenvConfigPath in Get-PyVenvConfig()
148 $pyvenvConfigContent | ForEach-Object { in Get-PyVenvConfig()
149 $keyval = $PSItem -split "\s*=\s*", 2 in Get-PyVenvConfig()
150 if ($keyval[0] -and $keyval[1]) { in Get-PyVenvConfig()
153 # Remove extraneous quotations around a string value. in Get-PyVenvConfig()
155 $val = $val.Substring(1, $val.Length - 2) in Get-PyVenvConfig()
159 Write-Verbose "Adding Key: '$($keyval[0])'='$val'" in Get-PyVenvConfig()
167 <# Begin Activate script --------------------------------------------------- #>
170 $VenvExecPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
171 $VenvExecDir = Get-Item -Path $VenvExecPath
173 Write-Verbose "Activation script is located in path: '$VenvExecPath'"
174 Write-Verbose "VenvExecDir Fullname: '$($VenvExecDir.FullName)"
175 Write-Verbose "VenvExecDir Name: '$($VenvExecDir.Name)"
181 Write-Verbose "VenvDir given as parameter, using '$VenvDir' to determine values"
184 Write-Verbose "VenvDir not given as a parameter, using parent directory name as VenvDir."
186 Write-Verbose "VenvDir=$VenvDir"
191 $pyvenvCfg = Get-PyVenvConfig -ConfigDir $VenvDir
196 Write-Verbose "Prompt specified as argument, using '$Prompt'"
199 Write-Verbose "Prompt not specified as argument to script, checking pyvenv.cfg value"
200 if ($pyvenvCfg -and $pyvenvCfg['prompt']) {
201 Write-Verbose " Setting based on value in pyvenv.cfg='$($pyvenvCfg['prompt'])'"
205 …Write-Verbose " Setting prompt based on parent's directory's name. (Is the directory name passed …
206 Write-Verbose " Got leaf-name of $VenvDir='$(Split-Path -Path $venvDir -Leaf)'"
207 $Prompt = Split-Path -Path $venvDir -Leaf
211 Write-Verbose "Prompt = '$Prompt'"
212 Write-Verbose "VenvDir='$VenvDir'"
216 deactivate -nondestructive
222 if (-not $Env:VIRTUAL_ENV_DISABLE_PROMPT) {
224 Write-Verbose "Setting prompt to '$Prompt'"
229 Copy-Item -Path function:prompt -Destination function:_OLD_VIRTUAL_PROMPT
230 …w-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Description "Python virtual environment prompt prefix…
233 Write-Host -NoNewline -ForegroundColor Green "($_PYTHON_VENV_PROMPT_PREFIX) " in global:prompt()
240 if (Test-Path -Path Env:PYTHONHOME) {
241 Copy-Item -Path Env:PYTHONHOME -Destination Env:_OLD_VIRTUAL_PYTHONHOME
242 Remove-Item -Path Env:PYTHONHOME
246 Copy-Item -Path Env:PATH -Destination Env:_OLD_VIRTUAL_PATH