Make requests optional
Hi,
I’m using python-consul often in a pure asyncio environment (and JFTR also added support to prometheus_async). At that I find it bothersome to get a heavy dependency like requests pulled in without needing it. And I would assume that Tornado (and future Twisted ;)) users feel the same.
I guess there’s no way to achieve that without breaking default installation but it’s really annoying and it would be great, if we could find a way.
@hynek do you have a suggestion on how this can be handled? Will leave this issue open to see what the community thinks.
For what its worth; it is extrememly likely that your environment already contains requests, for example it comes in as a base dependency for a lot of distros. At least this is the case for any distro with yum/dnf.
Since I don’t want to risk breaking my system’s Python installation (doing that by upgrading requests is a popular pitfall), my Python applications reside in separate virtual environments. Insofar the likeliness is exactly 0 :) (and I assure you that I’m not alone).
Unfortunately I have no suggestions how to achieve something akin to pip install python-consul installing requests but pip install python-consul[asyncio] not.
Maybe @dstufft can help but I suppose it can only be achieved by breaking backward-compatibility by making the requests case explicit (IOW pip install python-consul[requests]) xor making python-consul a meta package that pulls in a new package (JFTR, consul is free on PyPI – just saying :)) with the actual code (& explicit dependencies) plus requirements for the default case. I would certainly prefer the second options since I’m not a fan of python- prefixes on PyPI anyways. :)
There is currently no way to have an on-by-default but otherwise optional dependency. I'd like to add something like that, but for now the only options are meta packages or just dealing with a mandatory but not used dependency in those cases.