Feature Request: Add `.gitignore` to `build-dir`
Hello,
This could be a misconfiguration on my part, but I am building a wheel file with
python3 -m build --wheel -Cbuild-dir=builddir
and unlike building with meson directly, I do not see a .gitignore ( or .hgignore) file in builddir. Specifically I see this building with
- meson 1.5.0
- meson-python 1.16.0
- build 1.2.1
I'm interested in keeping a semi-permanent build directory around because build times on Windows are exceedingly large, and the .gitignore file that meson usually puts in the build directory is a nice quality of life. For now I've added builddir to the project's .gitignore file but this doesn't scale very well since we use this on multiple platforms and multiple python versions.
I can reproduce this by building one of the listed examples on:
- mingw64 (unsupported python)
- Windows (official python)
- RHEL9
Hi @augusew1, good question. meson-python does write out a .gitignore file for editable installs: https://github.com/mesonbuild/meson-python/blob/063fe8bc8ad6984c29b24a0f72a14e1ced091a9c/mesonpy/init.py#L1030
I believe our understanding so far has been that users either build a wheel for a one-off install/distribution, which by default happens in a tempdir created by pip/build, or they're using one of two development methods:
- Using
meson setup, either directly or via a CLI like spin. - Using an editable install (
pip install -e . --no-build-isolation).
In both cases a .gitignore gets generated.
I'm interested in keeping a semi-permanent build directory around because build times on Windows are exceedingly large,
That makes sense to me.
For now I've added
builddirto the project's.gitignorefile but this doesn't scale very well since we use this on multiple platforms and multiple python versions.
That shouldn't matter, right? It's called builddir everywhere, there's no platform or Python version dependence here. A one-line entry in your projects' .gitignore is all you should need.
Interesting about editable installs, I'll read up on that.
That shouldn't matter, right? It's called builddir everywhere, there's no platform or Python version dependence here. A one-line entry in your projects' .gitignore is all you should need.
It's called builddir everywhere if people do -Cbuild-dir=builddir every time. We certainly encourage that but it's not guaranteed, unfortunately.
That being said I recognize there are better ways to do this and that this is very much a skill isuse on my end. If you would like to close this feel free.
I think it'd be fine to add this feature actually, so I'll leave this issue open for now.
Note that the selected build directory is allowed to be non-empty. That's the case for meson setup as well - and a .gitignore/.hgignore is only written if the directory is empty.
Meson should be doing this already? https://mesonbuild.com/FAQ.html#how-do-i-ignore-the-build-directory-in-my-vcs
Meson adds .gitignore and .hgignore only if the build directory is empty. By the time it invokes meson, meson-python created a meson-python-native-file.ini in it. Moving this file to another location is not desirable as it is useful in debugging build failures.