Reputation: 31
I am using python in the MSYS2 environment. The MSYS2 has its own built MINGW python version. Also I can install the official python from the www.python.org.
Here is the problem: If I want to write a python code need to know the python version is MINGW or the official one, how can I do it?
Here are some ways I can image.
Is there any more elegant way can do this?
Upvotes: 3
Views: 2962
Reputation: 810
Another option is to check if GCC is in sys.version.
For example:
import sys
MSYS2 = ("GCC" in sys.version)
print(MSYS2)
> True
This works because the sys.version information has the type of compiler used, and MinGW uses GCC.
python -c "import sys; print(sys.version)"
3.7.4 (default, Aug 15 2019, 18:17:27) [GCC 9.2.0 64 bit (AMD64)]
Upvotes: 1
Reputation: 322
Mingw python3 build patched official sysconfig.get_platform()
function so it returns "mingw" and can be used for distinguishing from official python builds.
Upvotes: 6