I’m trying to make a plugin that utilizes a CPython package, and I’m trying to find the best way to distribute the package to users of the plugin. The plugin itself won’t be available outside of my lab, and we can’t put the package up on PyPI, but we do have an internal package index. Normally, we could use something like pip install --index-url https://my.package.index/ mypackage, but this doesn’t seem to be possible within the new Script Editor in Rhino 8. Is there any way to specify a package index, or am I locked into PyPI? In a similar vein, is it possible to install local packages (downloaded as a wheel or tarball)?
After poking around a little bit, it seems that Rhino searches for any line of text that looks like # r: mypackage and then tries to install mypackage. Doing something like # r: --index-url https://my.package.index/ mypackage bricks the script because it tries to create a folder with the name --index-url https://my.package.index/ mypackage. Putting the --index-url bit in an earlier comment also doesn’t work because it once again tries to make an invalid folder. It clearly isn’t passing the string following # r: into pip install, and it isn’t treating all of the requirements comments as lines in a requirements file.
I know how to distribute the package within the yak file, but it would be nice to not have other people in the lab reinstall the plugin every time I update the package.
I’ve found a way to hack it together by first installing a package from PyPI like numpy and then manually running the pip install via a subprocess call.
Hey @eirannejad , just wondering – will it be ready soon? I’m about to put the core part of my project (Euglena) on PyPI, but it’s more than 100 MB because of the TensorFlow stuff.
Last time, I made a simple setup in Python. I’d like to upload the package to github and install it with pip. Also, it’d be nice if the script component showed when it’s downloading packages. There’s a lot of waiting when it installs something big like MediaPipe, so users may think it’s frozen.
… upload the package to github and install it with pip…
You mean using the pip install git+https://github.com/... pattern to install directly from a git repo?
The editor originaly showed a green bar notifying that it is installing packages. The problem was that the Rhino UI would remain active and use could modify things before script was run. I’ll implement something similar soon:
RH-79324 Script Editor to notify when installing packages but make it block the UI