Post #868324
2026-03-30 16:25 UTC
Python packaging question:
I have a package on PyPI that depends on keras. Keras can work with either jax, torch, or tensorflow, but I want to let the user in charge of which of those they install.
So, currently, keras is in my default dependencies, and I have three optional feature sets: one with each backend, which I can install with the brackets syntax.
Which means that the "plain" installation is non-functional, because it lacks a backend library.
So, I am wondering if there would be a way to make one of the backends the default one, while still keeping the possibility to not install it (and install another one instead) in case the installation is difficult on a user's machine?
I think I am thinking of something similar to Rust's default features, which are installed by default but can be not installed if requested
#Python #PyPI
Replies (1)
-
@diazona@techhub.social 2026-03-30 17:29
@Armavica This capability ("default extras") doesn't exist yet, but I have definitely seen a proposal for it. I hope that gets accepted and implemented at some point. Until then, if you wind up explaining this in your package's installation instructions and telling people they have to manually select one of the three extras, you certainly wouldn't be alone. Of course it'd be ideal if your package (or keras) also checks at runtime and give a useful error message if it doesn't find any of the three dependencies installed. #Python #PythonPackaging