pyproject-hooks
A low-level library for calling build-backends in pyproject.toml-based Python projects. Current version: 1.2.0, released on September 29, 2024. Maintained by Thomas Kluyver, it provides basic functionality to help write tooling that generates distribution files from Python projects. If you want a tool that builds Python packages, you'll want to use https://github.com/pypa/build instead. This is an underlying piece for pip, build, and other 'build frontends' use to call 'build backends' within them. Note: The pep517 project has been replaced by this project (low level) and the build project (high level).
Warnings
- breaking In version 1.0.0, the package was renamed from 'pep517' to 'pyproject_hooks'.
- deprecated In version 1.0.0, deprecated modules '.build', '.check', and '.envbuild' were removed. Use the 'build' project for higher-level functionality.
- gotcha In version 1.1.0, the 'BackendInvalid' exception was renamed to 'BackendUnavailable'.
Install
-
pip install pyproject-hooks
Imports
- BuildBackendHookCaller
from pyproject_hooks import BuildBackendHookCaller
- BackendUnavailable
from pyproject_hooks import BackendUnavailable
- HookMissing
from pyproject_hooks import HookMissing
- UnsupportedOperation
from pyproject_hooks import UnsupportedOperation
- default_subprocess_runner
from pyproject_hooks import default_subprocess_runner
- quiet_subprocess_runner
from pyproject_hooks import quiet_subprocess_runner
Quickstart
import os
from pyproject_hooks import BuildBackendHookCaller
# Set the path to your pyproject.toml file
pyproject_toml_path = os.environ.get('PYPROJECT_TOML_PATH', 'pyproject.toml')
# Initialize the BuildBackendHookCaller
hook_caller = BuildBackendHookCaller(pyproject_toml_path)
# Call the build hook
hook_caller.call_hook('build_sdist')