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

Unhandled python exception when configuring project with MSVC backend #12935

Open
brunvonlope opened this issue Mar 4, 2024 · 5 comments
Open
Labels
backend:visualstudio Visual Studio project backends bug msys

Comments

@brunvonlope
Copy link
Contributor

Describe the bug

Meson detects VS Code but fails right after:

The Meson build system
Version: 1.3.2
Source dir: C:/msys64/home/josei/gimp-fix
Build dir: C:/msys64/home/josei/gimp-fix/_build-x64
Build type: native build
Project name: gimp
Project version: 2.99.19
Activating VS 17.9.2
Exception in thread Thread-1 (_readerthread):
Exception in thread Thread-2 (_readerthread):
Traceback (most recent call last):
Traceback (most recent call last):
  File "C:/msys64/clang64/lib/python3.11/threading.py", line 1045, in _bootstrap_inner
  File "C:/msys64/clang64/lib/python3.11/threading.py", line 1045, in _bootstrap_inner
    self.run()
    self.run()
  File "C:/msys64/clang64/lib/python3.11/threading.py", line 982, in run
  File "C:/msys64/clang64/lib/python3.11/threading.py", line 982, in run
    self._target(*self._args, **self._kwargs)
    self._target(*self._args, **self._kwargs)
  File "C:/msys64/clang64/lib/python3.11/subprocess.py", line 1597, in _readerthread
  File "C:/msys64/clang64/lib/python3.11/subprocess.py", line 1597, in _readerthread
    buffer.append(fh.read())
                  ^^^^^^^^^
  File "<frozen codecs>", line 322, in decode
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc6 in position 44: invalid continuation byte
    buffer.append(fh.read())
                  ^^^^^^^^^
  File "<frozen codecs>", line 322, in decode
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 27: invalid start byte
Traceback (most recent call last):
  File "C:/msys64/clang64/lib/python3.11/site-packages/mesonbuild/mesonmain.py", line 194, in run
    return options.run_func(options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:/msys64/clang64/lib/python3.11/site-packages/mesonbuild/msetup.py", line 358, in run
    app.generate()
  File "C:/msys64/clang64/lib/python3.11/site-packages/mesonbuild/msetup.py", line 181, in generate
    return self._generate(env, capture, vslite_ctx)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:/msys64/clang64/lib/python3.11/site-packages/mesonbuild/msetup.py", line 203, in _generate
    intr = interpreter.Interpreter(b, user_defined_options=user_defined_options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:/msys64/clang64/lib/python3.11/site-packages/mesonbuild/interpreter/interpreter.py", line 331, in __init__
    self.parse_project()
  File "C:/msys64/clang64/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 132, in parse_project
    self.evaluate_codeblock(self.ast, end=1)
  File "C:/msys64/clang64/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 198, in evaluate_codeblock
    raise e
  File "C:/msys64/clang64/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 190, in evaluate_codeblock
    self.evaluate_statement(cur)
  File "C:/msys64/clang64/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 204, in evaluate_statement
    return self.function_call(cur)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:/msys64/clang64/lib/python3.11/site-packages/mesonbuild/interpreterbase/interpreterbase.py", line 530, in function_call
    res = func(node, func_args, kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:/msys64/clang64/lib/python3.11/site-packages/mesonbuild/interpreterbase/decorators.py", line 260, in wrapper
    return f(*nargs, **wrapped_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:/msys64/clang64/lib/python3.11/site-packages/mesonbuild/interpreterbase/decorators.py", line 579, in wrapper
    return f(*wrapped_args, **wrapped_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:/msys64/clang64/lib/python3.11/site-packages/mesonbuild/interpreter/interpreter.py", line 1308, in func_project
    self.add_languages(proj_langs, True, MachineChoice.HOST)
  File "C:/msys64/clang64/lib/python3.11/site-packages/mesonbuild/interpreter/interpreter.py", line 1476, in add_languages
    success = self.add_languages_for(args, required, for_machine)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:/msys64/clang64/lib/python3.11/site-packages/mesonbuild/interpreter/interpreter.py", line 1519, in add_languages_for
    comp = compilers.detect_compiler_for(self.environment, lang, for_machine, skip_sanity_check)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:/msys64/clang64/lib/python3.11/site-packages/mesonbuild/compilers/detect.py", line 115, in detect_compiler_for
    comp = compiler_from_language(env, lang, for_machine)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:/msys64/clang64/lib/python3.11/site-packages/mesonbuild/compilers/detect.py", line 112, in compiler_from_language
    return lang_map[lang](env, for_machine) if lang in lang_map else None
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:/msys64/clang64/lib/python3.11/site-packages/mesonbuild/compilers/detect.py", line 614, in detect_c_compiler
    return _detect_c_or_cpp_compiler(env, 'c', for_machine)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:/msys64/clang64/lib/python3.11/site-packages/mesonbuild/compilers/detect.py", line 330, in _detect_c_or_cpp_compiler
    p, out, err = Popen_safe_logged(cmd, msg='Detecting compiler via')
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:/msys64/clang64/lib/python3.11/site-packages/mesonbuild/utils/universal.py", line 1580, in Popen_safe_logged
    rc, out, err = p.returncode, o.strip(), e.strip()
                                 ^^^^^^^
AttributeError: 'NoneType' object has no attribute 'strip'

../meson.build:1:0: ERROR: Unhandled python exception

    This is a Meson bug and should be reported!

To Reproduce

  1. Clone gimp repo;
  2. Run build/windows/gitlab-ci/2_build-gimp-msys2.sh (with -Dbacked=vs).

Expected behavior
Meson auto-detects MSVC and start setup

system parameters

  • Native build
  • Windows 11
  • Python 3.11
  • Meson 1.3.2
@bruchar1 bruchar1 added backend:visualstudio Visual Studio project backends msys labels Mar 5, 2024
@bruchar1
Copy link
Member

bruchar1 commented Mar 5, 2024

It seems to be an encoding issue. I'm not very familiar with msys. What is your current locale? I guess msys uses the LANG environment variable.

@brunvonlope
Copy link
Contributor Author

What is your current locale? I guess msys uses the LANG environment variable.

pt-BR (i think that it uses UTF-8). But no package is localized.

I found this setting in Mintty but i'm skeptical if it have some relevance:

image

@bruchar1
Copy link
Member

bruchar1 commented Mar 5, 2024

I'm blind-guessing, but one thing you could try is to set PYTHONIOENCODING=utf8 environment variable.
You can probably do locale -a to display the current locale. Ensure it is a utf-8 locale.
That being said, there is probably a bug in meson.

@brunvonlope
Copy link
Contributor Author

Just tested. Still have the same problem

@brunvonlope
Copy link
Contributor Author

brunvonlope commented May 5, 2024

This bug can't be reproduced with .msi meson provided in the GitHub releases (exact same version: 1.4.0). Probably this only affects msys2 builds.

gatuno1 added a commit to gatuno1/meson-numpy_error that referenced this issue Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:visualstudio Visual Studio project backends bug msys
Projects
None yet
Development

No branches or pull requests

2 participants