Repository navigation
Tracking issue: defaulting to Meson - follow-up tasks #23981
Copy link
Copy link
Closed
Labels
MesonItems related to the introduction of Meson as the new build system for NumPyItems related to the introduction of Meson as the new build system for NumPy
Milestone
Description
After gh-23838 we now default to building with Meson (via meson-python, when invoking a build with pip install . or similar) in main. There are a number of more niche build configs not yet ported, and a few things were xfail-ed and need fixing up. Here is a list, roughly in order of priority:
- Build nightlies for Python 3.12 to unblock other projects from testing with 3.12 (xref CI: BLD: build wheels and fix test suite for Python 3.12 #23991)
- Improve how CBLAS and ILP64 flags/dependencies are handled (xref BLD: undefined symbol: cblas_sgemm when building with meson with pip install #23909, and also automate passing
CFLAGS/CXXFLAGS- I'll work on this next): see BLD: improve handling of CBLAS, add-Duse-ilp64build option #23984 - Finish implementing all BLAS/LAPACK auto-selection and control options (e.g. the equivalent of
NPY_BLAS_ORDER). Done in ENH: meson: implement BLAS/LAPACK auto-detection and many CI jobs #24893 - Fix up the issue with PyPy and re-enable the
pypy3.9CI job on Azure. Done in BLD/CI: re-enable ILP64 usage and PyPy job in Azure #24238. - Integrate SIMD support (the relevant CI jobs are still going through
runtests.py) - Update the build docs (partially done in DOC: Update building docs to use Meson #24573; the rest in DOC: add "building from source" docs #25350).
- Fix and re-eanble the 32-bit Windows wheels builds with MSVC on Azure (or move to GHA, or drop? - see DEP: stop building and testing 32-bit windows #23717). Re-introducing on GHA in CI/BLD: fail by default if no BLAS/LAPACK, add 32-bit Python on Windows CI job #24279.
- Fix the
long doublerepresentation check so the builds works on some of the more niche platforms again (xref BUG: New meson system fails to identify long double representation on 64-bit BE platforms #23972) - Fix the
xfail-edtest_cythonfor Windows due to a missingnpyrandom.lib(done in BLD: change file extension for installed static libraries back to.lib#23983) - Move Travis CI jobs over to Meson
- Check that all CI jobs have been moved over (e.g., by removing
runtests.pyandsetup.py, then running CI and ensuring nothing fails). Done - there were a lot left. See Restructuring GitHub Actions CI jobs #24410 for the tracking issue for CI migration. - Investigate how to fix the
bin/f2py3XCLI install, in addition to thef2pyandf2py3ones (see project.scriptsinpyproject.toml`, and commit f22a33b). Or can/should that interface be dropped? Multiple installs into a single env is considered bad practice by now. Dropped in BLD: only install thef2pycommand, notf2py3orf2py3.X#24235. - Investigate and fix the two
einsumtest failures withint8/uint8that were xfailed in BLD: switch to meson-python as the default build backend #23838 (EDIT: these two tests fail withclang-clon Windows too, see ENH: Add changes that allow NumPy to compile with clang-cl #20866 (comment)). EDIT: opened separate issue: BUG:einsumwith int8/uint8 input is buggy #24732 - Fix the array-api entrypoint installation (see
xfailinnumpy/tests/test_public_api.py). Done in TST: enable test that checks fornumpy.array_apientry point #24249. - Fix the
longdoublestring repr test failures onaarch64- see Issue printinglongdoubleon Linux aarch64 with the Meson build #23974 and Revert "TST: disable longdouble string/print tests on Linux aarch64" #23985 - Move the Pyodide CI job over to Meson
- Clean up the apparently unused
skipstatements under[tool.cibuildwheel]inpyproject.toml; the platforms to build for are controlled in.github/workflows/wheels.yml - Compare all files included in sdist and wheel between the setup.py and Meson builds, ensure nothing went missing
- Fix
numpy.__version__(see comment further down) - Remove usages of
numpy.distutilsin user-facing docs. Here is one example.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
MesonItems related to the introduction of Meson as the new build system for NumPyItems related to the introduction of Meson as the new build system for NumPy
Activity
charris commentedon Jun 18, 2023
Note that cibuildwheel now supports Python 3.12.0b2.
mattip commentedon Jun 18, 2023
setup.pyandruntests.py(which usessetup.pyunderneath) are still used in thetools/travis-test.shscript.rgommers commentedon Jun 18, 2023
Thanks, included two action items related to that, one for Travis CI and one to ensure nothing else was forgotten in any CI jobs.
rgommers commentedon Jun 19, 2023
This is due to the produced static library being named
libnpyrandom.arather thanlibnpyrandom.lib, anddistutils(used bytest_cython) not understanding that. For why, see https://mesonbuild.com/FAQ.html#why-does-building-my-project-with-msvc-output-static-libraries-called-libfooa.We're planning to drop this static library completely in 2.0, and if we don't get to that we can keep the
.afile extension I'd say. For 1.26.0 though, we're better off using.libin order to not break SciPy'ssetup.pyWindows build (that may still have to work with 1.26.0).BLD: change file extension for installed static libraries back to `.lib`
ngoldbaum commentedon Jun 19, 2023
It would be nice if the version information from versioneer could percolate up to meson at install time, like the old setuptools build. This is a little confusing:
rgommers commentedon Jun 19, 2023
The exact same thing (including git hash in wheel filename and in
.dist-info/METADATA) is not really possible, there's no mechanism for propagating such dynamic info back up tomeson-python.__version__needs fixing though, it should be2.0.0.dev0+xxx. I added a task to the issue description.However, I'm also (yet again) wondering what on earth
versioneeris doing here. The most recent tag isv1.25.0, but in the root of a clean repo:Each time I look at
versioneerI get a little annoyed, because it's ~3,000 lines of essentially garbage incomprehensible code split acrossversioneer.pyandnumpy/_version.pyfor doing exactly the same job as the ~120 LoC in https://github.com/scipy/scipy/blob/main/tools/version_utils.py.I vote we get rid of it, and do exactly what SciPy does here - both lowest effort and a good cleanup.
seberg commentedon Jun 19, 2023
RAPIDS is also going away from versioneer use as I understand it and I think many projects are. Happy if we do also.
charris commentedon Jun 19, 2023
There is a missing tag.
charris commentedon Jun 19, 2023
I think some funny merges have taken place, messing up the history.
charris commentedon Jun 19, 2023
And I think I know what happened, investigating.
ngoldbaum commentedon Jun 19, 2023
For the docs, I think a reasonable editable development build command we can suggest (following pandas):
The
editable-verbose=Truebit avoids a confusing situation where importing numpy can cause a numpy build to happen unexpectedly, so the user will at least get output from meson in that case instead of a hanging python process.In addition, we should document how to pass arguments via meson-python to meson, e.g. here's how to create a debug build and override the default release build:
Just commenting here with that for now because it took 15 minutes or so to figure out the proper way to pass arguments from pip into meson-python and then into meson.
rgommers commentedon Jun 19, 2023
Good points @ngoldbaum. Do you find the
editable-verbose=trueuseful/necessary? I don't have much experience with it yet; happy with either choice there.Also, to save a bit of typing,
--config-settingscan be abbreviated now with an up-to-datepipto-C:36 remaining items
rgommers commentedon Sep 17, 2023
I've opened gh-24732 as a separate issue for that. It is a lot lower-prio to me than the other two items, and I don't have the hardware needed to reproduce the problem, so I'll leave that to whoever feels like digging in.
ngoldbaum commentedon Sep 21, 2023
I just noticed there are still some spots in the docs that tell users to use
numpy.distutilsso I added a task to the issue to deal with those.jorisvandenbossche commentedon Nov 16, 2023
I was helping a colleague to install a numpy debug build from source yesterday, and we ran into a few issues / confusions with the new meson / spin setup. Summarizing our experience here, in case that has some useful pointers for where the docs can be improved:
pip installinstructions there work fine to get an install, except that our goal was a debug build. But it has a note on "Advanced building with Meson", which points to the SciPy docs for more information (https://docs.scipy.org/doc/scipy/building/compilers_and_options.html). However, I think those instructions from SciPy might no longer be valid for numpy? (for example my understanding is that themeson setupdoesn't work right now for numpy because you vendor meson?)And so the
meson setup build --buildtype debugmentioned there didn't work to get a debug build throughpip installspin. First note here is that this full page doesn't mention whatspinactually is. It might be explained elsewhere in the docs, but this page is the first one (after git) in the "Development" section of the docs. For example mentioning thatspinis something you need to install separately (pip install spin) might be useful (it could also have been a tool included in the numpy repo itself, or similar to a makefile)spin build -- -Dbuildtype=debug ..command mentioned there, but what was unclear to me is what this exactly does. Did it only build numpy, or did it also install it in my dev env? My understanding now is that this essentially only builds numpy and "installs" it in a specific directory, but not in your environment, so you need to specifically add this directory on the path to use this build of numpy. This is whatspin test ..,spin gdb ..etc do for you (from seeing the console output doing anexport PYTHONPATH= ..). This is fine if you use those tools, but in our case we wanted to install numpy into our pyarrow dev environment (copying thatexportcommand manually worked to get pyarrow rebuilt). It's not clear to me ifspinalso has the option to do an actual install into your environment.spin gdbworked fine for me, my colleague had to uselldb. But that's withoutspin, so that means you need to manually set the python path to pick up the numpy build fromspin build? (which is not mentioned in the docs)In the end, once we got the gdb running with the numpy debug build, it pointed us directly to the information we needed to know, so a good ending to the story ;)
I assume that for our case, it might have been easiest to just stick with the initial
pip installwe tried, and I noticed that higher up here in this issue, it is mentioned how you can pass the debug build flag through pip (#23981 (comment)) withpython -m pip install . --config-settings setup-args="-Dbuildtype=debug". I agree that it would be nice to document this more clearly.rgommers commentedon Nov 16, 2023
Thanks for sharing your experience @jorisvandenbossche. Sorry it was painful - I guess we should update these docs asap.
spindoesn't have that option, it is only useful and meant for working onnumpyitself. We need to clearly separate "development work on numpy" from "building and installing numpy".Yes indeed, that should be all that is needed here. And with an up-to-date version of
pip, it gets even shorted (the-Calias for--config-settingswas added):stefanv commentedon Nov 16, 2023
Wrt potential spin improvements:
rgommers commentedon Jan 16, 2024
This is basically done and the tracking issue has served its purpose. I'm sure there's little more loose ends somewhere, but those should get their own issues by now.
I'll open a separate issue for this, that's a doc task that is more related to the deprecation of
numpy.distutilsthan to the introduction of Meson - it's just actionable now. EDIT: done in gh-25597