Repository navigation
uv does not work with meson-python editable installs #10214
Description
Activity
- addedcompatibilityCompatibility with a specification or another toolCompatibility with a specification or another tool
on Dec 28, 2024 Thanks for opening a dedicated issue for meson-python support in uv 😊
I believe there was some effort in getting build isolation working with in meson-python such that it works with uv, although I haven't tried it recently to see if there's any new changes.
I believe there was some effort in getting build isolation working with in meson-python such that it works with uv,
@eli-schwartz do you know about this?I believe there was some effort in getting build isolation working with in meson-python such that it works with uv,
maybe I should instead be asking @dnicolodi
meson-python attempts to rebuild compiled code changes on during interpreter startup, to avoid the case where you create an editable install, modify a C file, and rerun the python interpreter but your changes don't apply because you didn't re-run
pip install -e ..Build isolation (a concept with a number of issues that doesn't always work) is entirely unable to cope with this, as the entire point of build isolation is to have build dependencies in a temporary virtual environment which are immediately gotten rid of. So, ninja isn't available at import time and things fail.
It is detected at editable creation and "frozen" using the full path, so as long as the virtual environment exists, even if it is not active, it should be able to rebuild -- but the point of temporary build isolation is that they do get removed, so that is not helpful.
Reacted by Lucas ColleyI'm not sure how you'd go about solving this problem from the meson-python side. You need to have the same install of meson both inside and outside of the build environment, since meson writes the path into the generated build.ninja. So simply adding it as additional runtime dependencies for editable installs would not be a solution -- and is anyways forbidden by pep 621.
You can install ninja via apt or rpm or portage or pacman, and meson-python will detect and use that from /usr/bin/ninja instead of installing a python wheel of ninja into the virtual environment. That partially ameliorates the issue.
I believe there was some effort
okay, so I guess that was referring to @henryiii's:
Meson-python should also detect a moving build environment and rerun from scratch if it's detected, a feature I recently added to scikit-build-core.
How is it possible to rerun from scratch inside the import hook?
Certainly, if you re-run
uv pip install -e .the build backend can run again, reconfigure from scratch, and correctly build. That will work fine with meson-python as far as I know, and I assume that is what @henryiii means when saying scikit-build-core handles that use case.But meson-python is re-running the inner loop of the build backend -- it is compiling out-of-date C/C++/Fortran files -- on interpreter startup, the first time you import the editable-install module. It is not able to message
uvat that time to reinstall the build backend. I don't believe scikit-build-core attempts to handle this case, it assumes when you edit C/C++/Fortran files you re-install the editable package.For anyone coming to this issue in an attempt to make a meson-python project installable in a project workflow as editable, an alternative is to use https://pixi.sh/latest/reference/pixi_manifest/#no-build-isolation, provided that dependencies are available as conda packages. Pixi installs the conda dependencies first, so they are available when
uvis called to resolve the PyPI dependencies and during the build process.For anyone specifically trying to develop scikit-learn with a project workflow, see https://github.com/glemaitre/scikit-learn-workspace/blob/main/src/scikit-learn/pixi.toml for how this works in practice!
- added a commit that references this issue
on Oct 22, 2025 - added a commit that references this issue
on Dec 30, 2025 - added a commit that references this issue
on Sep 26, 2026
As per #7857 (comment), breaking the discussion from there out into a new issue.
A simple reproducer:
Error:
@rgommers summarised the problem:
@henryiii said
cc @samypr100 @zanieb @bluss