X Tutup
Skip to content

Commit d64ee1a

Browse files
brettcannonmiss-islington
authored andcommitted
bpo-32718: Make Activate.ps1 for venv cross-platform and available on all platforms (pythonGH-9321)
PowerShell Core 6.1 is the cross-platform port of Windows PowerShell. This change updates Activate.ps1 to not make Windows assumptions as well as installing it into the bin/Scripts directory on all operating systems. Requires PowerShell Core 6.1 for proper readline support once the shell has been activated for the virtual environment.
1 parent db1a80e commit d64ee1a

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

Doc/whatsnew/3.8.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,13 @@ pathlib
136136
contain characters unrepresentable at the OS level.
137137
(Contributed by Serhiy Storchaka in :issue:`33721`.)
138138

139+
venv
140+
----
141+
142+
* :mod:`venv` now includes an ``Activate.ps1`` script on all platforms for
143+
activating virtual environments under PowerShell Core 6.1.
144+
(Contributed by Brett Cannon in :issue:`32718`.)
145+
139146

140147
Optimizations
141148
=============
@@ -321,7 +328,7 @@ CPython bytecode changes
321328

322329
* The interpreter loop has been simplified by moving the logic of unrolling
323330
the stack of blocks into the compiler. The compiler emits now explicit
324-
instructions for adjusting the stack of values and calling the cleaning
331+
instructions for adjusting the stack of values and calling the cleaning-
325332
up code for :keyword:`break`, :keyword:`continue` and :keyword:`return`.
326333

327334
Removed opcodes :opcode:`BREAK_LOOP`, :opcode:`CONTINUE_LOOP`,
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
function Script:add-bin([string]$envPath) {
2+
$binPath = Join-Path -Path $env:VIRTUAL_ENV -ChildPath '__VENV_BIN_NAME__'
3+
return ($binPath, $envPath) -join [IO.Path]::PathSeparator
4+
}
5+
16
function global:deactivate ([switch]$NonDestructive) {
27
# Revert to original values
38
if (Test-Path function:_OLD_VIRTUAL_PROMPT) {
@@ -48,4 +53,4 @@ if (Test-Path env:PYTHONHOME) {
4853

4954
# Add the venv to the PATH
5055
copy-item env:PATH env:_OLD_VIRTUAL_PATH
51-
$env:PATH = "$env:VIRTUAL_ENV\__VENV_BIN_NAME__;$env:PATH"
56+
$env:PATH = add-bin $env:PATH
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
The Activate.ps1 script from venv works with PowerShell Core 6.1 and is now
2+
available under all operating systems.

0 commit comments

Comments
 (0)
X Tutup