toggle quoted messageShow quoted text
I know that there are not some modules that Python developers use
a lot among the modules that NVDA packages. (see. library.zip)
For example, I was trying to write a code sharing addon.
I thought urllib3 was the best option for me.
But urllib3 wanted a module called hmac.
hmac is one of Python's main modules.
If I have such a problem, I copy the .py file if the module
consists of a single file from pythonPath\lib.
Example of these modules: hmac.py, tempfile.py
Then I create a folder for these modules.
Example: "hmac" folder for Hmac.
Then I change the name of the hmac.py file module to
I add the path of the modules to Python with sys.path.append.
If one of the dependencies is a module consisting of more than one
file, it is enough to copy that module folder.
Although the processes seem very long, once completed, most of the
problems are solved.
Finally, some main modules may need .pyd files. Sqlite3 is an
I have never encountered this type of error.
I do not know that NVDA can correctly detect .pyd files in this
What I wrote can be very complicated. I'm trying to enhance my
English :) .
If you still have an unresolved point in your mind, I can share a
sample zip file.
On 08/06/2020 21:41, Andy B. wrote:
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:
- Use NVDA’s version of html and
xml with parsers removed.
- Use my version of html or xml and
ignore NVDA’s version.
- Rename the original html or xml
standard Python libraries and manage 3rd party
- Give up and consider it a lost
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
addonNamePathxX = os.path.abspath(os.path.dirname(__file__)) ^
#addon folder path
import opencv #example modules, Not available in NVDA.
On 08/06/2020 20:33, Sean via groups.io
I think your work will be a revolutionary thing.
Because screen readers have been working with the same logic
for 20 years.
There is no separate tool to manage the dependencies of NVDA
In addon's __init__.py file, the path of the modules is
added with sys.path.append.
Addon writers often use this.
One thing I want to add is;
All required modules should be in the same folder.
You can write C ++ codes to Python with a tool like Cython.
Or the code section written in C ++ can be compiled as a
In this way, we can use the functions of the DLL with
Ctypes is more commonly used in NVDA source.
On 08/06/2020 14:19, Shubham Jain
As part of my GSoC project,
I am writing an add-on that allows users to get
descriptions of images. To work, the ML models depend on
some python libraries like Numpy, Pillow, onnxruntime and
OpenCv. My questions are:
- Is it possible to package these
libraries in an add-on?
- Since I only require a few specific
functions from these libraries, is it possible to only
package those parts into the add-on?
Alternatively, the models could be converted to run using
native C++ by depending on the LibTorch library. Is it
possible to write add-ons in native C++?
👨🦯 I’m student and
programmer. I write often Python, sometimes Go and
student and programmer. I write often Python, sometimes
Go and rarely C++.
👨🦯 I’m student and programmer. I write often Python,
sometimes Go and rarely C++.