Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

venv/scripts/common/activate should use uname instead of $OSTYPE to detect Cygwin and MSYS #112507

Closed
J-M0 opened this issue Nov 29, 2023 · 0 comments
Labels
stdlib Python modules in the Lib dir topic-venv Related to the venv module type-bug An unexpected behavior, bug, or error

Comments

@J-M0
Copy link
Contributor

J-M0 commented Nov 29, 2023

Bug report

Bug description:

The venv activate script uses the $OSTYPE variable to determine if it's running on Cygwin or MSYS.

# 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

$OSTYPE is not defined by POSIX. It's provided by bash and zsh, but may not be present in other shells like dash. The uname command is always available in any shell and should be used instead.

CPython versions tested on:

3.12

Operating systems tested on:

Windows

Linked PRs

@J-M0 J-M0 added the type-bug An unexpected behavior, bug, or error label Nov 29, 2023
@iritkatriel iritkatriel added stdlib Python modules in the Lib dir topic-venv Related to the venv module labels Dec 1, 2023
vsajip pushed a commit that referenced this issue Dec 11, 2023
…H-112508)

Detect Cygwin and MSYS with `uname` instead of `$OSTYPE`

`$OSTYPE` is not defined by POSIX and may not be present in other shells.
`uname` is always available in any shell.
@vsajip vsajip closed this as completed Dec 12, 2023
aisk pushed a commit to aisk/cpython that referenced this issue Feb 11, 2024
…YPE` (pythonGH-112508)

Detect Cygwin and MSYS with `uname` instead of `$OSTYPE`

`$OSTYPE` is not defined by POSIX and may not be present in other shells.
`uname` is always available in any shell.
Glyphack pushed a commit to Glyphack/cpython that referenced this issue Sep 2, 2024
…YPE` (pythonGH-112508)

Detect Cygwin and MSYS with `uname` instead of `$OSTYPE`

`$OSTYPE` is not defined by POSIX and may not be present in other shells.
`uname` is always available in any shell.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir topic-venv Related to the venv module type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants