Wrappers to call hooks on pyproject.toml-based build backends.
Project description
pyproject-hooks
This package contains wrappers to call hooks on build backends for pyproject.toml
-based projects. It is intended to be a low-level shared implementation for tools like pip
and build
.
These wrappers provide:
- Fallback for the optional hooks.
- Build frontends can call the hooks without checking if they are defined.
- Isolation from current process, via a subprocess.
- Build frontends can control how the subprocess is run.
Usage
import os import tomli from pyproject_hooks.wrappers import PyProjectHookCaller source_path = "path/to/source" pyproject_toml_path = os.path.join(source_path, "pyproject.toml") with open(pyproject_toml_path) as f: build_system = tomli.load(f)["build-system"] # The caller is responsible for installing these and running the hooks in # an environment where they are available. print("static build-time requirements:", build_system["requires"]) hooks = PyProjectHookCaller( source_path, build_backend=build_system["build-backend"], backend_path=build_system.get("backend-path"), ) config_options = {} # Optional parameters for build backend # Again, the caller is responsible for installing these build requirements print( "dynamic build-time requirements:", hooks.get_requires_for_build_wheel(config_options), ) destination = "also/a/folder" whl_filename = hooks.build_wheel(destination, config_options) assert os.path.isfile(os.path.join(destination, whl_filename))
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyproject-hooks-0.1.0.tar.gz
(16.8 kB
view hashes)
Built Distribution
Close
Hashes for pyproject_hooks-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4361a2ade030a8ca24f2124f748563f4308733ff1046e8ff043c1057de89df87 |
|
MD5 | b77ab5a81ba92b1e18dd8236331b9dac |
|
BLAKE2-256 | 53df708d3772673c7ddfd3e4755268b4abfaf69b2749448e8bcbcee892218035 |