Re: perform tasks while add-on install

Alberto Buffolino

Christopher Pross, il 18/05/2020 14.33, ha scritto:
a short question, it is possible to do some tasks while add-on installations?
Hi Christopher,
yes, there is onInstall() function, called during add-on installation. It must be contained in, that must be located in add-on root directory (where is manifest.ini, to be clear).
There is onUninstall() too.
I need to register a python package in the python enviroment from nvda for my current project. and I don't know how to do that, while the add-on installing.
hmm, what you mean exactly with "register a python package"?
Because you cannot (you should not) register a package in strict and static sense. The thing usually done is:
- include the package sources/binaries in a folder called "mypackage" (for example);
- put this folder in a folder called "lib" (for example) in add-on root directory;
- where necessary, do:
import sys
libPath = os.path.join(os.path.dirname(__file__), "..", "lib")
import mypackage
del sys.path[-1]
...your code using mypackage...
At my knowledge, this should be the better organized and most secure way.

Join to automatically receive all group messages.