New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use plugins to define rhino installable packages #614
Conversation
ping |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool, let's just try it :)
@compas.plugins.pluggable(category='install', selector='collect_all') | ||
def installable_rhino_packages(): | ||
"""Provide a list of packages to make available inside Rhino. | ||
|
||
Extensions providing Rhino or Grasshopper features | ||
can implement this pluggable interface to automatically | ||
have their packages made available inside Rhino when | ||
COMPAS is installed into it. | ||
|
||
Examples | ||
-------- | ||
>>> import compas.plugins | ||
>>> @compas.plugins.plugin(category='install') | ||
... def installable_rhino_packages(): | ||
... return ['compas_fab'] | ||
|
||
Returns | ||
------- | ||
:obj:`list` of :obj:`str` | ||
List of package names to make available inside Rhino. | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so in some other package you would basically write a plugin for this function that adds itself to the list of installable packages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, eg. compas_fab: compas-dev/compas_fab#200
The main goal of this PR is to change the way other packages install themselves into Rhino to make it a more straightforward experience for the user.
Currently, non-core packages (eg.
compas_fab
) need to be explicitly installed using something likepython -m compas_rhino.install -p compas_fab
. This works fine for simple packages, but as soon as packages have other dependencies, the thing gets messy. In the case ofcompas_fab
, we provide a wrapped installer that takes care of both compas core and compas_fab+dependencies (python -m compas_fab.rhino.install
) but this means extra code on each package that needs this behavior, and a confusing situation with similar but not entirely identical commands to install compas stuff.So this PR leverages the new plugin system, defines a new
pluggable
extension point for packages to announce which packages they need and changes the install process to discover all existing plugins on that extension point and retrieve all the required rhino-installable packages.For this purpose, the plugin system now has two types of plugins (
first_match
(default) andcollect_all
), and as an almost side note, I create a doc page to list all available extension points, otherwise it's very hard to discover them (eventually, this page generation should be automated):There are already 3 examples of using this new end-point, two are in this PR:
compas_rhino
andcompas_ghpython
, instead of hard-coding the package names that need to go to Rhino, they define them using the same extension point. And forcompas_fab
, just opened a pr to do the same.What type of change is this?
Checklist
Put an
x
in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.CHANGELOG.md
file in theUnreleased
section under the most fitting heading (e.g.Added
,Changed
,Removed
).invoke test
).invoke lint
).compas.datastructures.Mesh
.