]> granicus.if.org Git - python/commitdiff
bpo-32718: Make Activate.ps1 for venv cross-platform and available on all platforms...
authorBrett Cannon <brettcannon@users.noreply.github.com>
Fri, 21 Sep 2018 22:27:26 +0000 (15:27 -0700)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 21 Sep 2018 22:27:26 +0000 (15:27 -0700)
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.

Doc/whatsnew/3.8.rst
Lib/venv/scripts/common/Activate.ps1 [moved from Lib/venv/scripts/nt/Activate.ps1 with 86% similarity]
Misc/NEWS.d/next/Library/2018-09-14-12-38-49.bpo-32718.ICYQbt.rst [new file with mode: 0644]

index 1c129a704429f269c10a58df9e8553a9b595e085..26928fbd55c0ec8419d55407c860db38b0d5744e 100644 (file)
@@ -136,6 +136,13 @@ pathlib
 contain characters unrepresentable at the OS level.
 (Contributed by Serhiy Storchaka in :issue:`33721`.)
 
+venv
+----
+
+* :mod:`venv` now includes an ``Activate.ps1`` script on all platforms for
+  activating virtual environments under PowerShell Core 6.1.
+  (Contributed by Brett Cannon in :issue:`32718`.)
+
 
 Optimizations
 =============
@@ -321,7 +328,7 @@ CPython bytecode changes
 
 * The interpreter loop  has been simplified by moving the logic of unrolling
   the stack of blocks into the compiler.  The compiler emits now explicit
-  instructions for adjusting the stack of values and calling the cleaning
+  instructions for adjusting the stack of values and calling the cleaning-
   up code for :keyword:`break`, :keyword:`continue` and :keyword:`return`.
 
   Removed opcodes :opcode:`BREAK_LOOP`, :opcode:`CONTINUE_LOOP`,
similarity index 86%
rename from Lib/venv/scripts/nt/Activate.ps1
rename to Lib/venv/scripts/common/Activate.ps1
index bf60869e552e9763e4c9638f4e218bec9070b842..de22962630aabbbc0f7d78600d42ec085bab3b76 100644 (file)
@@ -1,3 +1,8 @@
+function Script:add-bin([string]$envPath) {
+    $binPath = Join-Path -Path $env:VIRTUAL_ENV -ChildPath '__VENV_BIN_NAME__'
+    return ($binPath, $envPath) -join [IO.Path]::PathSeparator
+}
+
 function global:deactivate ([switch]$NonDestructive) {
     # Revert to original values
     if (Test-Path function:_OLD_VIRTUAL_PROMPT) {
@@ -48,4 +53,4 @@ if (Test-Path env:PYTHONHOME) {
 
 # Add the venv to the PATH
 copy-item env:PATH env:_OLD_VIRTUAL_PATH
-$env:PATH = "$env:VIRTUAL_ENV\__VENV_BIN_NAME__;$env:PATH"
+$env:PATH = add-bin $env:PATH
diff --git a/Misc/NEWS.d/next/Library/2018-09-14-12-38-49.bpo-32718.ICYQbt.rst b/Misc/NEWS.d/next/Library/2018-09-14-12-38-49.bpo-32718.ICYQbt.rst
new file mode 100644 (file)
index 0000000..b60106a
--- /dev/null
@@ -0,0 +1,2 @@
+The Activate.ps1 script from venv works with PowerShell Core 6.1 and is now
+available under all operating systems.