ToolboxHub / ToolboxToolbox

Declarative dependency management for Matlab.
The Unlicense
27 stars 11 forks source link

Handle "mltbx" files #86

Closed gkaguirre closed 5 years ago

gkaguirre commented 6 years ago

We now have examples of packages of Matlab code distribute in mtlbx format, such as:

https://github.com/flywheel-io/core/releases/download/2.1.4/flywheel-sdk-2.1.4.mltbx

Installing this particular file via the Matlab GUI places a directory of code inside MATLAB/Add-Ons/Toolboxes/flywheel-sdk. It seems that the code can also be unpacked and installed using the command:

% tbxFile is the full path to the mltbx file
tbxFile = 'flywheel-sdk.mltbx';
tbx = matlab.addons.toolbox.installToolbox(tbxFile);

As best I can tell, there is no particular reason why the directory of code need reside within the "Add-Ons" folder; this appears to be a cosmetic choice by Mathworks. As long as the directory is on Path, it works appropriately. That said, I don't see a way to get the "installToolbox" method to take a different destination, and I haven't as of yet figured out how to manually unpack the mltbx file.

DavidBrainard commented 6 years ago

I updated ToolboxToolbox to handle .mltbx files.

Do a pull on the ToolboxToolbox and then try tbUse('fw_sdk_mltbx'). That should fetch a fresh copy from the flywheel server and put it on your path.

I added a few headstands, so that the toolbox is copied to toolboxes folder from where Matlab unpacks it. I didn't care so much about the location, but the install routine insisted on putting the toolbox at the head of the path and I wanted the code to respect where the toolbox record says it should go (by default at the end).

I infer that the mltbx is supposed to handle the platform problem for us, so that it should work on Linux too. Maybe Michael can test that.

DavidBrainard commented 6 years ago

Trying new headstands. a) Uninstall all "installed" toolboxes when we reset the path. Had hoped this would remove the java routine from the java class path, but it doesn't seem to. Can test harder. b) Do the install after we reset the path. c) Use "mltbx" in the pathPlacement field as the thing that tells us this is an mltbx file. Use some kluges to get right form of information to the right places in TbTb.

Let's test this and see if it generally works, then can worry about version collisions and java class path.

DavidBrainard commented 6 years ago

Further work on this. I think some of the problems I was seeing before were because things got messed up. Now it seems to be working well for me. New code is on mltbx branch.

To test whether the flywheelskd is installed:

a) Type javaclasspath. You should see this at the end if it is installed right. That is, the flywheel .jar file should show up on the dynamic java path.

    DYNAMIC JAVA PATH

/Users/dhb/Documents/MATLAB/Add-Ons/Toolboxes/flywheel-sdk/code/api/rest-client-2.1.4.jar

b) Type which flywheel.api.ReportsApi. You should see it pointing to an m-fiele

To test whether flywheel is uninstalled, repeat a) and b) above. For java you should not see the flywheel .jar file anywhere on the java path, and the which command should not find anything.

I find that I can install and uninstall with tbUse('flywheel-sdk') and tbUse('Psychtoolbox-3'), without any warnings.

gkaguirre commented 5 years ago

Given that 1) mltbx is still broken on the Matlab side and 2) we no longer have a pressing need to use mltbx packages, I'm going to close this.