How to install mpmath, enum and future into Rhino IronPython package directly?

Based on what I’ve read, it’s possible to install other packages onto IronPython using pip and ipy.exe, using the Command Prompt with Administrator Access. However, these (pip and ipy.exe) appear to not be built in with the IronPython that ships with Rhino 5. My current workaround is that I install another version of IronPython 2.7.5 in C:\Program Files(x86), then do what @stevebaer does in his post here about enabling Frames (link here) and install mpmath, future and enum there using Command Prompt with admin access, pip and ipy.exe.

Then I link the paths of Rhino Python to these files, as follows (I’m referring to the lines with 'C:\Program Files (x86)\IronPython 2.7\ ):

image

I’m aware that this isn’t a very robust workaround, especially if I’d like to install my package on other computers, due to the number of steps. How would one then go about installing mpmath, enum and future directly into the IronPython shipped with Rhino without using Command Prompt, pip and ipy.exe? My goal is to build a setup module that does everything for the user without them having to go through so many steps such as using Command Prompt, etc. which would make it easier to share our package. I.e. the setup module would work like a Grasshopper component (drag and drop, then it does all the package downloading and putting them into the right locations) or like a widget (a normal installation application).

My colleague has built a setup module to help with this. I’m uploading the relevant part here, in case it helps illustrate my question better: sample_setup.txt (1.3 KB)

Any suggestions are much appreciated. Thanks!

1 Like

Hi Bianchi,

Did you have any luck with setting this up in the meantime?
I want to do something similar, so any hints in the right direction would be much appreciated!

Sven

I would recommend installing Python modules manually (see this old thread), that is download the tar.gz file (for instance mpmath-1.0.0.tar.gz from here) and unzip all those babushka layers until you get to the folder just called mpmath and move that to a directory in the Rhino.Python paths list, like so:

Edit: In this case I had to enable frames as well in the EditPythonScript editor.

3 Likes

Hi @shwdehaan, this is exactly what I did, but now I use a batch file to do the process automatically for me every time I need to do an update. You have to get the enum, mpmath packages directly (what @AndersDeleuran explained) and paste them in the relevant IronPython paths. To put simply:

You manually copy-paste the files you need (like enum, mpmath, etc.) in the following locations:

  • C:\Program Files (x86)\Rhinoceros 5\Plug-ins\IronPython\Lib\ or equivalent on your computer
  • C:\Program Files (x86)\Rhinoceros 5\Plug-ins\IronPython\Lib\site-packages or equivalent on your computer

Then afterwards you have to fix some of the settings in RhinoPython:

  • Open Rhino
  • Type in the command box: EditPythonScript
  • In the Rhino Python Editor window, go to Tools
  • Select ‘Options’
  • Select ‘Files’ (default tab)

Add in the following directory into Module Search Paths (change accordingly if your Rhinoceros 5’s IronPython is installed in a different folder):

  • C:\ Program Files (x86)\Rhinoceros 5\Plug-ins\IronPython\Lib\site-packages

In the script engine tab, check the Frames Enabled option and click ‘OK’. Then close Rhino (close it totally, not just closing the Python editor) and relaunch it again for the changes to take effect. Hope this helps.

Thank you both for your clear answers!

sys.path insert and/or sys.path append