wolfmanstout / gaze-ocr

Easily apply OCR to wherever the user is looking onscreen.
Apache License 2.0
29 stars 3 forks source link

Provide better control over running optional dependencies in a Talon context #2

Closed wolfmanstout closed 2 years ago

wolfmanstout commented 2 years ago

@lunixbochs FYI

Currently, if I try to include this package (and screen-ocr) in a Talon user directory, it runs several files that I don't want, including setup.py and optional dependencies such as dragonfly.py. I can guard some of these on if __name__ == "__main__", but not the optional dependencies, which are supposed to be imported as modules. This triggers import errors due to missing dependencies.

wolfmanstout commented 2 years ago

Found a simple workaround to this: hide this package under a directory starting with ".", and then add the package path to sys.path.

lunixbochs commented 2 years ago

You're only editing sys.path when not running in Talon, right?

wolfmanstout commented 2 years ago

This is in Talon, but only in an experimental repo. It's a way that I can have a vendor directory with some pure Python packages (my own 2 gaze ocr packages as well as rapidfuzz for fuzzy string comparison, which has one dep of its own on jarowinkler), without requiring any pip installs. These are managed via git subtree. I check for dupes before adding to path and only rely on this for imports from the single talon Python script which uses these packages.

Would be happy to have a more robust solution. I can reopen if you'd like. I just want some way that people can test this functionality out as an early preview without any pip installs and without maintaining code in two places with different structures.