diff --git a/Lib/venv/scripts/common/activate b/Lib/venv/scripts/common/activate index 70673a265d41f8..a36e83c2213eda 100644 --- a/Lib/venv/scripts/common/activate +++ b/Lib/venv/scripts/common/activate @@ -45,8 +45,17 @@ case "$(uname)" in export VIRTUAL_ENV ;; *) - # use the path as-is - export VIRTUAL_ENV=__VENV_DIR__ + case "$(uname -r)" in + *Microsoft*|*WSL*) + # convert path to /mnt/d/path/to/venv on WSL + VIRTUAL_ENV=$(wslpath __VENV_DIR__) + export VIRTUAL_ENV + ;; + *) + # use the path as-is + export VIRTUAL_ENV=__VENV_DIR__ + ;; + esac ;; esac diff --git a/Misc/NEWS.d/next/Windows/2024-09-17-12-32-34.gh-issue-124139.p-I_90.rst b/Misc/NEWS.d/next/Windows/2024-09-17-12-32-34.gh-issue-124139.p-I_90.rst new file mode 100644 index 00000000000000..a1c4acdb260f7c --- /dev/null +++ b/Misc/NEWS.d/next/Windows/2024-09-17-12-32-34.gh-issue-124139.p-I_90.rst @@ -0,0 +1 @@ +Add WSL path conversion in :mod:`venv` ``activate`` script.