API Documentation¶
This project exposes 2 modules:
build module¶
build - A simple, correct PEP 517 package builder
- exception build.BuildBackendException(exception, description=None, exc_info=(None, None, None))¶
Bases:
ExceptionException raised when the backend fails
- class build.ProjectBuilder(srcdir, python_executable='/usr/bin/python', scripts_dir=None, runner=<function default_subprocess_runner>)¶
Bases:
objectThe PEP 517 consumer API.
- Parameters
srcdir (
str) – The source directoryscripts_dir (
Optional[str,None]) – The location of the scripts dir (defaults to the folder where the python executable lives)python_executable (
str) – The python executable where the backend livesrunner (
Callable[[Sequence[str],Optional[str,None],Optional[Mapping[str,str],None]],None]) – An alternative runner for backend subprocesses
The ‘runner’, if provided, must accept the following arguments:
cmd: a list of strings representing the command and arguments to execute, as would be passed to e.g. ‘subprocess.check_call’.
cwd: a string representing the working directory that must be used for the subprocess. Corresponds to the provided srcdir.
extra_environ: a dict mapping environment variable names to values which must be set for the subprocess execution.
The default runner simply calls the backend hooks in a subprocess, writing backend output to stdout/stderr.
- build(distribution, output_directory, config_settings=None, metadata_directory=None)¶
Build a distribution.
- Parameters
distribution (
str) – Distribution to build (sdistorwheel)output_directory (
str) – Directory to put the built distribution inconfig_settings (
Optional[Mapping[str,Union[str,Sequence[str]]],None]) – Config settings for the build backendmetadata_directory (
Optional[str,None]) – If provided, should be the return value of a previouspreparecall on the samedistributionkind
- Return type
- Returns
The full path to the built distribution
- property build_system_requires: Set[str]¶
The dependencies defined in the
pyproject.toml’sbuild-system.requiresfield or the default build dependencies ifpyproject.tomlis missing orbuild-systemis undefined.
- check_dependencies(distribution, config_settings=None)¶
Return the dependencies which are not satisfied from the combined set of
build_system_requiresandget_requires_for_build()for a given distribution.
- get_requires_for_build(distribution, config_settings=None)¶
Return the dependencies defined by the backend in addition to
build_system_requiresfor a given distribution.
- static log(message)¶
Prints message
The default implementation uses the logging module but this function can be overwritten by users to have a different implementation.
- Parameters
msg – Message to output
- Return type
- metadata_path(output_directory)¶
Generates the metadata directory of a distribution and returns its path.
If the backend does not support the
prepare_metadata_for_build_wheelhook, a wheel will be built and the metadata extracted.
- prepare(distribution, output_directory, config_settings=None)¶
Prepare metadata for a distribution.
- Parameters
- Return type
- Returns
The full path to the prepared metadata directory
- build.check_dependency(req_string, ancestral_req_strings=(), parent_extras=frozenset({}))¶
Verify that a dependency and all of its dependencies are met.
build.env module¶
Creates and manages isolated build environments.
- class build.env.IsolatedEnv¶
Bases:
objectAbstract base of isolated build environments, as required by the build project.
- abstract install(requirements)¶
Install packages from PEP 508 requirements in the isolated build environment.