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

chore: switch to meson as build backend #327

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open

Conversation

rdenham
Copy link
Contributor

@rdenham rdenham commented Jan 27, 2025

What is this PR changing?

Transition to meson as the build backend

Our team is switching to meson as the build backend for all python projects that include compiled code, such as fortran, cython, c++ etc (not rust though, that would use maturin).

This helps us keep up to date with changes in python and numpy. Since some of our projects use geowombat as a dependency, then I was wondering if this sort of approach would be useful to this project as well. It would make building and installing geowombat on python > 3.12 and with numpy >= 2 easier for us.

I've included an example of the transition in the PR, but note that there are a couple of things that probably need work:

  • handling version. For now I've just added the version string to pyproject.toml, but I probably should look into a method that aligns with your current approach to setting version
  • most tests pass, but I did have a failure with one of the coreg tests which needs looking into
  • I unpinned pretty much everything, but this might need to be reviewed.

I've included a Dockerfile to provide an example of how geowombat can be installed for Ubuntu users, the main part is as follows:

RUN cd \
    && uv venv \
    && . .venv/bin/activate \
    && uv pip install gdal[numpy]==$(gdal-config --version)  \
    && uv pip install git+https://github.com/rdenham/geowombat@meson 

(uv is great, but the same should work for standard pip as the packaging frontend system).

Let me know if there is any interest in this and if so I'll do a bit more to make it fully functional.

numpy_dep = dependency('numpy', version: '>=2.0.0',required: true)
omp = dependency('openmp')

import('python').find_installation().extension_module(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The py_mod and py3 variables established in the root meson.build file are available for use here as well.

While you are at it, you may choose to do dependency lookups (dependency()) a single time in the root meson.build file as well, rather than once per subdir using it. The lookups are cached either way so it won't re-run the finders (numpy-config etc.), but it will emit additional log lines.

'src/geowombat/handler.py',
],
subdir: 'geowombat',
pure: false

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since meson 0.64, you can use pure: false in "find_installation" and it will be the defaulted value for each "install_sources" call, which lets you save a bit on DRY.

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

Successfully merging this pull request may close these issues.

3 participants