[FR] User configurable get_requires_for_build_wheel and get_requires_for_build_sdist
See original GitHub issueWhat’s the problem this feature will solve?
https://github.com/pypa/setuptools/issues/2823 proposes to remove the legacy setup_requires
option. Currently, setup_requires
can be set statically (which has been replaced by the requires
key in pyproject.toml
), or dynamically during the running of the setup.py
file. This latter method of dynamically setting the build requirements can be replaced more cleanly by the two optional PEP 517 hooks get_requires_for_build_wheel
and get_requires_for_build_sdist
. Currently setuptools does not allow users to override and/or set the output of these hooks.
Describe the solution you’d like
I’m not proposing a specific solution (I suspect the best solution will be the one that best matches what users need, and aligns with the internal design of setuptools), but here are three possible designs:
-
Add two new arguments to
setuptools.setup
:sdist_requires
andwheel_requires
. These would be lists of requirements, similar toinstall_requirements
. This would likely be the least change to existing setup.py files, but what that implies for the internal flow of setuptools is unclear. Additionally, this does not passconfig_settings
to the user code, which could be desired by users. It would be assumed that the presence ofsdist_requires
andwheel_requires
would overridesetup_requires
whilst that option was allowed. -
Like 1, but instead of the options being lists of requirements, instead a function matching the interface of the PEP 517 hooks would be given. This does require more changes to user code, but means that the user code can handle
config_settings
. I’m not sure there’s much difference between 1 and 2 from a setuptools internal-design perspective though (as both are being handled completely within thesetup.py
module). -
Add
sdist_requires
andwheel_requires
tosetup.cfg
. The values would follow the same format asbuild-backend
from PEP 517, with the callables being pointed to matching the interface of the relevant hook. Depending on the internals of setuptools, this could allow setuptools to only run thesetup.py
file on the mandatory hooks.
Alternative Solutions
No response
Additional context
This came from https://github.com/pypa/setuptools/issues/2823, from what I can see there’s not been a discussion around this.
I’m also not aware of build backends using this in anger, last time I surveyed the ecosystem none of the backends provided a way to set this, so I wouldn’t be surprised if this causes some breakage in some frontends (even if it is part of PEP 517).
Code of Conduct
- I agree to follow the PSF Code of Conduct
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (7 by maintainers)
Top GitHub Comments
(Please don’t put
.
on the path, create a dedicated folder.)Hi @aragilar, have you considered adding a thin layer on top of
setuptools.build_meta
as defined in https://www.python.org/dev/peps/pep-0517/#in-tree-build-backends?For example, you could have a
_build_backend.py
file:and then tell the front-end to use it via
pyproject.toml