Relative Addons System
This is a special system that allows you to manage your addons in runtime.
The library has caching that allows it to work faster
Definitions
Addon - directory that contains addon.json and __init__.py
addon.json is a json file that describes addon and must contain name, author,
description and version(strings)
Usage examples
from pathlib import Path
from RelativeAddonsSystem import RelativeAddonsSystem, Addon, AddonMeta
# Init addons system
system = RelativeAddonsSystem(Path(__file__).parent / "addons", auto_install_requirements=True)
# return list of Addon objects
addons: list[Addon] = system.get_all_addons()
if len(addons) < 1:
print("No addons found")
else:
for addon in addons:
# loaded meta(AddonMeta) from ADDON_DIR/addon.json
meta: AddonMeta = addon.meta
print("Working with", meta.name, "at", addon.path.absolute())
# Check dependencies
if not addon.check_requirements(alert=False):
print("Installing addon dependencies")
# Install dependencies
installed: list[str] = addon.install_requirements()
print("Successfully installed addon dependencies (", ", ".join(installed), ")")
else:
print("Addon dependencies already satisfied")
# Get addon module
module = addon.module # ADDON_DIR / __init__.py module
...
In this example, we have listed all addons and installed their dependencies if they were not already installed.
We can also disable or enable addons:
from pathlib import Path
from RelativeAddonsSystem import RelativeAddonsSystem, Addon
# Init addons system
system = RelativeAddonsSystem(Path(__file__).parent / "addons", auto_install_requirements=True)
addons: list[Addon] = system.get_enabled_addons() # get all enabled addons
if len(addons) > 0:
addon: Addon = addons[0] # first addon from list
addon.disable() # disable addon
...
addon.enable() # enable addon
Or import and re-import the module (useful when we have updated your addon):
from pathlib import Path
from RelativeAddonsSystem import RelativeAddonsSystem, Addon
# Init addons system
system = RelativeAddonsSystem(Path(__file__).parent / "addons", auto_install_requirements=True)
addons: list[Addon] = system.get_enabled_addons() # get all enabled addons
if len(addons) > 0:
addon: Addon = addons[0] # first addon from list
module = addon.module
... # Work with module
# Reimport module
module = addon.reload_module()
... # Work with module
We can also change the metadata in your code:
from pathlib import Path
from RelativeAddonsSystem import RelativeAddonsSystem, Addon, AddonMeta
# Init addons system
system = RelativeAddonsSystem(Path(__file__).parent / "addons", auto_install_requirements=True)
addons: list[Addon] = system.get_enabled_addons() # get all enabled addons
if len(addons) > 0:
addon: Addon = addons[0] # first addon from list
meta: AddonMeta = addon.meta
meta.set("version", "1.2")
meta.save()
Or set specific data into the addon's storage:
from pathlib import Path
from RelativeAddonsSystem import RelativeAddonsSystem, Addon
from RelativeAddonsSystem.utils import Storage
# Init addons system
system = RelativeAddonsSystem(Path(__file__).parent / "addons", auto_install_requirements=True)
addons: list[Addon] = system.get_enabled_addons() # get all enabled addons
if len(addons) > 0:
addon: Addon = addons[0] # first addon from list
# Loaded the ADDON_DIR/ADDON_NAME-storage.json file
storage: Storage = addon.get_storage()
storage.set("api_version", "1.2")
storage.save()
Metadata
Release files for relative-addons-system 2.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| relative-addons-system-2.6.0.tar.gz | 11.9 kB | Without provenance | Details for relative-addons-system-2.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| relative_addons_system-2.6.0-py3-none-any.whl | Python 3 | none | any | Details for relative_addons_system-2.6.0-py3-none-any.whl |
Total release size: 25.1 kB
Release files / relative-addons-system-2.6.0.tar.gz
| Download URL | relative-addons-system-2.6.0.tar.gz |
|---|---|
| Size | 11.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
193ee25403d7a0de3050b7784d7f848271952d4c5e135655821fcfa6d5b953dc
|
|
BLAKE2b-256 checksum How to use checksums |
eb24fcbfe6220cf749bf0166b31a66a5a6cb0c031c77e1309cccff9816ea3c31
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.3
|
Release files / relative_addons_system-2.6.0-py3-none-any.whl
| Download URL | relative_addons_system-2.6.0-py3-none-any.whl |
|---|---|
| Size | 13.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c20c2615bf43e731d2f1ed016c19aa6e74d1453bdebd6f18af6a952cd6b2d936
|
|
BLAKE2b-256 checksum How to use checksums |
b1a8f25eae6a877e2833f68873e4b39d11e41fe32a05d2e2800955aaa7957fe2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.3
|
Security for relative-addons-system 2.6.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.