Re: perform tasks while add-on install


 

Hi,
You can't register libraries while installing or uninstalling add-ons - you
must bundle these libraries with your add-on. This is more so on systems
where Python isn't even installed.
Cheers,
Joseph

-----Original Message-----
From: nvda-addons@nvda-addons.groups.io <nvda-addons@nvda-addons.groups.io>
On Behalf Of Christopher Pross
Sent: Tuesday, May 19, 2020 9:32 AM
To: nvda-addons@nvda-addons.groups.io
Subject: Re: [nvda-addons] perform tasks while add-on install

Hey,

thank you for your answer, yeah I know that I should only import a package.
but the problem is, that I need libraries, that are compex to install and
have many depententzies. So I thought I do this over pip in nvda. I gues I
am not allowed to do that. This makes all harder but when the this is to
risky...

What do you think?

Am 18.05.2020 um 15:57 schrieb 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?
Alberto:
Hi Christopher,
yes, there is onInstall() function, called during add-on installation.
It must be contained in installTasks.py, 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.
Alberto:
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")
sys.path.append(libPath)
import mypackage
del sys.path[-1]
...your code using mypackage...
At my knowledge, this should be the better organized and most secure way.
Alberto


Join nvda-addons@nvda-addons.groups.io to automatically receive all group messages.