Is it possible to load packages (.m) directly from the network (http, https) without installing it locally?
When loading packages remotely in Mathematica (extension
.m) one can use the
Import function, which behaves just as
Get. However, one must the manually check the need for loading packages (something that is usually dome with
It is possible to use
Import also within the imported package.
In the examples below one loads package
Import["https://.../Test1.m"], which automatically loads
Test2.m and imports both
Test'Deeptest' namespaces and both funcions
Test1.m, placed somewhere on the WWW server.
Import["https://.../Test2.m"] BeginPackage["Test`"] firstF::usage = "firstF calls secondF and prepends word first" Begin["`Private`"] firstF := "first, " <> Test`DeepTest`secondF End[ ] EndPackage[ ]
Test2.m, placed somewhere on the WWW server.
BeginPackage["Test`DeepTest`"] secondF::usage = "secondF returns string second" Begin["`Private`"] secondF := "second" End[ ] EndPackage[ ]
Thanks to the image_doctor for providing the initial help.
For an enterprise deployment of a package we store our packages on a network file server and then add the following to the user's init.m file:
You can then use
Needs and package documentation shows up in the help browser.
For development we have found it to be much easier to use Wolfram Workbench (we use the Eclipse plugin) to synchronize with a Git archive (over http or other protocols) and load the package into Mathematica. It has a big advantage of automatically clearing and reloading the package after you make changes.