Grasshopper Plugin running Python

Hi all,

I’m new to python development and I’m wondering how it can be integrated into a Grasshopper plugin.
Out team develops Grasshopper plugins for in-house use. One of our developers uses python libraries to work with large data sets and AI and we would like to integrate his work into one Grasshopper plugin. We have many internal users and don’t want them to be bothered with installing Python or any other library, but rather seamlessly using the tool as any other GH plugin.
Given that, I started researching some options and some questions have arised:

  1. Is this already possible using the ScriptEditor to release a .yak package? Does it pack all required project python libraries into the .gha? I tried locally with success, but the plugin failed to load on an external machine without the python package

  2. Can this be done using our regular development workflow (using Visual Studio/C# to create the .gha)? Maybe with PyInstaller or py2exe to pack the python code into an executable that is used by the Grasshopper component?

  3. Any other suggestions? (i.e. the Grasshopper components actually calls webservice that runs the python code)

I have an ongoing project (not RH related) where I ship a standalone Python application using cxFreeze, building an executable and packaging it as an .msi. This works nicely and is much easier than dealing with tooling like the WixToolset (.msi packaging). CxFreeze does it all out of the box and requires minimal configuration.

I would rather take the other route and make a .msi installer being capable in injecting Rhino/GH specific addins in the correct folders. You describe it, that the GH component basically is only a middleware and the real logic is inside this Python application. In my opinion it is always better to have dedicated applications, shipped alone and only provide small interfacing middleware. I would not dump a whole app inside a .yak package. But this is my personal view.

There are three different types of Python component now in GH, that can be shipped as .ghuser style plug-ins.

The CPython one may even run all your dev’s dependencies.

@pegiachini

  1. Yes. See this updated post. Make sure that you specify the package requriements for scripts in the script (e.g. # requirements: numpy). Otherwise if these packages are not installed on target machines the script will fail, and the scripting infrastructure would not know what package to install.

  2. Sure. But that’s exactly what the script editor does. It also generates a Visual Studio solution of the plugins so you can fully customize it if need be. See Project Solution

  3. Nope. Write and test the scripts. Specify their requirements in-script. Pack and publish. :smiley:

1 Like