-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
RFC: switch to Meson as a build system #13615
Comments
I think good documentation is essential. That meson is small and fast is a plus. It looks like meson users currently skew strongly towards Linux, C, and C++, so there will likely be some work adding support for Fortran and perhaps compilers other than gcc. OTOH, they are a high end group of users and have likely made a good choice from among the various options. Last time I experimented with cmake, admittedly many years ago, it was a mess and installation a hassle. I wanted nothing to do with it. |
I have to report from a very recent adventure with it; the situation did not change with cmake. |
|
|
It looks like there is PEP517 support available such that we can tell |
FWIW, my preference here is CMake because I have a lot of experience with it--including usage of the |
I've also submitted patches to CMake in the past for i.e., handling the |
I would love to give meson a try. I will also comment that I have gained a lot of CMake experience at my day job -- it has a lot of widespread industry support, so I don't expect it to ever go away or become unmaintained (in my lifetime at least). It may be ugly, but it certainly works |
There is a short discussion of build software at the Fortran Wiki here. Meson looks pretty cutting edge, but growing. Python was much the same, but there may be some growing pains. Both meson and cmake have 500 results on stackexchange (what is special about 500?) @certik may have some input. |
I've heard of Meson, but never used it yet. CMake certainly works, it works on Windows, has first class support for Fortran and that is my choice for all my projects. But I've heard that Meson might be better. If you are worried about Fortran, I recommend you start a thread at our Fortran Discourse to discuss: https://fortran-lang.discourse.group/ we have created a Fortran website: https://fortran-lang.org/ Finally, I would like you to also know that we are working hard on a Fortran Package Manager (fpm): https://github.com/fortran-lang/fpm, we are planning to have CMake backends, we can also add a Meson backend. fpm will be most useful for Fortran projects. For SciPy probably CMake or Meson are the two good choices. |
I don't want to propose the same thing in two places, but I'd say that if this works out well for SciPy then NumPy is likely to follow. NumPy's requirements are a little easier than SciPy's build-wise, but the benefits are similar. Plus there's the bigger "no need for much or all of
As short as possible I'd say - max one release in case it turns out packagers need to do work adjusting. Ideally pull the plug as soon as things work well with Meson. That's why the "delete the main
I didn't find any complex enough Python packages that we can learn much from. I did give myself one day a few weekends ago to both learn Meson and try to port PyWavelets. I did get pretty far and it was a pleasant experience. Didn't completely finish though, because PyWavelets has one very weird thing in its setup where just calling
Yes indeed. I edited the issue description to add this explicitly. We do need to make One thing to note is that there's no PEP yet that specifies how to invoke a development/inplace build. So we should do that in our own way (e.g.
Thanks for the input @certik. I'm not worried about Fortran really. There are non-Python Fortran projects that use Meson. All the main compilers are supported and adding niche ones looks easy: https://github.com/mesonbuild/meson/blob/master/mesonbuild/compilers/fortran.py |
The kind of thing I'm more worried/curious about is how to do very specific things. For example, if we have test failures in SciPy with Intel Fortran because |
The only tweak to the plan I would suggest is moving 8 and 10 (CI migration halves) to before step 7 (merge into SciPy |
This would fix the issue with depending on Boost nicely by the way. Meson has built-in support, so all it takes is documenting the build dependency and doing:
|
I'm the project lead of Meson and it's great that you are considering switching to it. Here are a couple of random tidbits related to the discussion here and questions raised.
One thing you probably need to consider is supporting old distro releases. If you need to build all of Scipy on an old RHEL, say, using only distro packages, this gets a bit tricky since Meson versions on those are fairly old. If you can use your own Meson then this is not an issue but there may be people who can't do that due to various policy issues. |
Thanks @jpakkane!
It looks pretty solid to me indeed. The most tricky bit may be dealing with how we have to glue MSVC and gfortran together, as documented in https://pav.iki.fi/blog/2017-10-08/pywingfortran.html#building-python-wheels-with-fortran-for-windows.
That philosophy is quite appealing. Currently our build infrastructure is split over 5 projects with all sorts of monkeypatching going on, so the benefits of having it all in one place are pretty clear to us by now:)
That shouldn't be much of a problem. Linux packagers seem fine with using recent build dependencies - we regularly require very recent Cython versions for example. As long as a build dependency is easy to install (which is the case for Meson), there's no problem. Runtime dependencies are another story, there we have to be much more conservative. |
I analyzed the repository and have found out the submodules which are easiest to port first, based upon their independence from other modules. This data might be useful to everyone involved during the project. Link to the analysis: here |
@conda-forge, we frequently run into issues with meson updates. For eg PyPy: mesonbuild/meson#8570 |
It probably is (in the short term at least). I think right now there are very few Python packages that use Meson, so it's not surprising to me there are scenario's like PyPy on macOS that aren't tested much and less are less stable. My view on it is that this will improve once more scientific Python packages adopt it (and if SciPy is successful, I think they will), and that at least Meson has a sane design. Last Sunday I spent a couple of hours fixing a |
Thanks, looks good @thisisshub. Some thoughts on the green modules:
That gives a decent coverage of languages. Then |
@rgommers, |
We had a short discussion about the Meson topic in the community meeting. The main questions were:
Where Python packaging is going
What has been changing in the Python packaging ecosystem itself is a move away from "assume a package uses setuptools" to a standards-based approach with hooks, so any package installer (like
The tl;dr of all those things is: you can specify all your project metadata and build-time and runtime dependencies in There are also a number of small projects that have as purpose to be a standalone tool fulfilling one aspect of the build/package/install lifecycle, adhering to the PEPs linked above and not requiring Status of building SciPy with MesonI have a branch named To actually use that branch:
The next steps / main blockers are:
We can work around both (2) and (3) I believe, by extensive use of (2) and (3) are both being implemented by @dcbaker, so a big thank you to him. We should probably use our own fork of Meson for a bit that is like an integration branch of upstream for 1-3. And then once we're completely happy, contribute the BLAS/LAPACK detection upstream. Can we start a long-term branch in this repo?Right now the strategy I used in my fork is:
This rebase strategy obviously doesn't work well when multiple people are collaborating on the same branch, if it's in the main repo (with a few people it does work on a fork). Also, CI runs on the main repo are not all that useful. So my preference would be to push it a little further in my own fork; once we have BLAS/LAPACK working we can add support for more submodules quickly. And then also make CI work on the fork first, so we can deal with Windows, building wheels, etc. Using PRs to my repo should work for that - I'd love some help though. Once we have most submodules done and some working CI, then I think it's time to move to this repo. The one thing we should probably do now to make life easier is to create a |
The 1.8.x branch is still 1.5 months away I think. I'd prefer to not wait that long. We can remove the CI jobs and docs from the 1.8.x branch after it's created - at that point there's really nothing else than a set of
Me neither, however the plan was always to do that for one release cycle, since I'd be uncomfortable getting rid of If it turns out to be a regular occurrence that CI doesn't pass (which I don't expect, but you never know) I'm also fine with a rule that it can be ignore - at least there's some signal then that a fix is needed. It's pretty tricky right now to keep catching up with large changes like the recent UNU.RAN and PROPACK PRs.
That is great news, exactly what we needed for that - thanks @eli-schwartz! |
Also let me add: I plan to use a stable Meson install from either https://github.com/rgommers/meson/tree/scipy or a fixed commit in the Meson repo; and will run Meson master in CI on my own fork. CI on my fork has been quite stable for ~3 months now. |
@rgommers, do you have an update on how the meson build system coming along? |
The Windows build works as well now, as do wheel builds. It's been pretty much ready to merge into master for a month or two. I just need to find a full to update the PR and iron out the last little issues with CI and changes to codegen scripts that work across Meson and distutils builds. I plan to do this around Christmas (no meetings for ~2 weeks will be really helpful). |
FWIW I tried this out on PyPy + windows, and it failed. I opened mesonbuild/meson#10080. Not a blocker, but more of a heads-up. |
We have now switched to using Meson by default by using the Thanks everyone who pitched in! |
Now that the
distutils
deprecation in Python 3.10 is around the corner, I've been thinking about moving build systems. This feels like the right time. The thought of doing a lot of work migratingnumpy.distutils
features tosetuptools
, basically becoming responsible for Fortran support there, and then still being stuck with such a poor build system isn't giving me warm and fuzzy feelings. So here's an alternative.tl;dr there are only two candidates for use as a build system, Meson and CMake. Meson +
mesonpep517
has more gaps in the short term than CMake +scikit-build
, however it's much cleaner (small code base of modern pure Python) than CMake (a ton of C++ code + a weird DSL + scikit-build seems to use legacy CMake constructs which are awful) and has much better documentation. So I'd prefer Meson.What we need from a build system
Let's first outline everything that we need in terms of build, packaging, dev workflows, etc. And then figure out the projects that implement that.
At the highest level we need the following:
A development build (can be in-place or out-of-place, as long as the workflow is good)
create an
sdist
create packages from an
sdist
(create packages from the git repo is optional):.deb
,.rpm
, Homebrew bottles, etc.Other tools and jobs to invoke (standalone and/or via a
runtests.py
-like interface):Interfacing with Python packaging/install tools (e.g.,
pip install .
should work as expected)The build system itself should handle (note, some of these we don't have today but can have):
ccache
), incremental builds including for Cython__config__.py
)CFLAGS
et al. but configurable per compilerPython-specific build features that are necessary but may live outside the main build system:
submodulename.cpython-39m-x86_64-linux-gnu.so
)Moving to Meson
Advantages:
distutils
,numpy.distutils
andsetuptools
combination is particularly fragile.setuptools
, which means that that headache just goes away.setuptools
.Challenges:
It's a lot of work to move, and we may introduce new bugs in the process.
There are missing pieces of the puzzle:
tools/cythonize.py
should be useful.mesonpep517
builds sdists and wheels, but development builds are missing. Given that PEP 517 itself does not have support, it's unclear if this should be added tomesonpep517
or done as a separate package.We'll be early adopters in the scientific Python space, so we may run into unforeseen issues.
A potential plan:
runtests.py
as needed, and/or add tomesonpep517
or a new package.scipy-wheels
repo and test wheels for all platformssetup.py
, leave othersetup.py
files in place for a while (unused, just in case)distutils
-using code and declare victoryThis will be a significant amount of work, which is why I added a GSoC project idea for it: https://github.com/scipy/scipy/wiki/GSoC-2021-project-ideas. A good student should get quite far in ~5 weeks of work.
The text was updated successfully, but these errors were encountered: