GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-112507 Detect Cygwin and MSYS with `uname` instead of `$OSTYPE` by J-M0 · Pull Request #112508 · python/cpython

Conversation

@J-M0

@J-M0 J-M0 commented Nov 29, 2023 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

$OSTYPE is not defined by POSIX and may not be present in other shells. uname is always available in any shell.

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@J-M0
Detect Cygwin and MSYS with uname instead of $OSTYPE
904b6e8
`$OSTYPE` is not defined by POSIX and may not be present in other shells.
`uname` is always available in any shell.
@J-M0
J-M0 requested a review from vsajip as a code owner November 29, 2023 01:46
@bedevere-app bedevere-app Bot added the awaiting review label Nov 29, 2023
@bedevere-app bedevere-app Bot mentioned this pull request Nov 29, 2023
venv/scripts/common/activate should use uname instead of $OSTYPE to detect Cygwin and MSYS #112507
Closed
vsajip
vsajip reviewed Dec 11, 2023
View reviewed changes
Comment thread Lib/venv/scripts/common/activate
# 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

@vsajip vsajip Dec 11, 2023

Copy link
Copy Markdown
Member

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?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@J-M0 J-M0 Dec 11, 2023

Copy link
Copy Markdown
Contributor Author

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.

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vsajip reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
vsajip
vsajip approved these changes Dec 11, 2023
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels Dec 11, 2023
@vsajip vsajip added the skip news label Dec 11, 2023
@vsajip
vsajip merged commit d7b5f10 into python:main Dec 11, 2023
@bedevere-app bedevere-app Bot removed the awaiting merge label Dec 11, 2023
@vsajip vsajip added needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes labels Dec 11, 2023
@miss-islington-app

miss-islington-app Bot commented Dec 11, 2023

Copy link
Copy Markdown

Thanks @J-M0 for the PR, and @vsajip for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington-app

miss-islington-app Bot commented Dec 11, 2023

Copy link
Copy Markdown

Thanks @J-M0 for the PR, and @vsajip for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington-app

miss-islington-app Bot commented Dec 11, 2023

Copy link
Copy Markdown

Sorry, @J-M0 and @vsajip, I could not cleanly backport this to 3.11 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker d7b5f102319bb0389c5248e9ecf533eae4163424 3.11
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington-app miss-islington-app Bot assigned vsajip Dec 11, 2023
@miss-islington-app

miss-islington-app Bot commented Dec 11, 2023

Copy link
Copy Markdown

Sorry, @J-M0 and @vsajip, I could not cleanly backport this to 3.12 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker d7b5f102319bb0389c5248e9ecf533eae4163424 3.12
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@J-M0
J-M0 deleted the venv_ostype branch January 3, 2024 18:21
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
@J-M0 @aisk
pythongh-112507: Detect Cygwin and MSYS with uname instead of `$OST…
e6df8a8
…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 pull request Sep 2, 2024
@J-M0 @Glyphack
pythongh-112507: Detect Cygwin and MSYS with uname instead of `$OST…
71e247a
…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.
julienp added a commit to julienp/cpython that referenced this pull request Oct 13, 2024
@julienp
Convert paths in venv activate script when using MinGW
0bb8440
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.
julienp added a commit to julienp/cpython that referenced this pull request Oct 13, 2024
@julienp
Convert paths in venv activate script when using Git Bash under Windows
9e36819
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.
This was referenced Oct 13, 2024
The virtualenv activate script does not correctly detect the Windows Git Bash shell #125398
Closed
gh-125398: Convert paths in venv activate script when using Git Bash under Windows #125399
Merged
julienp added a commit to julienp/cpython that referenced this pull request Oct 13, 2024
@julienp
Convert paths in venv activate script when using Git Bash under Windows
61ab573
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.
vsajip pushed a commit that referenced this pull request Oct 19, 2024
@julienp
gh-125398: Convert paths in venv activate script when using Git Bash …
2a378db
…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.
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 19, 2024
@julienp @miss-islington
pythongh-125398: Convert paths in venv activate script when using Git…
66bda75
… 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 <[email protected]>
@miss-islington miss-islington mentioned this pull request Oct 19, 2024
[3.13] gh-125398: Convert paths in venv activate script when using Git Bash under Windows (GH-125399) #125733
Merged
ebonnal pushed a commit to ebonnal/cpython that referenced this pull request Jan 12, 2025
@julienp @ebonnal
pythongh-125398: Convert paths in venv activate script when using Git…
f781a5d
… 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.
@ZeroIntensity ZeroIntensity removed the needs backport to 3.11 only security fixes label Feb 17, 2025
@hugovk

hugovk commented Feb 26, 2025

Copy link
Copy Markdown
Member

@J-M0 @vsajip Triage: is the 3.12 backport still needed? If so, please could you create it? Otherwise, let's remove the backport label.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vsajip pushed a commit to vsajip/cpython that referenced this pull request Feb 28, 2025
@J-M0 @vsajip
[3.12] pythongh-112507: Detect Cygwin and MSYS with uname instead o…
ff21e75
…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 <[email protected]>
@vsajip vsajip mentioned this pull request Feb 28, 2025
[3.12] gh-112507: Detect Cygwin and MSYS with uname instead of `$OS… #130674
Merged
@bedevere-app

bedevere-app Bot commented Feb 28, 2025

Copy link
Copy Markdown

GH-130674 is a backport of this pull request to the 3.12 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.12 only security fixes label Feb 28, 2025
vsajip added a commit that referenced this pull request Feb 28, 2025
@vsajip
[3.12] gh-112507: Detect Cygwin and MSYS with uname instead of `$OS…
4eb1421
…TYPE` (GH-112508) (GH-130674)

(cherry picked from commit d7b5f10)
@brianschubert brianschubert mentioned this pull request Apr 10, 2025
Double parenthesis in activated venv generated by Python 3.12.10 #132361
Closed
@LuNoX LuNoX mentioned this pull request Jun 7, 2026
gh-151042: venv: Pass VIRTUAL_ENV through cygpath inside fish on Windows #151043
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@vsajip vsajip vsajip approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@vsajip vsajip

Labels

skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@J-M0 @hugovk @vsajip @ZeroIntensity
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.