Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to specify rust_extensions via setup.cfg #208

Closed
alex opened this issue Feb 26, 2022 · 10 comments
Closed

Ability to specify rust_extensions via setup.cfg #208

alex opened this issue Feb 26, 2022 · 10 comments

Comments

@alex
Copy link
Contributor

alex commented Feb 26, 2022

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!

@davidhewitt
Copy link
Member

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.

@messense
Copy link
Member

FYI: a related upstream issue: pypa/setuptools#1272

@messense
Copy link
Member

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"

@alex
Copy link
Contributor Author

alex commented Jul 31, 2022

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?

@messense
Copy link
Member

Right, but it should work after merging pyca/cryptography#7164

@alex
Copy link
Contributor Author

alex commented Jul 31, 2022

Good point! Though that's still a ways off since it needs patches to rust and pypy.

@messense
Copy link
Member

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"]

@nils-werner
Copy link

nils-werner commented Mar 31, 2023

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.

@abravalheri
Copy link
Contributor

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.

@alex
Copy link
Contributor Author

alex commented Aug 11, 2023

I think this is resolved now. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants