pdm
pdm copied to clipboard
Better support for Meson editable installs
PDM could be improved for packages using Meson and meson-python
. Note that Meson is nowadays quite important. It is used in particular for Numpy, Scipy and Scikit-image.
For these packages, the editable install (https://meson-python.readthedocs.io/en/latest/how-to-guides/editable-installs.html) has to be made with:
python -m pip install --no-build-isolation --editable .
and therefore the build dependencies have to be installed in the main virtual environment.
Currently, I have a build
dev group:
[build-system]
requires = ["meson-python", "numpy", "transonic>=0.6.1", "pythran>=0.9.7"]
build-backend = 'mesonpy'
[tool.pdm.dev-dependencies]
build = ["meson-python", "ninja", "numpy", "transonic>=0.6.1", "pythran>=0.9.7"]
And I install with:
pdm sync --clean --no-self
pdm run pip install -e . --no-deps --no-build-isolation -v
This is complicated and not optimal. PDM could detect that the project uses mesonpy
, install the build requirements in the main env and install in editable mode with the correct option (--no-build-isolation
).
Note that there is the same problem for subpackages in the repository also using Meson. For example, I'd like to have:
[project.optional-dependencies]
# so that users can run `pip install fluidfft[fftw]`
# However, it should not be included in the lock file because for development
# we want to install fluidfft-fftw from source
fftw = ["fluidfft-fftw"]
[tool.pdm.dev-dependencies]
# we want to have this one in the lock file
# fluidfft-fftw uses Meson and should be installed in editable mode with `--no-build-isolation`
plugins = [
"-e fluidfft-fftw @ file:///${PROJECT_ROOT}/plugins/fluidfft-fftw",
]
Related question: is it possible to tell PDM that some optional dependency groups should not be included by default in the lock file?
I think you could this:
pdm sync --clean --no-isolation
...instead of pdm sync ...
then pdm run pip ...
.
There's also the PDM_BUILD_ISOLATION=0
environment variable. This will affect all source builds, not just the project itself.
I'm testing PDM for PyGObject, which is also meson-python based.
I added
[tool.pdm.options]
install = ["--no-isolation"]
to pyproject.toml
. This seems to do the trick for me.
Thanks for the advice. @amolenaar What about installation of the build dependencies? Do you also repeat them in a dev group?
Yes, there's a dev group containing meson-python and friends. I linked the PR.