我想编写我自己的 Python 构建后端,可用于pyproject.toml
[build-system]
requires = ["setuptools>=42", "wheel", "mybackend"]
build-backend = "mybackend.build_meta"
这与 setuptools 的作用相同,只是它在行前
# nice code!
到每个.py
文件。mybackend
必须提供哪些入口点,是否可以以某种方式从安装工具"继承"?
扩展setuptools
的一种方法是将它们包装在您自己的build_wheel
/build_sdist
中
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)
无需立即返回 setuptools 函数的输出(例如,tar 文件),而是可以处理这些文件。