-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Incorrect platform detection when using MSYS2 MINGW64 #2355
Comments
Happy to review a PR. Note that both mingw and msys are not officially supported platforms by us, and are not guaranteed to work. |
Thanks, I may have a fix that involves using This comment is what I am basing it off. I did just install python in the MSYS2 environment and |
@davidism I see that the change introduced here is now causing this fail. Simply reverting this change seems to work on MSYS2 MINGW64. I ran the Pytests with the regular Windows python 3.10, the MSYS2 python 3.10 and the MINGW64 python 3.10. |
Thanks for looking at this. However, the previous issue and PR indicate that it was correct at the time because MSYS2 used Bash. Why is removing this correct now? What has changed, and why? |
Hi, I'll have to look through the changes in the MSYS2 repo to see if anything has changed. I'm seeing python report sys.platform on MSYS as being cygwin so maybe the package maintainers changed how the platform appears to python to resolve issues like this? I don't think checking for the string GCC is the correct way to go about checking for the platform. Both MSYS and MINGW64 compile python with GCC from what I've gathered. MSYS executables use the POSIX emulation layer but I don't think the MINGW ones do. I haven't checked the clang repos either. I'll get back to you with what I can find. |
Ran into this from platformio/platformio-core#3597 (not sure why they blamed cygwin) and investigated a bit. I think reverting #1393 is the correct solution. I think #1338 was fixed more correctly by #1135, and #1393 was misguided to start with. There are 2 distinct issues:
For this bug, the question is whether the running python can or should try to load tty/termios libraries. Msys and cygwin provide a compatibility layer that would make that work, so loading them in a python installed from For #1338, the question is whether To complicate it further, on recent win 10 conhost can be made to understand utf8+vt100 instead of using console color API (colorama does this if possible now i think?), and recent mintty uses the ConPTY API to allow it to understand the console APIs. The new windows terminal similarly works with either. None of that helps with the original reporter using 8.1, but it does make it harder to test things without an actual 8.1 install. Testing in mintty with ConPTY disabled does seem to show that #1338 is still a problem without either #1135 or #1393 though, and that #1135 is enough to fix it. |
@3b thanks for the detailed analysis. It sounds like we should revert #1393 and make sure #1135 is still intact.
Could you describe how to do that? I'm not a Windows user or developer, all these additional systems are not familiar to me. From some research, it seems like the modern system is msys2, which uses mingw-w64. I'm not sure how accurate all of the following is, but it's what I found trying to figure out the different ways Python might be available on Windows.
|
I've confirmed that |
I think i was using |
Description:
When running click in MSYS2 MINGW64 Python environment, click is trying to import tty. This fails due to termios not being a package supported by Windows.
This happens because of the platform detection in _compat.py. The following code detects the platform as being MSYS2 which then tries to use MSYS2 compatible packages:
MSYS2 = sys.platform.startswith("win") and ("GCC" in sys.version)
This does not work when using python packaged with MINGW64 as it still detects the platform as being MSYS2.
Reproduce:
Open a progress bar in MSYS2 MINGW64 Python3 i.e.
with click.progressbar(length=10, label="Downloading") as pbar:
Traceback (most recent call last):
File "C:\msys64\mingw64\lib\python3.10\site-packages\apio\managers\installer.py", line 200, in install
dlpath = self._download(platform_download_url)
File "C:\msys64\mingw64\lib\python3.10\site-packages\apio\managers\installer.py", line 382, in _download
filed.start()
File "C:\msys64\mingw64\lib\python3.10\site-packages\apio\managers\downloader.py", line 68, in start
with click.progressbar(length=chunks, label="Downloading") as pbar:
File "C:\msys64\mingw64\lib\python3.10\site-packages\click\termui.py", line 394, in progressbar
from ._termui_impl import ProgressBar
File "C:\msys64\mingw64\lib\python3.10\site-packages\click_termui_impl.py", line 626, in
import tty
File "C:\msys64\mingw64\lib\python3.10\tty.py", line 5, in
from termios import *
ModuleNotFoundError: No module named 'termios'
Expected Behaviour:
Expect the platform detection to detect the platform as Windows and not MSYS2.
Environment:
The text was updated successfully, but these errors were encountered: