What’s the proper way to share code in my Libraries with Grasshopper components that I am turning into a plugin with the Script Editor. I thought I followed these instructions correctly but it’s not working. I have to put the # env: hardcoded path in order for the component to find my code correctly which obviously won’t work in production since these paths won’t exist on users’ machines. Why can’t I just from lazytoolkit import skeleton, mesh_from_skeleton and because I have lazytoolkit as a library in my Script Editor project, and an init.py file where all the functions are listed, it work?
What am I doing wrong?
The easiest way is to publish the libraries on PyPi (under an open source license), but that makes the code visible to everyone.
That’s not ideal. Can anyone at McNeel please chime in as to why this isn’t working?
The “_init__.py” must be empty. This file is just to mark the folder “lazytoolkit” as a package.
Then, in a python script in Commands (Script_A as in the instructions), you can do :
from lazytoolkit import overture_colors
If the package will be used in a python grasshopper component, the package’s path would be logically add to the python 3 option (I haven’t tested it yet). Tell me if it works.
That’s only a convention. And one that’s often broken.
If it lets libraries be shipped with plug-ins, it’s no hardship to stick to this convention though.
1 Like