py-sherlock / sherlock

Easy distributed locks for Python with a choice of backends.
MIT License
374 stars 35 forks source link

Use `extra_requires` for the backend clients pip #44

Closed kalyanaramansanthanam closed 1 year ago

kalyanaramansanthanam commented 4 years ago

Suggestion: Instead of requiring all 3 backend clients to be installed, please allow an option to only install the backend being used.

Relevant: https://setuptools.readthedocs.io/en/latest/setuptools.html#declaring-extras-optional-features-with-their-own-dependencies

davidandreoletti commented 2 years ago

@vaidik (ping)

Problem

45 and #44 relate to the same issue: library users may not have/need all 3 supported backend at once and related libraries installed yet the package requires them all.

As @kalyanaramansanthanam described above Python offers a solution for optional dependencies. The link above seems not to point to the relevant section anymore but here is a very short summary: https://stackoverflow.com/a/45043494

Additionally, only XXXLock classes whose dependency is available at runtime should be declared (nice to have) to avoid package import failure. This issue will become more problematic as the number of backends increases.

Workaround

macOS: brew install libmemcached Ubuntu: apt-get install libmemcached-dev

PS: This is a fantastic library!

@judahrand Are you the new maintainer now ?

judahrand commented 2 years ago

@davidandreoletti I'm certainly planning on trying to get this project modernized and merge in some fixes improvements, etc.

If you're keen to contribute this change/feature please feel feel to open a PR and I'll do my best to support!

davidandreoletti commented 2 years ago

I have limited bandwidth for OSS projects and ended up not using this package. Another time perhaps :-)

judahrand commented 1 year ago

This should now work. Just need to actually release it -- in the meantime you could install from the repo.