Package Usage and Development » Paclet Usage
Paclets
As we discussed previously, paclets provide a way to distribute code, resources, and other things in Mathematica. They are the native format for this type of distribution and are tightly bound into the system.
Paclets can provide any or all of the following:
- Code
- Resources
- Style Sheets
- Palettes
- Documentation
In general the most common thing we'll want to provide is code, but the others are common things to distribute as well.
We'll talk briefly about how to install and work with these paclets. Everything in this section requires the "PacletManager`"
context, so, if you have to, run:
Needs["PacletManager`"]
Installation
As the paclet system is tightly bound into Mathematica, installation is very easy via the PacletInstall
function.
We can use it in a few ways:
PacletInstall[fileOrURL]
— installs a .paclet file at the given pathPacletInstall[name]
— looks for and installs the paclet namedname
PacletInstall[{name, version}]
— looks for and installs the paclet namedname
with version numberversion
We can also pass a few options to PacletInstall
. The main ones are:
"Site"
— provides a server to look for the paclet on"IgnoreVersion"
— installs the paclet even if a different version has already been installed
If we pass a "Site"
it should be the path to a "paclet server", which we'll talk about more later.
Here's an example of this:
PacletInstall["ChemTools",
"Site"->"http://raw.githubusercontent.com/paclets/PacletServer/master"
]
Once we do this we can load the package with:
<<ChemTools`
Finding Paclets / Paclet Information
We can use the PacletFind
and PacletInformation
functions to find the installed paclet and get information about a paclet. We can call PacletFind
in a few ways:
PacletFind[name]
— finds the installed pacletname
PacletFind[{name, version}]
— finds the installed pacletname
with version numberversion
PacletFind
can take a number of filters as Options
:
"Location"
— where to search for the paclets"Qualifier"
— search for paclets with a given qualifier"SystemID"
— search for paclets stated to work on a given system"WolframVersion"
— search for paclets targeted for a given Mathematica version or verions"Enabled"
— search for paclets that are enabled"Loading"
— search for paclets with a given loading mode"Creator"
— search for paclets created by a specific person/persons"Publisher"
— search for paclets published by a given entity"Internal"
— search for internal paclets"IncludeDocPaclets"
— allow paclets that only server system-level documentation to be included"Context"
— search for paclets that serve a given context"Extension"
— search for paclets that serve a given extension
Here's a way to use this. We'll make use of the fact that PacletFind
will expand the "*"
wildcard to find every paclet ending in "Link"
which also provide the "LibraryLink"
extension and which work in Mathematica 11.0.1 or before:
PacletFind["*Link", "Extension"->"LibraryLink", "WolframVersion"->"11.0.1"]
We can then find information about these paclets with PacletInformation
. This can be called in a few ways:
PacletInformation[paclet]
— returns information about thePaclet
expressionpaclet
PacletInformation[name]
— returns information about the first paclet found viaPacletFind[name]
PacletInformation["DAALLink"]
{
"Name"->"DAALLink",
"Version"->"1.0",
"BuildNumber"->"",
"Qualifier"->"",
"WolframVersion"->"11.0+",
"SystemID"->All,
"Description"->"Link to the Intel DAAL Library",
"Category"->"",
"Creator"->"Sebastian Bodenstein <sebastianb@wolfram.com>",
"Publisher"->"",
"Support"->"",
"Internal"->False,
"Location"->"/Applications/Mathematica.app/Contents/SystemFiles/Links/DAALLink",
"Context"->{"DAALLink`"},
"Enabled"->True,
"Loading"->Automatic
}
Removal
If we have a paclet installed, but want to remove it, we can do so with PacletUninstall
. This can be called either on a Paclet
or with a name that works for PacletFind
.