-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
gh-112507 Detect Cygwin and MSYS with uname
instead of $OSTYPE
#112508
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
Conversation
`$OSTYPE` is not defined by POSIX and may not be present in other shells. `uname` is always available in any shell.
# 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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Sorry, @J-M0 and @vsajip, I could not cleanly backport this to
|
Sorry, @J-M0 and @vsajip, I could not cleanly backport this to
|
…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.
…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.
With python#112508 the check to change paths when running on Windows was changed from using the non-posix environment variable `$OSTYPE` to using `uname` instead. However this missed the fact that when running under MinGW shell, uname reports `MINGW*` (`$OSTYPE` is still `msys`). This results in `$PATH` being set to something like `D:\a\github-actions-shells\github-actions-shells\venv/Scripts:…`, instead of `/d/a/github-actions-shells/github-actions-shells/venv/Scripts`. Notably, the Git Bash shell for Windows behaves like this, and this is also the bash shell that’s used for GitHub Actions Windows runners.
With python#112508 the check to converts paths when running on Windows was changed from using the non-posix environment variable `$OSTYPE` to using `uname` instead. However this missed the fact that when running under Git Bash on Windows, uname reports `MINGW*` (`$OSTYPE` is still `msys`). This results in `$PATH` being set to something like `D:\a\github-actions-shells\github-actions-shells\venv/Scripts:…`, instead of `/d/a/github-actions-shells/github-actions-shells/venv/Scripts`. Notably, the Git Bash is the bash shell that’s used for GitHub Actions Windows runners, and ships with VSCode.
With python#112508 the check to converts paths when running on Windows was changed from using the non-posix environment variable `$OSTYPE` to using `uname` instead. However this missed the fact that when running under Git Bash on Windows, uname reports `MINGW*` (`$OSTYPE` is still `msys`). This results in `$PATH` being set to something like `D:\a\github-actions-shells\github-actions-shells\venv/Scripts:…`, instead of `/d/a/github-actions-shells/github-actions-shells/venv/Scripts`. Notably, the Git Bash is the bash shell that’s used for GitHub Actions Windows runners, and ships with VSCode.
…under Windows (GH-125399) * Convert paths in venv activate script when using Git Bash under Windows With #112508 the check to converts paths when running on Windows was changed from using the non-posix environment variable `$OSTYPE` to using `uname` instead. However this missed the fact that when running under Git Bash on Windows, uname reports `MINGW*` (`$OSTYPE` is still `msys`). This results in `$PATH` being set to something like `D:\a\github-actions-shells\github-actions-shells\venv/Scripts:…`, instead of `/d/a/github-actions-shells/github-actions-shells/venv/Scripts`. Notably, the Git Bash is the bash shell that’s used for GitHub Actions Windows runners, and ships with VSCode.
… Bash under Windows (pythonGH-125399) * Convert paths in venv activate script when using Git Bash under Windows With python#112508 the check to converts paths when running on Windows was changed from using the non-posix environment variable `$OSTYPE` to using `uname` instead. However this missed the fact that when running under Git Bash on Windows, uname reports `MINGW*` (`$OSTYPE` is still `msys`). This results in `$PATH` being set to something like `D:\a\github-actions-shells\github-actions-shells\venv/Scripts:…`, instead of `/d/a/github-actions-shells/github-actions-shells/venv/Scripts`. Notably, the Git Bash is the bash shell that’s used for GitHub Actions Windows runners, and ships with VSCode. (cherry picked from commit 2a378db) Co-authored-by: Julien <julien@caffeine.lu>
… Bash under Windows (pythonGH-125399) * Convert paths in venv activate script when using Git Bash under Windows With python#112508 the check to converts paths when running on Windows was changed from using the non-posix environment variable `$OSTYPE` to using `uname` instead. However this missed the fact that when running under Git Bash on Windows, uname reports `MINGW*` (`$OSTYPE` is still `msys`). This results in `$PATH` being set to something like `D:\a\github-actions-shells\github-actions-shells\venv/Scripts:…`, instead of `/d/a/github-actions-shells/github-actions-shells/venv/Scripts`. Notably, the Git Bash is the bash shell that’s used for GitHub Actions Windows runners, and ships with VSCode.
…f `$OSTYPE` (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. (cherry picked from commit d7b5f10) Co-authored-by: James Morris <6653392+J-M0@users.noreply.github.com>
GH-130674 is a backport of this pull request to the 3.12 branch. |
$OSTYPE
is not defined by POSIX and may not be present in other shells.uname
is always available in any shell.uname
instead of$OSTYPE
to detect Cygwin and MSYS #112507