Re: Python dependencies in add-ons


example code:

addonNamePathxX = os.path.abspath(os.path.dirname(__file__)) ^ #addon folder path

import numpy

import opencv #example modules, Not available in NVDA.

del sys.path[-1]


#content code

On 08/06/2020 20:33, Sean via wrote:

Hi  Subham,

I think your work will be a revolutionary thing.
Because screen readers have been working with the same logic for 20 years.
Good luck.

There is no separate tool to manage the dependencies of NVDA addons.

In addon's 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 DLL.
In this way, we can use the functions of the DLL with Ctypes.
Ctypes is more commonly used in NVDA source.

On 08/06/2020 14:19, Shubham Jain wrote:

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++?

Shubham Jain


👨‍🦯 I’m 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++.

Join to automatically receive all group messages.