Skip to content

Commit 107e061

Browse files
committed
Error out when someone tries to use msys/python to run Meson
This mistake seems to be a very common hiccup for people trying to use Meson with MSYS2 on Windows from git or with pip. msys/python uses POSIX paths with '/' as the root instead of a drive like `C:/`, and also does not identify the platform as Windows. This means that configure checks will be wrong, and many build tools will be unable to parse the paths that are returned by functions in Python such as shutil.which. Closes #3653
1 parent fbc7160 commit 107e061

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

mesonbuild/environment.py

+5
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,11 @@ def detect_system():
240240
return 'cygwin'
241241
return system
242242

243+
def detect_msys2_arch():
244+
if 'MSYSTEM_CARCH' in os.environ:
245+
return os.environ['MSYSTEM_CARCH']
246+
return None
247+
243248
def search_version(text):
244249
# Usually of the type 4.1.4 but compiler output may contain
245250
# stuff like this:

mesonbuild/mesonmain.py

+10
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from . import mconf, mintro, mtest, rewriter, minit
2424
from . import mlog, coredata
2525
from .mesonlib import MesonException
26+
from .environment import detect_msys2_arch
2627
from .wrap import WrapMode, wraptool
2728

2829
default_warning = '1'
@@ -287,6 +288,15 @@ def run(original_args, mainfile):
287288
print('You have python %s.' % sys.version)
288289
print('Please update your environment')
289290
return 1
291+
# https://github.com/mesonbuild/meson/issues/3653
292+
if sys.platform.lower() == 'msys':
293+
mlog.error('This python3 seems to be msys/python on MSYS2 Windows, which is known to have path semantics incompatible with Meson')
294+
msys2_arch = detect_msys2_arch()
295+
if msys2_arch:
296+
mlog.error('Please install and use mingw-w64-i686-python3 and/or mingw-w64-x86_64-python3 with Pacman')
297+
else:
298+
mlog.error('Please download and use Python from www.python.org')
299+
return 2
290300
# Set the meson command that will be used to run scripts and so on
291301
set_meson_command(mainfile)
292302
args = original_args[:]

0 commit comments

Comments
 (0)