Skip to content

Recompilation in an editable install hides all compiler output #820

Closed

Description

@Cadair

This line:

subprocess.run(self._build_cmd, cwd=self._build_path, env=env, stdout=subprocess.DEVNULL, check=True)

hides all build output, so if the build fails due to missing build requirements or some other reason, you don't get any indication as to why.

I would expect the compilation output to be shown at import time.

I found this while trying to do an editable install of numpy, and because the initial install of numpy used build isolation the import time recompile did not have the build requirements (cython).

Activity

  1. rgommers commented on Nov 5, 2025

    @rgommers
    Contributor

    Does https://mesonbuild.com/meson-python/how-to-guides/editable-installs.html#verbose-mode help?

    There might be an improvement to make there, showing the build output by default only if the build fails.

  2. Cadair commented on Nov 5, 2025

    @Cadair
    Author

    That documentation page is helpful. It would be helpful for any compilation errors to show up. Apart from build environment issues I encountered, if you are developing the C code and you make a mistake you are going to want to see why!

  3. lesteve commented on Nov 7, 2025

    @lesteve
    Contributor

    Discussing with @Cadair IRL there are at least two things:

    • he was not getting an error when using meson editable install in non-verbose mode. If that's the case this seems like a bug. I was involved in Editable install: raise ImportError when rebuilding fails #648 a while ago and I think it was supposed to raise an ImportError when compilation fails? Maybe we are missing some context or this was a bit of an edge case.
    • should the default editable be verbose by default? I guess this is a bit more controversial but I lean towards "verbose by default" as well. If you are doing editable install you are likely in "developer mode" and you are probably interested to see some output when things are recompiled (be it only to be reassured something is happening).
  4. dnicolodi commented on Nov 11, 2025

    @dnicolodi
    Member
    • he was not getting an error when using meson editable install in non-verbose mode

    This is not what should happen. There is a test that verify that an ImportError is raised

    @pytest.mark.parametrize('verbose', [False, True], ids=('', 'verbose'))
    def test_editable_rebuild_error(package_purelib_and_platlib, tmp_path, verbose):
    with mesonpy._project({'builddir': os.fspath(tmp_path)}) as project:
    finder = _editable.MesonpyMetaFinder(
    project._metadata.name, {'plat', 'pure'},
    os.fspath(tmp_path), project._build_command,
    verbose=verbose,
    )
    path = package_purelib_and_platlib / 'plat.c'
    code = path.read_text()
    try:
    # Install editable hooks
    sys.meta_path.insert(0, finder)
    # Insert invalid code in the extension module source code
    path.write_text('return')
    # Import module and trigger rebuild: the build fails and ImportErrror is raised
    stdout = io.StringIO()
    with redirect_stdout(stdout):
    with pytest.raises(ImportError, match='re-building the purelib-and-platlib '):
    import plat # noqa: F401
    assert not verbose or stdout.getvalue().startswith('meson-python: building ')
    finally:
    del sys.meta_path[0]
    sys.modules.pop('pure', None)
    path.write_text(code)
    If this is not the case, we would need a way to reproduce the issue to investigate further.

    • should the default editable be verbose by default?

    The reason for making the rebuild silent by default is that editable installs may be used for packages that install scripts. The output of those scripts becomes unusable when it is intermixed with compilation logging. This problem is more severe because ninja output the compilation log on the standard output and not on the standard error. Someone went to great lengths to suppress any output when there is nothing to be built even when verbose output is enabled, thus there is definitely a group of users that does not want output emitted. What could be done is to redirect the compilation output to a file and display it (or the last N lines of it) when the compilation fails.

  5. Cadair commented on Nov 11, 2025

    @Cadair
    Author

    I got an error (the import failed) but there was no indication as to why (in my case I was missing Cython). No ninja output was shown by the import error so I didn't know how to fix it.

  6. lesteve commented on Nov 12, 2025

    @lesteve
    Contributor

    Someone went to great lengths to suppress any output when there is nothing to be built even when verbose output is enabled, thus there is definitely a group of users that does not want output emitted

    (I think?) I am one of the user who did not want any output when there is no work to do. I tried to open a PR to do it in #579, which @dnicolodi finished in #579 🙏.

    Yet at the same time, where there is an error, I would have liked a quick tip about meson-editable verbose, mostly because I am neither a meson nor meson-python expert 😅 and it took me a while to debug the situation and understand that things were not recompiling as I naively thought. As a scikit-learn maintainer, I am guessing other scientific Python package maintainers may be in a similar boat.

    I tried to mention the MESON_EDITABLE_ERROR in the ImportError message in #648 (comment) but @dnicolodi was not a great fan of the approach which I guess is completely understandable.

    To be explicit, I am not trying to sway anyone, but mostly summarize the situation at this point 😉.

  7. rgommers commented on Nov 13, 2025

    @rgommers
    Contributor

    It is a complicated UX question given the various usage scenarios plus the issues with different tools emitting content to stdout vs. sterr inconsistently. However, I would say that the main use case - using an editable build for developing a package that uses meson-python in a regular environment - does have the requirement of showing the traceback on a build error.

    What could be done is to redirect the compilation output to a file and display it (or the last N lines of it) when the compilation fails.

    I like this idea. Perhaps the last N lines + the path to the file (which will be preserved in the build dir) if the user needs the full output?

  8. crusaderky commented on Dec 5, 2025

    @crusaderky

    +1. I just hit this exact issue with meson-python used to compile cython.

  9. orlitzky commented on Feb 6, 2026

    @orlitzky

    We've received a lot of complaints about this since switching to meson-python (with an editable install by default) in SageMath. Sage is a big project, so touching the wrong file can lead to a mysterious hour-long delay when you go to test your changes.

  10. dimpase commented on Feb 6, 2026

    @dimpase

    As far as I understand, it's currently not possible to pass -Ceditable-verbose=yes via meson.options.
    Although it would be useful...

  11. eli-schwartz commented on Feb 6, 2026

    @eli-schwartz
    Member

    As far as I understand, it's currently not possible to pass -Ceditable-verbose=yes via meson.options. Although it would be useful...

    That file is solely used to define new options (and their default values) that don't previously exist; it cannot pass values for any existing options. The project default_options can be used to pass values for any built-in meson option (but not pep517 build backend options owned by meson-python).

    Meson-python as it stands today is primarily configured via pyproject.toml

    (Editable-verbose is not listed as available to be set via https://mesonbuild.com/meson-python/reference/pyproject-settings.html however.)

  12. dimpase commented on Feb 7, 2026

    @dimpase

    Editable-verbose is not listed as available

    why can't it be set in the project (meta)data, be it in pyproject.toml, or in menson.build, or in meson.options ?

    Looks like a bug to me. We don't want to tell the users to normally/always use a non-default option, or always have an environment variable set. Normal operations should be working out of the box.

  13. dnicolodi commented on Feb 7, 2026

    @dnicolodi
    Member

    No one ever asked for it. But it can be added. See #838

  14. added this to the v0.20.0 milestone on Apr 25, 2026
  15. 3 remaining items

  16. dnicolodi commented on Jun 28, 2026

    @dnicolodi
    Member

    #750 started out on the wrong foot and is still wrong. The author seems to have lost interest in fixing it.

  17. rgommers commented on Jun 28, 2026

    @rgommers
    Contributor

    The principle discussed there is still valid though: parse the ninja logs and show the relevant part of a build failure. Hence why this issue is still open. In case gh-750 keeps being stalled, someone else can give that a go.

  18. added 6 commits that reference this issue on Jun 29, 2026
    899cb5c
    afe4ef2
    9bbc6c8
    fa08e0d
    b41af25
    c8de736
  19. added 3 commits that reference this issue on Jul 23, 2026
    fba435c
    e8c67de
    7dd8711
  20. added a commit that references this issue on Aug 5, 2026
    6c0f5f7
  21. added a commit that references this issue on Aug 21, 2026
    be2f1c9
  22. added a commit that references this issue on Aug 21, 2026
    4124821
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions