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

Fix OSError when running on MinGW64 with MSYS2 #1393

Merged
merged 1 commit into from
Oct 9, 2019

Conversation

danyeaw
Copy link
Contributor

@danyeaw danyeaw commented Sep 13, 2019

Fixes #1338.

In version 6.0, echo and prompt functions were modified to work with full unicode in the windows console by emulating an output stream. Since MSYS2 uses a bash console it was creating an OSError to apply these modifications when running in this environment.

This PR changes these modifications to only apply them if not running in a MSYS2 environment.

@danyeaw
Copy link
Contributor Author

danyeaw commented Oct 5, 2019

Thanks for the awesome library! ❤️ Any interest in merging these changes or will we need to fix this downstream?

@davidism
Copy link
Member

davidism commented Oct 5, 2019

Thanks for working on this, sorry I didn't comment sooner. This check seems like it could cause false positives. Is there no better way to detect that MinGW is used?

@danyeaw
Copy link
Contributor Author

danyeaw commented Oct 5, 2019

@davidism I am not sure how you could have GCC on a Windows platform without using MINGW. Was there a false positive you had in mind?

Downstream, MINGW patches sysconfig, so we could do something like:

try:
     from sysconfig import _POSIX_BUILD
     MSYS2 = _POSIX_BUILD
except ImportError:
     MSYS2 = False

This seems kind of messy compared to the solution I used though. 😄

@davidism
Copy link
Member

davidism commented Oct 5, 2019

I'm not super familiar with these types of tools, but what about others like Cygwin, MSYS2, or WSL? Do they require the same fix? Or do they get picked up incorrectly by this check?

@danyeaw
Copy link
Contributor Author

danyeaw commented Oct 6, 2019

@davidism I ended up installing Cygwin to test this out. You are correct in that Python installed in Cygwin is compiled with GCC as well. However, sys.platform.startswith('win') returns False, since sys.platform returns cygwin. I don't have access to WSL, but I understand that sys.platform returns linux. Click in Cygwin works fine currently with master and this branch.

I think my changes might be a little more clear if I did:
MSYS2 = sys.platform.startwith('win') and ('GCC' in sys.version)
and then:
WIN = sys.platform.startswith('win') and not APP_ENGINE and not MSYS2

and then remove my changes from the if statement. Do you agree? If so I can update my PR.

@ThiefMaster
Copy link
Member

Yes, WSL is Linux as far as userspace is concerned (and sys.platform indeed returns 'linux' there)

@davidism
Copy link
Member

davidism commented Oct 6, 2019

I like the suggested more specific version.

@danyeaw
Copy link
Contributor Author

danyeaw commented Oct 6, 2019

@davidism I have updated the PR with the discussed changes 👍

@jcrotts jcrotts added this to the 7.1 milestone Oct 9, 2019
Fixes pallets#1338. In version 6.0, echo and prompt functions were modified to
work with full unicode in the windows console by emulating an output
stream. Since MSYS2 uses a bash console it was creating an OSError to
apply these modifications when running in this environment.
@davidism davidism merged commit ec6f110 into pallets:7.x Oct 9, 2019
@danyeaw
Copy link
Contributor Author

danyeaw commented Oct 9, 2019

Thanks @davidism

@davidism
Copy link
Member

davidism commented Oct 9, 2019

Thanks for the fix!

Right after I merged this, I noticed that it's very similar to issue #1065, although the fix in #1135 addresses the Windows API rather than detecting MSYS2. Any thoughts on their relation?

@davidism
Copy link
Member

davidism commented Oct 9, 2019

It appears that this fixed #1065, so I need to figure out if I should merge #1135 too. cc @segevfiner

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants