{"library":"meson-python","title":"Meson Python build backend","description":"meson-python is a Python build backend (PEP 517) that integrates the Meson build system for Python packages. It is particularly well-suited for projects that include extension modules written in compiled languages such as C, C++, Cython, Fortran, Pythran, or Rust. The library is actively maintained, with version 0.19.0 currently available, and new releases occurring every few months to introduce features and address compatibility.","status":"active","version":"0.19.0","language":"en","source_language":"en","source_url":"https://github.com/mesonbuild/meson-python","tags":["build-system","pep517","meson","extensions","c","c++","cython","fortran","rust"],"install":[{"cmd":"pip install meson-python","lang":"bash","label":"Install meson-python"},{"cmd":"pip install build meson ninja","lang":"bash","label":"Install build tools (recommended)"}],"dependencies":[{"reason":"Required build system that meson-python integrates with.","package":"meson","optional":false},{"reason":"Default high-performance build tool used by Meson.","package":"ninja","optional":false},{"reason":"Requires Python 3.9 or newer. Python 3.8 support was dropped in 0.19.0.","package":"python","optional":false},{"reason":"Minimum required version has been bumped multiple times for PEP 639 support and other features.","package":"pyproject-metadata","optional":false}],"imports":[{"note":"meson-python is a build backend and is not typically imported into Python code. Its functionality is invoked by build frontends (like pip or build) via the 'build-backend' entry in pyproject.toml.","symbol":"mesonpy","correct":"# Defined in pyproject.toml\n[build-system]\nbuild-backend = 'mesonpy'"}],"quickstart":{"code":"mkdir my_project\ncd my_project\n\n# Create pyproject.toml\ncat <<EOL > pyproject.toml\n[build-system]\nrequires = [\"meson-python\", \"meson\", \"ninja\"]\nbuild-backend = \"mesonpy\"\n\n[project]\nname = \"my_example_package\"\nversion = \"0.1.0\"\nEOL\n\n# Create meson.build\ncat <<EOL > meson.build\nproject('my_example_package', 'python', version: '0.1.0')\npython = import('python').find_installation(pure: false)\npython.install_sources(\n    'src/my_example_package/__init__.py',\n    subdir: 'my_example_package'\n)\nEOL\n\n# Create a simple Python source file\nmkdir -p src/my_example_package\ncat <<EOL > src/my_example_package/__init__.py\ndef greet():\n    return \"Hello from my_example_package!\"\nEOL\n\n# Build the package (e.g., a wheel)\npython -m build --wheel\n\n# Install and test (optional)\npip install dist/*.whl\npython -c \"from my_example_package import greet; print(greet())\"\n","lang":"bash","description":"This quickstart demonstrates how to set up a minimal Python project using `meson-python` as the build backend. It involves creating a `pyproject.toml` to declare `mesonpy` as the backend and a `meson.build` file to define the build logic. The example then shows how to build a wheel distribution and optionally install and test it."},"warnings":[{"fix":"Upgrade your project's Python interpreter to 3.9 or newer.","message":"Python 3.7 support was dropped in meson-python 0.18.0, and Python 3.8 support was dropped in 0.19.0. Projects using these older Python versions will need to upgrade to at least Python 3.9.","severity":"breaking","affected_versions":">=0.18.0"},{"fix":"Ensure that Meson version 0.64.0 or newer (or 1.2.3+ for Python 3.12+) is installed in your build environment.","message":"The minimum required Meson version was bumped to 0.64.0 in meson-python 0.18.0, and Meson 1.2.3 or later is required for Python 3.12+ in meson-python 0.15.0.","severity":"breaking","affected_versions":">=0.15.0, >=0.18.0"},{"fix":"For data files needed at runtime, include them within your Python package alongside the code and access them using `importlib.resources` (or the `importlib-resources` backport for older Python versions).","message":"Meson's `install_data()` function installs non-package data files to a platform-specific location, making them difficult to reliably find at runtime after wheel installation.","severity":"gotcha","affected_versions":"All"},{"fix":"While some options can be passed via environment variables or specific build frontend flags, for fine-grained control or complex native configurations, consider an explicit `meson setup` step before invoking the Python build frontend, or consult `meson-python` documentation on passing build config settings.","message":"Passing native build options to Meson via `pip` or `build` can be complex due to the layers of abstraction introduced by the PEP 517 backend. Full control over Meson flags might be hindered.","severity":"gotcha","affected_versions":"All"},{"fix":"Monitor `meson-python` and Meson project releases for compatibility fixes with Python 3.13. If encountering issues, consider using an earlier Python version until a fix is available.","message":"Changes in `os.path.isabs` semantics in Python 3.13 have been reported to break Meson's path detection on Windows, which could lead to build failures for projects using `meson-python`.","severity":"gotcha","affected_versions":"Potentially future versions of Python 3.13+"}],"env_vars":null,"last_verified":"2026-04-05T00:00:00.000Z","next_check":"2026-07-04T00:00:00.000Z"}