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

Better support for Meson editable installs #2621

Open
paugier opened this issue Feb 7, 2024 · 4 comments
Open

Better support for Meson editable installs #2621

paugier opened this issue Feb 7, 2024 · 4 comments
Labels
⭐ enhancement Improvements for existing features

Comments

@paugier
Copy link

paugier commented Feb 7, 2024

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?

@paugier paugier added the ⭐ enhancement Improvements for existing features label Feb 7, 2024
@pawamoy
Copy link
Sponsor Contributor

pawamoy commented Feb 7, 2024

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.

@amolenaar
Copy link

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.

@paugier
Copy link
Author

paugier commented Feb 8, 2024

Thanks for the advice. @amolenaar What about installation of the build dependencies? Do you also repeat them in a dev group?

@amolenaar
Copy link

Yes, there's a dev group containing meson-python and friends. I linked the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⭐ enhancement Improvements for existing features
Projects
None yet
Development

No branches or pull requests

3 participants