setuptools-rust
setuptools-rust copied to clipboard
Ability to specify rust_extensions via setup.cfg
Currently one specifies rust_extensions in setup.py, imperatively (e.g. https://github.com/pyca/cryptography/blob/main/setup.py#L43-L56). Nowadays, setuptools lets one specify many options declaratively in setup.cfg (e.g. https://github.com/pyca/cryptography/blob/main/setup.cfg). It'd be great if rust_extensions could also be specified in setup.cfg -- though truthfully I have no idea if that is possible!
I agree that this would be great. I think that this needs support from setuptools maintainers. As far as I know, this page describes all the valid setup.cfg fields and I'm not aware of a mechanism for plugins like setuptools_rust to define additional fields.
FYI: a related upstream issue: https://github.com/pypa/setuptools/issues/1272
Although we can not extend setup.cfg, we can certainly extend pyproject.toml to add a [tool.setuptools-rust] section, for example
[[tool.setuptools-rust.rust-extensions]]
target = "example"
binding = "pyo3"
Then we can implement a PEP 517 backend in setuptools-rust to read it and generate a corresponding setup.py.
[build-system]
requires = ["setuptools", "wheel", "setuptools-rust"]
build-backend = "setuptools_rust"
At least for my use case I need the build backend to be setuptools itself, since I also have cffi extensions that need its setuptools extension.
I don't we can do configuration in pyproject.toml without overriding build-backend?
Right, but it should work after merging https://github.com/pyca/cryptography/pull/7164
Good point! Though that's still a ways off since it needs patches to rust and pypy.
Or we can add a [tool.setuptools-rust.extra-setup-args] that can add arbitrary arguments to the generated setup.py.
[tool.setuptools-rust.extra-setup-args]
cffi_modules = ["src/_cffi_src/build_openssl.py:ffi"]
I think it'd be also great if the use of the rust_extensions keyword arg did not require me to also import RustExtension()... I'm not sure how setuptools handles it nowadays, but importing a dependency in setup.py used to be a huge pain, because it might or might not be there on install.
I saw the help-wanted label in this issue and I gave it a try in #348.
Please feel free to ignore/close if that is not what the project is looking for.
I think this is resolved now. Thank you!