Skip to content

Adding plugin loading#287

Open
taconi wants to merge 1 commit intoQirky:masterfrom
taconi:plugins
Open

Adding plugin loading#287
taconi wants to merge 1 commit intoQirky:masterfrom
taconi:plugins

Conversation

@taconi
Copy link

@taconi taconi commented Oct 15, 2025

Plugins

Adding the loading of plugins that alter the FoxDot namespace

Example

Here is an example of how to create a plugin.

  1. Add the table [project.entry-points."FoxDot.namespace_hooks"] to your project configuration.
# ./pyproject.toml
[project]
name = "FoxDotPlugin"
version = "0.1.0"

requires-python = ">=3.11"
dependencies = []

[project.entry-points."FoxDot.namespace_hooks"]
FoxDotPlugin = "FoxDotPlugin:main"

[build-system]
requires = ["setuptools>=80.9.0"]
build-backend = "setuptools.build_meta"

FoxDotPlugin is the name of the plugin. “FoxDotPlugin:main” represents the function that will be executed (main) from the FoxDotPlugin module. The function must receive an argument that is a dictionary containing all FoxDot global variables, FoxDotCode.namespace to be more exact.

  1. Create the function that will change the namespace with your own functions, patterns, synthdefs, effects, etc., or replace existing variables (classes/functions).
# ./FoxDotPlugin.py
def custom_function():
    """Custom function."""
    print('Custom Function')


def main(namespace):
    """Change FoxDot namespace."""
    namespace['custom_function'] = custom_function

To test it, you need to install the plugin in the environment where FoxDot is located. We could do the following to install the example above:

pip install .

When starting FoxDot, the custom_function() function can be used normally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant