{"id":1111,"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":"python","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,"search_vec":"'0.19.0':56 '517':14 'activ':52 'address':70 'avail':58 'backend':4,12 'build':3,11,19,73 'build-system':72 'c':42,43,78,79 'compat':71 'compil':38 'current':57 'cython':44,80 'everi':63 'extens':34,77 'featur':68 'fortran':45,81 'includ':33 'integr':16 'introduc':67 'languag':39 'librari':50 'maintain':53 'meson':1,6,18,76 'meson-python':5 'modul':35 'month':65 'new':60 'occur':62 'packag':23 'particular':26 'pep':13 'pep517':75 'project':31 'python':2,7,10,22 'pythran':46 'releas':61 'rust':48,82 'suit':29 'system':20,74 'version':55 'well':28 'well-suit':27 'written':36","created_at":"2026-04-05T13:06:10.639346+00:00","updated_at":"2026-04-16T16:30:42.321782+00:00","problems":{"verify_error":"no import statement found"},"ecosystem":"pypi","meta_description":null,"install_score":80,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.19.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/mesonbuild/meson-python","docs":"https://mesonbuild.com/meson-python/","changelog":"https://mesonbuild.com/meson-python/changelog.html","pypi":"https://pypi.org/project/meson-python/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"skip","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-05","install_tag":"verified"}}