Re: Python dependencies in add-ons


Sean
 

This seems to be an interesting problem.

Just I think:
You might need to do something like "myhtml" in the name of the html module folder.
But this will destroy all requirements.

I think this problem is related to Python's module search tree structure.
And as far as I know, the folder you're in is the top priority search path.

On 09/06/2020 15:22, Andy B. wrote:

I did the following to see if this would work:

 

  • Copied the html library from python3/lib install path and put it in my addon install folder.
  • Added the lines below to the top of my addon __init__.py file:
  • import os
  • import sys
  • addonNamePath = os.path.abspath(os.path.dirname(__file__)) #addon folder path
  • sys.path.append(addonNamePath)
  • import html.parser
  • del sys.path[-1]

I either get module not found errors or syntax errors because relative imports aren’t allowed. Doing the same to the lxml library works as expected. However, it depends on html.parser which NVDA removed from the html library.

 

Sent from Mail for Windows 10

 

From: Shaun Everiss
Sent: Tuesday, June 9, 2020 5:53 AM
To: nvda-addons@nvda-addons.groups.io
Subject: Re: [nvda-addons] Python dependencies in add-ons

 

Well just remember guys that while this may not become that important in say another few years, nvda is used on a lot of systems.

Not everyone has the latest and greatest and not everyone can have the latest and greatest of systems depending where they are especially now.

I know quite a few with win7 and yes xp.

While nvda latest doesn't matter in this reguard, even if we take in to mind that at minimum your system will have 4gb of ram, 30mb could be a lot to someone.

And even if this is excluded, not everyone has an ssd.

And even if that is excluded also not everyone will have the best cpu.

I know at least a few using 3rd generation intel systems and older amd systems.

I myself maintain a 3700, a i530, a 7200, and a 4500 and I know that in the second hand systems part of my tech store they are still trading crappy 2nd generation systems.

Even though a laptop of reasonable design costs between 800 and 1000 bucks easily, some can't afford it and will use older tech.

They will use it till it dies.

And even if that is not a problem not everyone even in my country has fibre.

Some have wireless, lite fiber, some still use dialup.

So while thats not many 30mb may matter.

At first I was like just load it all in, but thats why the core package never has everything in it.

In fact nvda is designed for modules to be installed.

No one needs everyone of them, but everyone has a certain subset.

So for me I have enough for all the programs that use one of course, including the os, and a few extra utilities I like.

In the home network systems, I have enough for the systems to work as well as apps on those if I need but a lot less.

In the systems I administrate though which are not mine including family servers, the only modules I have are the modules I absolutely need.

Then again if you think extra stuff is needed then it is needed.

 

 

On 9/06/2020 9:30 pm, Sean wrote:

I know that the NVDA team wants to keep the size of NVDA to a minimum.
This is important for use as a portable.

I think the pure python code doesn't take up much size.
The .pyd files of this type of modules are very size large.
If there are problems with file sizes, this can be reduced with UPX.
After all, 20-30 MB of RAM is used more, but it is an efficient method.

I wish you good coding...
As the work emerges, great ideas will continue to come from here.

On 09/06/2020 11:28, Shubham Jain wrote:

Hi Sean!

This seems like a fairly simple solution! The weights of the model already take up a lot of space (~150-200 Mb) and some of these libraries are ~50 Mb in size so I might need to get rid of all the unnecessary parts of the library to reduce space. Since I only require little functionality from these libraries, it would help with that too.

Your English is great and your explanation was very clear! Many thanks.

regards,
Shubham Jain

--

Sean

👨🦯 I’m student and programmer. I write often Python, sometimes Go and rarely C++.

 

--

Sean

👨‍🦯 I’m student and programmer. I write often Python, sometimes Go and rarely C++.

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