WRI Technical Support [CASE:4868964]
Preamble
So far I am using Wolfram Workbench (i.e., a plugin to the Eclipse IDE) to develop packages collecting often used Wolfram Language functionality. For some time now, the way to go about developing, testing, and deploying packages has been the Paclet system
:
Paclets are units of Wolfram functionality, packaged up in a way that allows them to be discovered, installed, updated, and integrated seamlessly into the Wolfram environment. The essential element that makes a paclet is the PacletInfo.wl file, a small, simple file of metadata that describes the paclet, its requirements, and the ways in which it extends the Wolfram environment.
Unfortunately, starting in Version 12.1
the format of PacletInfo.wl
has changed, PacletManager`
functions have been added to the System`
context and Paclet[...]
has become PacletObject[ ...]
. For more details and advice I would like to point to the new tech note in Version 13
's documentation center.
While the new format will not be compatible with earlier versions of the Wolfram Langauge, the ease of working with paclets makes "going with the flow of development" an appealing option. Alas, Wolfram Workbench and its support for Paclet Development appear rather outdated (e.g., PacletInfo.wl
is not recognized as such, the file structure within the package will not match the new default one etc.).
How to Best Use Workbench With the New PacletInfo.wl
format?
Let's start by first creating a paclet from within a notebook
Needs["PacletTools`];
$pacletDir = FileNameJoin @ { "D:", "git-local" } (* or wherever you develop... *);
(* if $pacletDir does not yet exist, it needs to be created first *)
obj = PacletObject[ <|
"Name" -> "MyFirstPaclet",
"Version" -> "0.1",
"WolframVersion" -> "12.2+", (* paclet will be invisible to earlier versions *)
"Creator" -> "My Name <me@domain>",
"Description" -> "My first package further developed in Workbench.",
"Extensions" -> {
{ "Kernel", "Root" -> "Kernel", "Context" -> { "MyFirstPaclet`" } },
{ "Documentation" }
(* maybe also { "Path" }? Note, that { "FrontEnd" } does not work in 12.3 *)
}
|> ];
CreatePaclet[ obj, $pacletDir ] (* creates files and directory structure *)
In $pacletDir
we will now find the following files and directories:
MyFirstPaclet/
Documentation/
Kernel/
MyFirstPaclet.wl
PacletInfo.wl
QUESTION 1: Upon inspection we note that
"Creator"
and"Description"
information has been dropped and is not contained inPacletInfo.wl
. How can this be avoided and are there appropriate ways to come up with aPacletInfo.wl
file from within Workbench?
We can now add a project notebook
We can open a new notebook and save it as ProjectNotebook.nb
to $pacletDir/MyFirstPaclet/
(i.e., next to where PacletInfo.wl
is located). The notebook will be used to test and show the functions contained in the package.
If we were to run a project notebook from outside Workbench, we can do so by adding the following:
PacletDirectoryLoad @ NotebookDirectory[];
PacletDataRebuild[]; (* to make sure that changes in PacletInfo.wl are recognized *)
(* the code above is made an `Initialization Cell`*)
Needs[ "MyFirstPaclet`" ]
SayHello[ "Bob" ] (* this is by default included in MyFirstPaclet.wl :) *)
(* Hello Bob! *)
When we run a project notebook directly from Workbench, as far as I can see, neither PacletDirectoryLoad[ ]
, PacletDataRebuild[ ]
nor Needs[ ]
are needed: Simply select ProjectNotebook.nb
in the Package Explorer
and then right click: Run as > 1 Wolfram
). So, when we add another function:
BeginPackage["MyFirstPaclet`"]
...
SayGoodbye
Begin["`Private`"]
...
SayGoodbye[ ___ ] := Print[ "Goodbye." ]
End[]
EndPackage[]
... and save these changes in the editor, we can immediately use the function in the running ProjectNotebook.nb
as is the usual development process in Workbench.
Question 2: How can a project notebook be employed that is automatically created by Workbench, e.g., when you select the main directory and run the project as is usually the case in Workbench?
Question 3: How to best deploy a paclet from Workbench?
Paclet system
has undergone. $\endgroup$