Description
What's the problem this feature will solve?
Python native extensions cannot take advantage of optional dependencies. This is because the information required to support optional dependencies is not exposed at build time.
For a specific example, I'm investigating adding wasm support to tree-sitter. To do this, I want to add a wasm
extra to tree-sitter which enables a dependency on wasmtime. However, I also need to set a compiler flag to enable the functionality in the native extension. It's not possible to always enable the compiler flag, because then users without the extra will get link errors (this isn't quite true, see below).
Describe the solution you'd like
I'd like a mechanism to access the selected extras to be exposed to setup.py
, so that it may then alter its build process to enable or disable the extra.
Alternative Solutions
In order to work around this issue, it's necessary for my native extension to create stub methods that can dynamically load the endpoints at runtime (effectively, I have to use dlopen
instead of letting the linker do its job).
Additional context
Here's another user from 2022 who encountered the same issue.
I hope this is the right place to request this. Thanks for the consideration.
Code of Conduct
- I agree to follow the PSF Code of Conduct.