-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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 win32 vs msys2 conditions on Windows 10. #1338
Comments
Want to open a PR? |
I also have the problem originally reported in #650, so I'd like to see this solved. However, with MSYS2, one needs to carefully distinguish between its MSYS subsystem on the one hand and its MINGW64/32 subsystems on the other hand. Which the proposed change does not yet do at this point. The MSYS subsystem is intended to be mainly a UNIX-like environment under Windows. The MINGW64/32 subsystems are intended to be mainly a build environment for native Windows executables. They have different tool chains that should not be mixed, and they have different python2/3 packages for each kind of subsystem, each built with the proper toolkit for the subsystem. You can see one difference between these subsystems in the way directory path names are constructed (see the examples below). IMO, the MINGW64/32 subsystems are the more important ones to support, but if we are at it, we may as well support all three subsystems of MSYS2. Also, we should make a decision whether or not the old MINGW+MSYS (http://www.mingw.org/wiki/MSYS, i.e. before MSYS2) still should be supported by Pip or not. I think with the presence of MSYS2 the old MINGW+MSYS have no real reason to be used anymore, but that's just my opinion. In the current MSYS2 version, the In MSYS2, the MSYSTEM environment variable is guaranteed to be set to the upper case name of the active subsystem. Because the MINGW64/32 subsystem is intended to be a native WIndows environment, Python's Python 2 packages in MSYS2:
MSYS2 with MINGW64 subsystem:
MSYS2 with MSYS2 subsystem:
Sorry for the lengthy explanations, but if we want to support these MSYS2 subsystems properly, the proposed change needs to be extended. |
As noted in #650, I believe this is something that should be fixed at the MSYS2 end. They patch their Python build quite heavily, so it's down to them to patch it in a way that means that pip and virtualenv work correctly. The MSYS2 build of Python isn't supported by the Python core developers, so I don't think pip/virtualenv are likely (speaking as a core dev on both projects) to add special case code to support that build. |
With all the conditional code dependent on IS_WIN that is already in the current virtualenv.py code, I feel it is a bit too simple to argue that it is MSYS2's fault. That code in virtualenv.py has several inconsistencies (sometimes it uses IS_WIN, sometimes sys.platform=='win32', sometimes it invokes os.symlink without checking whether it exists, to name just a few). I don't think the problem can be solved by asking MSYS2 not to patch Python in a way that makes virtualenv fail. I think it takes quite some cleanup in virtualenv as well, if only to remove technical debt. On the arguments used in #650: If we just look at the MINGW64/32 subsystem of MSYS2, it is not so bad anymore. sys.platform is win32, and when not using a virtualenv, it does have the correct directories in sys.path (the statement in #650 that a directory was missing,was made when looking at a virtualenv that did not work), its sys.prefix is correct, and pip installs and works correctly. Maybe that wasn't the case in 2014 when #650 was discussed, but it is the case now. The main thing that makes MINGW64/3 different from Windows is that it has UNIX paths. And that cannot be addressed by having MSYS2 patching Python differently. That is in fact something that needs to be properly recognized in virtualenv. Of course, virtualenv can decide to ignore MSYS2, but arguing with the way they patched Python is not really a valid argument, IMO. Update: Having said that it has UNIX paths, is even not quite correct. If you look at sys.path and sys.prefix, you see that it has Windows paths with forward slashes. Which means it ought to work on native Windows (which is its purpose). |
PS: I'm willing to help on this one, but you need to let me to... :-) |
The point is that MSYS2 Python says it's Windows, but then it doesn't behave in the way that claim would imply (or it says it's Unix, and doesn't behave in the way that claim would imply - I don't know which). It's not that having conditional code in applications (and everything you say above could apply to any one of many applications, not just virtualenv) is wrong, just that the applications need to be able to rely on the meaning of the checks (like One question - have you talked to the MSYS2 Python maintainers at all, to find out if there are reasons why they have the behaviours that they do? Are they willing to accept patches to make it easier for applications to write code that works portably on MSYS2 as well as on the core Python supported platforms? Looking at the specifics, the MSYS subsystem appears to be returning a value that's not technically valid according to the sys.platform docs which only allow for arbitrary values on non-Linux Unix systems. So MSYS is technically claiming to be a Unix system here - and maybe it is, I don't know how good its POSIX emulation is. The MINGW subsystem is claiming to be Windows. But I'm not clear in what ways it isn't. Looking at the patch reverenced in the original issue here, I see the following:
Well, from your example, only for the MSYS subsystem not the MINGW62/MINGW32 subsystem. The only thing I see there is that Anyway, you've not convinced me. Maybe the other maintainers will have different views, but I still feel that msys is not a supported platform for us, and any fixes should be handled by them. (Of course, another option would be for them to provide a customised msys virtualenv and pip via their own channels, if they wanted to avoid changing their Python build). |
I think the rewrite branch fixed this. |
This is a new bug report in relation to issue #650
The conditionals are broken for using virtualenv inside msys2 as Python reports the os as 'win32'.
@pe244 came up with a solution in #650 which I've updated for the latest source. Unfortunately the bug report was closed due to being idle. It is still in issue on Windows 10.
The is_msys variable is somewhat of a hack but it does work.
If there are any fixes or testing required let me know this does work for me and I've deployed it a few dozen times.
Here is a patch for v16.0.0:
msys2_win10_2019-03-25.diff.txt
The text was updated successfully, but these errors were encountered: