Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions 20 Lib/venv/scripts/common/activate
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,18 @@ deactivate () {
deactivate nondestructive

# on Windows, a path can contain colons and backslashes and has to be converted:
if [ "${OSTYPE:-}" = "cygwin" ] || [ "${OSTYPE:-}" = "msys" ] ; then
# transform D:\path\to\venv to /d/path/to/venv on MSYS
# and to /cygdrive/d/path/to/venv on Cygwin
export VIRTUAL_ENV=$(cygpath "__VENV_DIR__")
else
# use the path as-is
export VIRTUAL_ENV="__VENV_DIR__"
fi
case "$(uname)" in
CYGWIN*|MSYS*)
# transform D:\path\to\venv to /d/path/to/venv on MSYS
# and to /cygdrive/d/path/to/venv on Cygwin
VIRTUAL_ENV=$(cygpath "__VENV_DIR__")
export VIRTUAL_ENV
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a minor point - why export on a separate line instead of export VIRTUAL_ENV=$(cygpath "__VENV_DIR__") as it was before?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declaring and assigning a variable at the same time can mask the return value if the command fails. Doing them separately won't which can help with debugging and error handling.

https://www.shellcheck.net/wiki/SC2155

;;
*)
# use the path as-is
export VIRTUAL_ENV="__VENV_DIR__"
;;
esac

_OLD_VIRTUAL_PATH="$PATH"
PATH="$VIRTUAL_ENV/__VENV_BIN_NAME__:$PATH"
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.