This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: redundant ‘/’ in $env:VIRTUAL_ENV when use venv in powershell
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.9, Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Schwarzichet, vinay.sajip
Priority: normal Keywords: patch

Created on 2020-01-31 08:24 by Schwarzichet, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 18290 merged Schwarzichet, 2020-01-31 09:21
PR 18359 merged miss-islington, 2020-02-05 08:17
Messages (3)
msg361094 - (view) Author: Fuzheng Duan (Schwarzichet) * Date: 2020-01-31 08:24
When windows users use "python -m venv ENV_DIR", a python virtual environment will be created in ENV_DIR. 
Powershell users use ENV_DIR\Scripts\Activate.ps1 to activate virtual environment.
In powershell, a environment variable, "$env:VIRTUAL_ENV", is set and used by many tools to determine that there is an activated venv. In bash, it is "$VIRTUAL_ENV"
In python3.8 and python3.9, $env:VIRTUAL_ENV has a redundant '/', for example:
PS C:\Users\Test> python -m venv test_venv
PS C:\Users\Test> .\test_venv\Scripts\Activate.ps1
PS C:\Users\Test> $env:VIRTUAL_ENV
C:\Users\Test\test_venv/

using python3.7, or using virtualenv with python3.8 or 3.9, or in linux, there will be no such a '/' in the end.

This '/' matters because some tools many tools use this environment variable, for example, oh-my-posh will take "test_venv/" as virtual environment name rather than "test_venv"(Although venv's activate.ps 1 itself's default prompt is correct). And from the perspective of semantics and consistency with other platform, the '/' is redundant.
msg361414 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2020-02-05 08:17
New changeset 787b6d548c250f36df6d3f3179f60d754c8aa5e3 by schwarzichet in branch 'master':
bpo-39505: delete the redundant '/' in $env:VIRTUAL_ENV (GH-18290)
https://github.com/python/cpython/commit/787b6d548c250f36df6d3f3179f60d754c8aa5e3
msg361417 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2020-02-05 08:39
New changeset 927d3aab1c7874b5705fcc8269ea608315434e66 by Miss Islington (bot) in branch '3.8':
bpo-39505: delete the redundant '/' in $env:VIRTUAL_ENV (GH-18290) (GH-18359)
https://github.com/python/cpython/commit/927d3aab1c7874b5705fcc8269ea608315434e66
History
Date User Action Args
2022-04-11 14:59:26adminsetgithub: 83686
2020-02-05 08:40:11vinay.sajipsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-02-05 08:39:40vinay.sajipsetmessages: + msg361417
2020-02-05 08:17:24miss-islingtonsetpull_requests: + pull_request17734
2020-02-05 08:17:06vinay.sajipsetmessages: + msg361414
2020-01-31 11:29:46xtreaksetnosy: + vinay.sajip
2020-01-31 09:21:08Schwarzichetsetkeywords: + patch
stage: patch review
pull_requests: + pull_request17663
2020-01-31 08:24:20Schwarzichetcreate