Re: Python dependencies in add-ons
toggle quoted messageShow quoted text
This generally works. However, it has one major problem that NVDA won’t allow add-on authors to overcome. If a dependency requires modules/libraries that NVDA removed from the standard Python library, all of the included Python libraries that attempt to import such removed libraries will fail. For example, trying to import bs4, lxml, or cssutils will terminally fail because NVDA removed html.parser and xml.parser from the standard library while maintaining the rest of the html and xml modules. Attempting to reimport the original html or xml standard Python libraries into an add-on also fails because it will cause a namespace conflict with the NVDA provided html and xml libraries. As a result, either one can exist, but not both. I attempted this and was forced to choose from a few different options:
I took the last option: give up because it is a lost cause. Using NVDA’s version of html and xml breaks the imported libraries that require html.parser or xml.parser. On the other hand, using the original Python provided versions breaks NVDA. Renaming the originals to something different seems like a ton of unwanted work because I would have to trudge through all the bs4/cssutils/lxml code and rename html.parser to something else, and after all of that, we can’t be sure it will work. If someone has a fix or workaround for this problem, I am all ears. It would bring a whole new level to my add-on.
Sent from Mail for Windows 10
Sent: Monday, June 8, 2020 1:40 PM
Subject: Re: [nvda-addons] Python dependencies in add-ons
import opencv #example modules, Not available in NVDA.
On 08/06/2020 20:33, Sean via groups.io wrote:
👨🦯 I’m student and programmer. I write often Python, sometimes Go and rarely C++.