dictation-toolbox / dragonfly

Speech recognition framework allowing powerful Python-based scripting and extension of Dragon NaturallySpeaking (DNS), Windows Speech Recognition (WSR), Kaldi and CMU Pocket Sphinx
GNU Lesser General Public License v3.0
379 stars 74 forks source link

Modularize dependencies #238

Open cjbassi opened 4 years ago

cjbassi commented 4 years ago

I'm writing a program that only needs the grammar and kaldi backend and it would be nice if I only had to pull in dependencies for those two features. Kaldi is already hidden behind a feature flag which is nice, but I still don't need rpc features, pyperclip, and pynput. I think it would be nice if the sub packages were modularized behind feature flags. Thanks!

cjbassi commented 4 years ago

Unfortunately it is not possible to specify default features in python: https://github.com/pypa/setuptools/issues/1139

So if the dependencies are modularized, it would be a breaking change and dependent projects would have to specify all of the features that they need.

drmfinlay commented 4 years ago

Yes, I'm sorry about this. I should have made the RPC dependencies, pyperclip, pynput and others optional from the start.

One way I could see around this problem is to have a separate dragonfly2 project on PyPI.org with a different name so you can still import dragonfly, e.g. dragonfly2-minimal. To avoid ImportErrors relating to missing dependencies, you should be able to remove lines from dragonfly/__init__.py to import only the parts of Dragonfly that you need.

LexiconCode commented 4 years ago

I would be in support of this as well. Ultimately would help diversify Dragonfly use case to different applications.

It would be nice not to have to split releases but it looks like we are a constrained with packaging technical limitations.

cjbassi commented 4 years ago

I'm glad that this is something that's open to being fixed. Another idea might be to split dragonfly into a bunch of sub packages and publish those separately, like dragonfly_grammar, dragonfly_kaldi, etc. Just an idea.

drmfinlay commented 4 years ago

Sorry for the late response!

It's certainly possible to split Dragonfly into a bunch of sub-packages to be published separately. Some of us are considering splitting Dragonfly's actions and related OS control code into a separate dictation-toolbox repository with similar code from Unimacro.

drmfinlay commented 4 years ago

I believe modularisation of dependencies should be done for Dragonfly version 1.0.0.