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 path
  • PacletInstall[name] looks for and installs the paclet named name
  • PacletInstall[{name, version}] looks for and installs the paclet named name with version number version

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"
  ]
321installation-3001995490788476466

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 paclet name
  • PacletFind[{name, version}] finds the installed paclet name with version number version

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"]
321installation-7671577574912776238

We can then find information about these paclets with PacletInformation . This can be called in a few ways:

  • PacletInformation[paclet] returns information about the Paclet expression paclet
  • PacletInformation[name] returns information about the first paclet found via PacletFind[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 .