import_3dm icon indicating copy to clipboard operation
import_3dm copied to clipboard

Separate rhino3dm install and update

Open tsvilans opened this issue 5 years ago • 5 comments

Is your feature request related to a problem? Please describe.

  • Installing rhino3dm is currently part of the main add-on script.
  • It is also not possible currently to update rhino3dm from the add-on interface.

Describe the solution you'd like

  • Move installation (pip) functions to another file (perhaps util.py?).
  • Add a Blender operator for updating rhino3dm with latest version.

Describe alternatives you've considered Manually running python -m pip install -upgrade rhino3dm from the Blender Python executable.

tsvilans avatar Oct 28 '19 15:10 tsvilans

@jesterKing I just tagged you because you were looking into the wider rhino3dm installation stuff! If you'd like, I can also tackle this, however.

tsvilans avatar Oct 28 '19 15:10 tsvilans

@tsvilans yes thanks for logging the issue!

jesterKing avatar Nov 02 '19 22:11 jesterKing

I'm running into a bit of a problem. Since rhino3dm is a non-pure Python module, using shared library in C/C++ it is impossible to update the module in-process. Currently I get this exception


Exception:
Traceback (most recent call last):
  File "C:\Users\Nathan\AppData\Roaming\Python\Python37\site-packages\pip\_internal\basecommand.py", line 228, in main
    status = self.run(options, args)
  File "C:\Users\Nathan\AppData\Roaming\Python\Python37\site-packages\pip\_internal\commands\install.py", line 381, in run
    options.target_dir, target_temp_dir, options.upgrade
  File "C:\Users\Nathan\AppData\Roaming\Python\Python37\site-packages\pip\_internal\commands\install.py", line 432, in _handle_target_dir
    shutil.rmtree(target_item_dir)
  File "c:\users\nathan\appdata\local\programs\python\python37\lib\shutil.py", line 507, in rmtree
    return _rmtree_unsafe(path, onerror)
  File "c:\users\nathan\appdata\local\programs\python\python37\lib\shutil.py", line 391, in _rmtree_unsafe
    onerror(os.unlink, fullname, sys.exc_info())
  File "c:\users\nathan\appdata\local\programs\python\python37\lib\shutil.py", line 389, in _rmtree_unsafe
    os.unlink(fullname)
PermissionError: [WinError 5] Access is denied: 'C:\\Users\\Nathan\\AppData\\Roaming\\Blender Foundation\\Blender\\2.80\\scripts\\addons\\modules\\rhino3dm\\_rhino3dm.cp37-win_amd64.pyd'

I think I'll just make import_3dm always try to update rhino3dm when loaded.

jesterKing avatar Nov 03 '19 00:11 jesterKing

Hey @jesterKing, I've done a similar thing for the SpeckleBlender add-on for dependency installation. This seems to work:

import os, subprocess
modulespath = os.path.normpath(os.path.join(bpy.utils.script_path_user(),"addons","modules"))
res = subprocess.run([bpy.app.binary_path_python, "-m", "pip", "install", "-q", "--upgrade", "-t", "{}".format(modulespath), "rhino3dm"])

It doesn't require admin privileges - since it puts it in the user data folder - or a Blender restart, so it seems like a safer bet. I'll try to update the dependency installation code and put it in a separate script file for a bit of clean-up.

tsvilans avatar Mar 17 '20 23:03 tsvilans

Ah, and regarding your issue above, I ran into the same thing.. Only thing I could do was disable the add-on, reboot Blender, run the update code, and then all is well.

A clunky solution would be to have a sidecar rhino3dm updater add-on which just wraps that up into a button / Blender operator... I suppose that would just be the equivalent of an installer / updater script.

tsvilans avatar Mar 17 '20 23:03 tsvilans