pyproject-api is a Python library that provides an abstract API for interacting with `pyproject.toml`-based projects. It standardizes the communication with various build backends (like setuptools, Hatchling, Flit) as defined by PEP 517 and PEP 660, allowing tools to build, inspect, and manage Python packages without direct knowledge of the underlying build system. The library is actively maintained by the tox-dev team and is currently at version 1.10.0, with regular releases to support new Python versions and address issues.
pip install pyproject-apiVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `pyproject_api.Frontend` to programmatically interact with a project structured around `pyproject.toml`. It sets up a minimal project with a dummy build backend, then uses `Frontend` to query build requirements and simulate building a wheel. The `backend_paths` argument is essential for `pyproject-api` to locate and import your custom build backend module.
Upgrade your Python environment to 3.10 or higher. For older Python versions, use pyproject-api <1.9.0 for Python 3.9, or pyproject-api <1.8.0 for Python 3.8.
Always include the necessary build backend in your `pyproject.toml`'s `[build-system] requires` section. If an operation fails with `BackendFailed`, verify the backend's presence and functionality.
Thoroughly validate your `pyproject.toml` content against PEP specifications (PEP 517, PEP 518, PEP 621) and the requirements of your chosen build backend. Use tools like `validate-pyproject` or `check-wheel-contents` for pre-build validation.
If your code directly instantiates `pyproject_api.Frontend`, update it to use a concrete subclass such as `pyproject_api.pip_frontend.PipFrontend` (if `pip` is installed), or implement your own custom subclass that provides an implementation for the abstract method `_send_msg`. Alternatively, if direct instantiation of the base `Frontend` class is required for compatibility with older code, pin `pyproject-api < 1.7.0`.