Skip to main content

packages - PacletInfo.m documentation project


Packages can be made into paclets, which provides easy distribution and versioning. The paclet metadata is in the PacletInfo.m file. The PacletInfo settings also determine how the paclet can extend Mathematica: e.g. provide new functions for the kernel (a usual package), new palettes or stylesheets for the Front End, etc.


What settings and extensions can be used in a PacletInfo.m file and what are their effects?



Documenting these will be very useful for people who develop and publish packages.




Related posts:




Answer



This is a community project to produce useful documentation for PacletInfo.m. Feel free to edit and improve this answer.




While the Paclet Manager is loaded from .mx files, its plain text .m sources are also available. Much of the information in this post comes from the comments in those source files. See SystemOpen@Lookup[PacletInformation["PacletManager"], "Location"], especially Extension.m and Paclet.m.


Some other information comes from PacletInfo.m files that come with Mathematica:


paclets = Import[#, "Package"] & /@ FileNames["PacletInfo.m", $InstallationDirectory, Infinity];


as well as the GitLink package.





Paclets are a format and distribution mechanism for packages or other resources that can extend Mathematica. The paclet is described by the PacletInfo.m file. This file is used by the PacletManager, which is built into the Wolfram Language.


When would a Mathematica user want to create a PacletInfo.m file?


This is generally useful when building packages or applications. Having this file allows integrating documentation into the Documentation Center, or bundling the package into a .paclet file and installing it with PacletInstall. The file is also recognized in applications installed into $UserBaseDirectory/Applications or $BaseDirectory/Applications manually (the usual way) and not using PacletInstall.


In addition to Paclets installed into a base directory, the PacletDirectoryAdd command can be used to add a directory containing paclets to the PacletManager so that it is recognized by the Mathematica FrontEnd and Needs. This allows a paclet or a library of multiple paclets to reside anywhere, such as a network drive where it can be accessed by multiple users.






A sample PacletInfo.m file from GitLink:


Paclet[
Name -> "GitLink",
Version -> "2100.0",
MathematicaVersion -> "10.1+",
Root -> ".",
Internal -> True,
Extensions ->
{
{"Kernel", Root -> ".", Context -> "GitLink`"},


{"Documentation", Language -> "English"},

{"LibraryLink"}
}
]

Note: GitLink is eventually going to become part of Mathematica. The Internal flag may be related to this and may not be appropriate for user packages.






These are some of the settings that can be given in PacletInfo files. See the default values using


Normal[PacletManager`Paclet`Private`$piDefaults]

The following should generally be present in any PacletInfo file:




  • Name, paclet name. This can be used to refer to the paclet, e.g. PacletFind["name"] or PacletUpdate["name"].




  • Version, paclet version. Must be up to five .-separated numbers. If multiple versions of a paclet are installed, it is always the latest one that will be used.



    This value is parsed as PadRight[ToExpression@StringSplit[version, "."], 5].




The following can affect whether the paclet may be loaded:




  • MathematicaVersion (deprecated) or WolframVersion (current since M10), minimum compatible Mathematica version, e.g. "10+" or "10.0.2+". The paclet will not load in incompatible versions. As of M11.0, it defaults to "10+".


    While the MathematicaVersion form is deprecated, using MathematicaVersion -> "10+" allows Mathematica 9 to correctly identify a paclet as incompatible. M9 doesn't understand WolframVersion.





  • SystemID, compatible system types. Can be a string, a list of strings, or All. See $SystemID for possible values. Defaults to All, and should be omitted unless your package is only compatible with certain operating systems.




Other settings:




  • Root, probably the paclet root relative to PacletInfo.m. Not tested yet.




  • Loading, can be Manual, Automatic, or "Startup". Defaults to Manual, i.e. the package can be loaded with Needs as usual. Automatic is allowed only when the Symbols argument of the Kernel extension is set (see below). "Startup" causes the package to load at kernel startup.



    This setting will be exposed in the Documentation Center (see below) and can be changed by the user.


    Warning: Be careful if the package does more than issue definitions upon loading. Some operations do not work during kernel initialization and may even lock up the kernel.




  • Internal, can be True/False, ???




  • Qualifier, have seen values like $SystemID, ???





Paclets that provide the Documentation extension will be listed in the Documentation Center under guide/InstalledAddOns.


enter image description here


The following metadata will be listed for each package/paclet on that page:




  • Creator, author name.




  • Description, description.





  • Publisher, publisher name.




  • Thumbnail, relative path to an image file. Will be used as the package icon. Should be 46 by 46 pixels.


    Warning: There are some problems with the thumbnail retrieval. Rescaling to 46×46 fails (small bug) and using a thumbnail causes high CPU usage in M11 while the add-ons list is open (but not in M10.x).




  • URL, package homepage.





enter image description here


Other metadata:


These can be retrieved for installed paclets using PacletInformation["name"]



  • BuildNumber, Category, Copyright, License, Support.





The Extensions setting contains a list of extensions, each in the form



{"ExtensionName", "Argument1" -> Value1, "Argument2" -> Value2, ...}

The possible extensions and their arguments are below.


Application


Seems to work in a similar way to Kernel. Not sure what the difference is. At this moment I believe that one can (perhaps should) always use Kernel instead.


Arguments:



  • Root, defaults to "." (same as Kernel extension)

  • Context



AutoCompletionData


???


Arguments:



Hints: See PacletFind["EntityFramework"]


ChannelFramework


???


Hints: See PacletFind["DemoChannels"] for the implementation of the Demo:OneLiner channel which is shown in ChannelListen -> Applications -> Chat.


Documentation


Fully documented in the Workbench Help.



Used to integrate documentation into the Documentation Center.


Will cause the application to show up in the auto-generated application list in the Documentation Center at guide/InstalledAddOns.


Arguments:



  • Language, defaults to All

  • Root, defaults to "Documentation"

  • Context, rarely needed, use same argument in Kernel extension instead

  • MainPage

  • LinkBase

  • Resources



Multiple instances of the Documentation extension can be used in the same PacletInfo file. For example, if multiple languages are supported there should be one extension for each language. For an example, see the Parallel paclet in AddOns/Applications.


The LinkBase argument is needed only in cases where documentation is stored in a different paclet from the code*. For an example, see the Parallel paclet in AddOns/Applications which links to the ParallelTools paclet.


The Resources should never need to be used by outside developers of paclets used in version 7+*.


FrontEnd


Will cause subdirectories within the FrontEnd to be handled, e.g. FrontEnd/Palettes, FrontEnd/StyleSheets, FrontEnd/SystemResources, FrontEnd/TextResources. These items will be recognized by the Front End, e.g. palettes will show up in the Palettes menu.


Arguments:




  • Root, defaults to "FrontEnd"





  • WolframVersion




  • SystemID




References:




JLink


Will cause .jar files within the root ("Java" by default) to be added to the classpath.


Arguments:




  • Root, defaults to "Java"




  • WolframVersion





  • SystemID




Kernel


Makes the package loadable by Needs.


Arguments:




  • Root, defaults to "." for compatibility but "Kernel" is also typical. FindFile resolves the specified context to this location during the first stage of its name resolution. See also https://mathematica.stackexchange.com/q/133242/12.





  • Context, package context or list of contexts. Used by FindFile. Also causes >> documentation links to be added to usage messages when documentation is present.




  • Symbols, a list of symbols that will trigger autoloading if Loading -> Automatic is set. It is required for Loading -> Automatic to be a valid setting. Similar to DeclarePackage. Symbols can be given with full context, e.g. Symbols -> {"MyPack`MyFun1", "MyPack`MyFun2"}.




  • WolframVersion





  • SystemID




  • HiddenImport




LibraryLink


Arguments:


Will cause shared libraries within LibraryResources/$SystemID to be found by FindLibrary.





  • Root, defaults to LibraryResources.




  • WolframVersion




  • SystemID





Path


???


Arguments:




  • Base




  • Root





  • WolframVersion




  • SystemID




Resource


The Resource extension can be used to create new extensions that are managed by the PacletManager and can be located using PacletResources or PacletResource. These functions cull the resources by SystemID, Wolfram Language version and Language, providing a system-independent method to manage arbitrary files that paclets depend on.



To use the resource in a package, use PacletResource to retrieve the path to the resource, then use that path in the package functions as appropriate.


An example is the MachineLearning paclet in SystemFiles\Components. It provides a number of system-specific libraries used by the component, and demonstrates how to use aliases for the resources.


MachineLearning defines a "KenLM" resource. To get the path to the system-appropriate resource, use PacletResource["MachineLearning", "KenLM"]. This returns "C:\\Program Files\\Wolfram \ Research\\Mathematica\\11.0\\SystemFiles\\Components\\MachineLearning\ \\Resources\\Binaries\\Windows-x86-64\\lmplz.exe" on a 64-bit Windows machine.


To find all paclets with a "Libraries" resource, use PacletResources["Resource", "Libraries"]. This returns two paclets and resource paths: {{Paclet["Cryptography","1.0",<>],{"C:\\Program Files\\Wolfram Research\\Mathematica\\11.0\\SystemFiles\\Components\\Cryptography\\Resources\\Libraries"}},{Paclet["MachineLearning","1.0.0",<>],{"C:\\Program Files\\Wolfram Research\\Mathematica\\11.0\\SystemFiles\\Components\\MachineLearning\\Resources\\Libraries"}}}


Arguments:




  • Root





  • Resources




  • SystemID




Root is the path to the folder the resources are stored in, relative to the paclet directory.


Resources is a list of resources. Each resource can be defined as a string for the resource path or a list {"Name", "Path"} where Name is an alias to identify the resource. The path is relative to the Root path. The resource can be a file or directory.


SystemID must be used when resources are system specific.





* From personal correspondence with Todd Gayley, WRI


Comments

Popular posts from this blog

plotting - Filling between two spheres in SphericalPlot3D

Manipulate[ SphericalPlot3D[{1, 2 - n}, {θ, 0, Pi}, {ϕ, 0, 1.5 Pi}, Mesh -> None, PlotPoints -> 15, PlotRange -> {-2.2, 2.2}], {n, 0, 1}] I cant' seem to be able to make a filling between two spheres. I've already tried the obvious Filling -> {1 -> {2}} but Mathematica doesn't seem to like that option. Is there any easy way around this or ... Answer There is no built-in filling in SphericalPlot3D . One option is to use ParametricPlot3D to draw the surfaces between the two shells: Manipulate[ Show[SphericalPlot3D[{1, 2 - n}, {θ, 0, Pi}, {ϕ, 0, 1.5 Pi}, PlotPoints -> 15, PlotRange -> {-2.2, 2.2}], ParametricPlot3D[{ r {Sin[t] Cos[1.5 Pi], Sin[t] Sin[1.5 Pi], Cos[t]}, r {Sin[t] Cos[0 Pi], Sin[t] Sin[0 Pi], Cos[t]}}, {r, 1, 2 - n}, {t, 0, Pi}, PlotStyle -> Yellow, Mesh -> {2, 15}]], {n, 0, 1}]

plotting - Plot 4D data with color as 4th dimension

I have a list of 4D data (x position, y position, amplitude, wavelength). I want to plot x, y, and amplitude on a 3D plot and have the color of the points correspond to the wavelength. I have seen many examples using functions to define color but my wavelength cannot be expressed by an analytic function. Is there a simple way to do this? Answer Here a another possible way to visualize 4D data: data = Flatten[Table[{x, y, x^2 + y^2, Sin[x - y]}, {x, -Pi, Pi,Pi/10}, {y,-Pi,Pi, Pi/10}], 1]; You can use the function Point along with VertexColors . Now the points are places using the first three elements and the color is determined by the fourth. In this case I used Hue, but you can use whatever you prefer. Graphics3D[ Point[data[[All, 1 ;; 3]], VertexColors -> Hue /@ data[[All, 4]]], Axes -> True, BoxRatios -> {1, 1, 1/GoldenRatio}]

plotting - Mathematica: 3D plot based on combined 2D graphs

I have several sigmoidal fits to 3 different datasets, with mean fit predictions plus the 95% confidence limits (not symmetrical around the mean) and the actual data. I would now like to show these different 2D plots projected in 3D as in but then using proper perspective. In the link here they give some solutions to combine the plots using isometric perspective, but I would like to use proper 3 point perspective. Any thoughts? Also any way to show the mean points per time point for each series plus or minus the standard error on the mean would be cool too, either using points+vertical bars, or using spheres plus tubes. Below are some test data and the fit function I am using. Note that I am working on a logit(proportion) scale and that the final vertical scale is Log10(percentage). (* some test data *) data = Table[Null, {i, 4}]; data[[1]] = {{1, -5.8}, {2, -5.4}, {3, -0.8}, {4, -0.2}, {5, 4.6}, {1, -6.4}, {2, -5.6}, {3, -0.7}, {4, 0.04}, {5, 1.0}, {1, -6.8}, {2, -4.7}, {3, -1.