pymodbus-dev/pymodbus

`client.async` sneaking in dependencies

patrickfuller opened this issue · 5 comments

In importing client.async.asyncio, client.async.__init__ triggers from pymodbus.client.async.deprecated.async (source), which then imports twisted. Twisted is a fairly heavy dependency and is not needed to use asyncio.

@patrickfuller please give a try with branch https://github.com/riptideio/pymodbus/tree/sneaky-twisted and let me know if that solves this issue. Thanks.

This fix works for me. Thanks!

Thanks for the confirmation. I will merge the PR in to dev.

I work in an environment where we use a Python interpreter for various processes. Although twisted is present, the process that uses pymodbus relies exclusively on asyncio, so the solution from #339 is not suitable for our case.

A note for others digging around this area - I monkey-patched is_installed with a function that always returns False, to ensure that an attempt to load twisted will not occur:

def my_is_installed(_): return False
pymodbus.compat.is_installed = my_is_installed

If there's a possibility use virtualenvs to avoid these kinds of problems and workaround