mcneel / compute.rhino3d

REST geometry server based on RhinoCommon and headless Rhino
Other
296 stars 186 forks source link

Package as GHA #336

Open sbaer opened 3 years ago

sbaer commented 3 years ago

Provide a tool to take a python server and hops code to create a compiled GHA along with supporting python code. The goal would be to make easy to share yak packages with a python backend server that works on users computers who may not even have python installed.

sbaer commented 3 years ago

Todo: investigate pyinstaller to make self contained apps that yak could distribute

https://www.pyinstaller.org

zooid commented 3 years ago

Check this one out. If GHA is just a .net assembly then this might be the way to go. Supposedly, it packages the interpreter as a .net assembly and it doesn't matter if you have Python installation or not. Alas, it works just with Python 3.7.

xarthurx commented 2 years ago

Is there any update on this issue recently? It would be great if we can publish a python server as gha and then distribute libraries and customized ghpython components using the cython lib.

JoostGevaert-Arup commented 1 year ago

Hey @sbaer, Any updates on making it possible to publish CPython-based Grasshopper plugins as .gha?

The only way I found so far is the "Ladybug way", which seems a bit complicated as they:

  1. install Python 3.7 in C:\Users\Name.Surname\ladybug_tools.
  2. pip install lbt-dragonfly (GitHub): the core Python libraries (lbt-dragonfly depends on e.g. lbt-ladybug, which is a collection of all Ladybug Python packages, such as ladybug-core).
  3. pip install ladybug-rhino (GitHub, API documentation): the library needed for interaction with between the ladybug Python 3.7 installation and Rhino's IronPython 2.7.
  4. set Rhino's IronPython to look for Python installed in C:\Users\Name.Surname\ladybug_tools\python.
  5. pip install lbt-grasshopper (GitHub): this installs the src and user_objects folders from ladybug-grasshopper, honeybee-grasshopper-xxx and dragonfly-grasshopper in C:\Users\Name.Surname\AppData\Roaming\Grasshopper\UserObjects\<library>-grasshopper.
  6. pip install ladybug-grasshopper-dotnet (GitHub): this installs the the Ladybug.Grasshopper.gha Grasshopper plugin and Ladybug.Executor.exe in C:\Users\Name.Surname\AppData\Roaming\Grasshopper\Libraries\ladybug_grasshopper_dotnet.

This would require me to maintain at least 4 code repos:

  1. Python library with core functionality
  2. my-plugin-rhino, communication between my Python 3.7 installation and Rhino's IronPython 2.7, see 3. & 4.
  3. my-plugin-grasshopper: User Objects
  4. my-plugin-grasshopper-dotnet: the .gha
sbaer commented 1 year ago

This request seems a little bit different than the focus of this issue which is to allow ghhops-server instances to become self-contained. CPython support is now in Grasshopper for Rhino 8. I don't believe CPython scripts can be compiled into GHAs yet, but best to ask on https://discourse.mcneel.com/