BLD: use meson's NumPy resolution mechanism for building#63703
BLD: use meson's NumPy resolution mechanism for building#63703jorisvandenbossche wants to merge 4 commits intopandas-dev:mainfrom
Conversation
Instead of querying the include folder's location from NumPy during building, use Meson's built-in dependency resolution for NumPy. With this change during build-time Meson first tries to query the dependency details using numpy-config (which, in turn essentially uses the same method as the original code this commit replaces), and in case that fails for some reason, it tries to discover NumPy resources using pkg-config - which, beside being a good fail-over mechanism, has the added benefit of somewhat simpler cross-compiling, as querying the include folder location from NumPy module is only usable for cross-compiling only in some corner cases, while pkg-config is a bit more universal. Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
|
The In case they are needed for a cross-compile job (do you have any here?), then there is no need to poke at private numpy internals, you can get the right path by simply running: |
|
Yes, I was going to post some follow-up questions/notes after reading through the whole discussion in the original PR:
|
|
Oh you're not wrong, having to run the host interpreter is pretty much the most critical point for cross compilation. That said, conda-forge relies on The other way to deal with it is a cross file, which is typically being written out by distro tooling for things like compilers; passing a second cross file with a
|
|
Hi @rgommers and @jorisvandenbossche, you are right that the environment variable doesn't work in this case. I noticed that the I think this links back to this draft PR in I'll note that we do ship a Meson cross file; accessible via the command line as |
| tempita = files('generate_pxi.py') | ||
| versioneer = files('generate_version.py') | ||
|
|
||
| numpy_dep = dependency('numpy', method: 'auto') |
There was a problem hiding this comment.
If you still intend to support numpy<2, you can create a NumPy dependency as it was done before in incdir_numpy.
| numpy_dep = dependency('numpy', method: 'auto') | |
| numpy_dep = dependency('numpy', required: false) | |
| if not numpy_dep.found() | |
| incdir_numpy = run_command( | |
| py, | |
| [ | |
| '-c', | |
| ''' | |
| import os | |
| import numpy as np | |
| try: | |
| # Check if include directory is inside the pandas dir | |
| # e.g. a venv created inside the pandas dir | |
| # If so, convert it to a relative path | |
| incdir = os.path.relpath(np.get_include()) | |
| except Exception: | |
| incdir = np.get_include() | |
| print(incdir) | |
| ''', | |
| ], | |
| check: true, | |
| ).stdout().strip() | |
| numpy_dep = declare_dependency(include_directories: incdir_numpy) | |
| endif |
There was a problem hiding this comment.
My understanding is that this is run / checked during build time only, and we already do require numpy>=2 for building (in the build-system.requires key in pyproject.toml), so we can assume numpy>=2 here ?
There was a problem hiding this comment.
In the failing CI jobs it's being used numpy==1.26.0, so it's possible to bypass this requirement with --no-build-isolation.
There was a problem hiding this comment.
Ah yes. I had seen that failure and was planning to update that to use a newer numpy or to not use build-isolation, as that feels like an error on our side (as a user of pandas in our own CI), we should honor our own build requirements.
In general if you use build isolation, you are responsible to make sure to have all needed libraries and correct versions installed, so my feeling is that we don't have to account for the use case of older numpy in that case.
|
This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this. |
Continuation of #61095