How to include deps in egg builds?

Suggest, post, or discuss plugins for Deluge
Post Reply
griest
New User
New User
Posts: 1
Joined: Thu Oct 17, 2024 7:41 pm

How to include deps in egg builds?

Post by griest »

I have a plugin which relies on some 3rd party packages not available in Deluge's set of requirements. How can I build the plugin such that all extra deps are bundled? Pretty new to python btw. I get the following error:

Code: Select all

The 'fuzzysearch' distribution was not found and is required by the application
mhertz
Moderator
Moderator
Posts: 2331
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: How to include deps in egg builds?

Post by mhertz »

For eggs, like plugins, you need pure python modules unfortunately. You don't even need add them manually to sys.path I found, as is done for you if just droping the src dirs into the plugin's main dir, as is added to sys.path, e.g. I made a small plugin once like this:

Code: Select all

martin@arch ~ % la testing/webhook 
total 24K
drwx------ 3 martin users 4.0K Aug 23  2023 certifi
drwxr-xr-x 3 martin users 4.0K Oct 16  2023 deluge_webhook
drwx------ 3 martin users 4.0K Oct 10  2023 requests
drwx------ 6 martin users 4.0K Aug 23  2023 urllib3
-rwxr-xr-x 1 martin users  529 Oct 16  2023 create_dev_link.sh
-rw-r--r-- 1 martin users 1.2K Oct 16  2023 setup.py
martin@arch ~ % la testing/webhook/requests 
total 212K
drwx------ 2 martin users 4.0K Oct  8  2023 __pycache__
-rw-r--r-- 1 martin users 3.9K Oct 10  2023 __init__.py
-rw-r--r-- 1 martin users  436 Feb  9  2020 __version__.py
-rw-r--r-- 1 martin users 1.1K Feb  9  2020 _internal_utils.py
-rw-r--r-- 1 martin users  20K Feb  9  2020 adapters.py
-rw-r--r-- 1 martin users 6.4K Feb  9  2020 api.py
-rw-r--r-- 1 martin users  10K Feb  9  2020 auth.py
-rw-r--r-- 1 martin users  453 Feb  9  2020 certs.py
-rw-r--r-- 1 martin users 1.8K Feb  9  2020 compat.py
-rw-r--r-- 1 martin users  18K Feb  9  2020 cookies.py
-rw-r--r-- 1 martin users 3.2K Feb  9  2020 exceptions.py
-rw-r--r-- 1 martin users 3.5K Feb  9  2020 help.py
-rw-r--r-- 1 martin users  757 Feb  9  2020 hooks.py
-rw-r--r-- 1 martin users  35K Feb  9  2020 models.py
-rw-r--r-- 1 martin users  542 Feb  9  2020 packages.py
-rw-r--r-- 1 martin users  29K Feb  9  2020 sessions.py
-rw-r--r-- 1 martin users 4.1K Feb  9  2020 status_codes.py
-rw-r--r-- 1 martin users 3.0K Feb  9  2020 structures.py
-rw-r--r-- 1 martin users  30K Feb  9  2020 utils.py
martin@arch ~ % 
Where requests and it's two deps auto-added to sys.path, and can be used through merely importing requests in core.py or whatever.

Again, the issue is with c modules and otherwise non-pure python stuff - I found if using/distributing the egg/plugin extracted i.e. as a dir just ending it's name in *.egg, then would work, as the issue is that an egg is zipped, and the OS's api calls for loading native module code, doesn't support loading such from a zipped dir path like python generates. I once had to code generating temp folder in /tmp / %temp%, then extracting the c-module dep dir from plugin and into there, and adding said temp dir to sys.path, to use in plugin, but pretty lame honestly, and abandoned for better idea later, with other pure python dep found instead.
Post Reply