'Custom build backend for Python
I would like to write my own Python build backend that can used in pyproject.toml like
[build-system]
requires = ["setuptools>=42", "wheel", "mybackend"]
build-backend = "mybackend.build_meta"
and that does the same thing as setuptools, except that it preprends the line
# nice code!
to each .py file. What entry points would mybackend have to provide, and is it possible to somehow "inherit" from setuptools?
Solution 1:[1]
One way to extend setuptools is to use wrap those in your own build_wheel/build_sdist like
from setuptools.build_meta import build_sdist as setuptools_build_sdist
from setuptools.build_meta import build_wheel as setuptools_build_wheel
def build_wheel(wheel_directory, config_settings=None, metadata_directory=None):
return setuptools_build_wheel(
wheel_directory,
config_settings=config_settings,
metadata_directory=metadata_directory,
)
def build_sdist(sdist_directory, config_settings=None):
return setuptools_build_sdist(sdist_directory, config_settings)
Instead of immediately returning the output of the setuptools functions (e.g., the tar-file), one can work on those files.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Nico Schlömer |
