pypa/build

How to use `build` with customized setuptools commands

T4mmi opened this issue · 2 comments

Hi, this issue might be out of scope and I apologize if that's the case.
I have a setuptools extension that implements custom build commands to generate some third-party formated extensions from a python package (typically generate some tweaked metadata files and wraps everything in a zip archive).

Since python -m build is to replace python setup.py build, how to tell build to run a custom command (extend the --sdist/--wheel) ?

example:
assuming we have a setuptools_custom.build_custom(setuptools.Command) registered (running python -c "import setuptools; setuptools.setup()" build_custom is OK but triggers a deprecation warning,
Is it possible/OK to ask build to run this build_custom command ? (I'd expect something like python -m build . --build_custom or python -m build . --command=setuptools_custom.build_custom)

Build does not run setuptools commands. Build runs build_wheel (and build_sdist) from your backend hooks, as defined by PEP 517. Build commands are an internal setuptools detail (and other build backends, like scikit-build-core, meson-python, and maturin to name a few for built extensions, use different designs). Setuptools doesn't have a clear plan AFAICT for how to handle custom build commands. What I've done for the scikit-build-core setuptools plugin is inject my build command into the build command list.