Embedding python for Tunny for Mac

Hi forums and mcneel RhinoCode team,

Right now I am working on a mac version of Tunny, a multi-objective optimization tool.
It has already reached the stage where it works as follows, but there is one problem.

Tunny is running Python behind the scenes and the windows version uses Embeddable Python. However, there is no mac version.
So now it works in only my Python environment. This makes it difficult to distribute.

RhinoCode downloads Python3 and automatically embeds the Python file in /.rhinocode/py39-rh8.
Does anyone know how this is done?

By “Embeddable Python” are you compiling Python yourself in Visual Studio? Not using RhinoPython, or either Python component in Grasshopper?

The .rhinocode directory appears similar to the CPython embedded in Rhino 8. There’s probably been two years of work by the McNeel team to integrate Python 3.9. But I believe under the hood it uses PythonNet.

1 Like

Thanks @James_Parrott

I also use Pythonnet in my implementation.
Pythonnet only provides the Python manipulation part, not Python itself.

So I am looking into Python that can be distributed on mac.

Oh wow, that’s impressive, and advanced. Is there so much being sent from Tunny’s C# to Optuna, that it’s too much for native Grasshopper connections that the user should connect together to a Python component?

I’ve only called out to an external Python that the user has installed, but I haven’t tested the external application on MacOS.

Maybe @eirannejad can help here?

1 Like

@hiron You’d need to manually build Python 3 from source on macOS and configure to be built as a framework.

I wonder if you can use the same python that is shipped with Rhino >=8 in Tunny. How does Tunny use Python 3?

2 Likes

Hi @eirannejad

Tunny has confirmed that it works with Python in Rhino >= 8.

Python is connected to Grasshoper via Pythonnet, which is used to perform Galapagos-like optimizations using Python’s optimization library.

I was worried about conflicts with other packages in the existing RhinoCode, but your following article made me think that creating a site-envs folder for Tunny would not be a problem.

1 Like