This is always a problem when I distribute my packages to colleagues working on different platforms. I have my packages installed into a private directory and I autoload some of them when Mathematica starts, but since everyone has a different folder hierarchy and different customs on where to put files/what to autoload, this is always a bottleneck. Should non-power-users simply use the menu option: Install...? Can a foolproof script be defined, that - no matter what platform is in use - installs these packages in a way that both the user and both Mathematica (and the code I wrote and distributed) can find it? That is, packages are not added to the system-default package directory. Or would it be better to put packages into the default directory of Mathematica (e.g. C:\Applications\Mathematica 8.0.1\AddOns)? If yes, then which directory should hold them: LegacyPackages, ExtraPackages or Packages?
Further questions:
What if the package that I send consists of multiple packages, in a delicate directory structure? Can the menuitem Install... deal with that?
Answer
I think that the menu item File -> Install... is very convenient, even for power users. The only problem is that there is no uninstall option. However, if the package consists of a single file, upgrading is easy: the old file will be overwritten with the new file.
You can write some simple instructions for users:
- Open the .m file you sent them
- Choose
File -> Install... - Choose Type -> Package, Source -> (the open notebook), Install Name -> SomePackage
- Load the package by evaluating
<.
The only thing that can go wrong is that they mistype the install name.
The Install... menu item will put the package into
FileNameJoin[{$UserBaseDirectory, "Applications"}]
which on Windows is
%appdata%\Mathematica\Applications
(Press Win-R and type the above to get to that directory.)
When necessary, the package file can be deleted from that directory.
This is the usual way I install and upgrade palettes myself.
Putting packages into the Mathematica installation directory is not really advantageous because they will get lost when Mathematica is upgraded (for example, from 8.0.1 to 8.0.4). Instead they can be put into $BaseDirectory/Application (for all users) or $UserBaseDirectory/Application (for the current user). This is what the Install... menu item does.
It seems that the Install... menu item can deal with multi-file packages too. "Type of Item to Install" should be set to "Applications", "Source" -> "From File..." and the package files need to be inside an archive (.zip file). I have not used this personally, so I have no experience with it (e.g. about what happens on upgrade).
@AlbertRetey noted below that the Wolfram Player Pro does not have this menu item at all. The only way to install packages into it is to do it manually or create a script that does it.
Comments
Post a Comment