compas icon indicating copy to clipboard operation
compas copied to clipboard

More ways to advertise plugins

Open tetov opened this issue 4 years ago • 3 comments

Feature Request

As a extension/plugin dev, I want a more flexible way to advertise plugin functionality.

Details

Currently plugins are searched for in packages named compas_*. My current project's fab package is named gramaziokohler/rapid_clay_formations_fab. For a bit it was named compas_rcf but this was changed since:

  1. It's not meant for general users in the compas ecosystem.
  2. No one knows what RCF stands for.

Describe the solution you'd like Being able to advertise plugins in setup.pys entrypoints or something similar.

https://setuptools.readthedocs.io/en/latest/userguide/entry_point.html

tetov avatar Dec 11 '20 13:12 tetov

(I want to advertise a rhino_installable_package)

tetov avatar Dec 11 '20 13:12 tetov

My first implementation indeed relied on setuptools and entrypoint hooks, however, I had to revert to a naming-convention style of discovery because plugins should also be discoverable inside IronPython which totally lacks setuptools infrastructure.

I realize it's a bit inconvenient, however, notice there's a simple workaround: you don't have to rename your entire project to be compas_xyz, you can keep your name but include a top-level package called compas_rcf_plugins (or whatever fits your case), which contains the entry points to plugins for the compas framework.

gonzalocasas avatar Feb 01 '21 06:02 gonzalocasas

I implemented this for a package I wrote yesterday and it works well, in case anyone wants to see an example.

mmec_fab
├── README.md
├── setup.cfg
├── setup.py
└── src
    ├── compas_mmec_fab_plugin
    │   └── __init__.py
    └── mmec_fab
        ├── __init__.py
        ├── module1.py
        ├── module2.py
        └── rhino_install.py

src/compas_mmec_fab_plugin/__init__.py

__all_plugins__ = ["mmec_fab.rhino_install"]

src/mmec_fab/rhino_install.py

import compas.plugins


@compas.plugins.plugin(category="install")
def installable_rhino_packages():
    return ["mmec_fab", "compas_rrc"]

(I included compas_rrc here as well since it hasn't got a installable_rhino_packages() plugin.)

tetov avatar Mar 24 '21 08:03 tetov

@gonzalocasas your comment seems a informative statement that closes the issue?

jf--- avatar Apr 08 '24 18:04 jf---