Making a Paclet with BTools


Today we’re gonna look at something I’ve been meaning to document for a long time now. Over the past two or so years I’ve developed a framework to simplify the development process. In the post, I’m gonna show you how to actually use it.

To make it easier to use all this I have a video showing how I do things:

Installing BTools

The easiest way to install BTools is to load it off the paclet server . Head over to its paclet page and copy the installation instructions there:

<< https://paclets.github.io/PacletServer/Install.wl
PublicPacletInstall["BTools"]

Making a New Package

With BTools installed you’ll then go up to the palettes menu and open up the App Manager palette that it provides. (see the video for more details)

From the palette you’ll click the New App button on the bottom. It’ll have a bunch of other buttons in it. Ignore those. They haven’t really done anything since 2017. This’ll open up a little window. Put your app name in there and click the “New App” button.

The package will appear in the drop-down menu provided. You can open it up by clicking on its name (the left side of the drop down is a button).

Adding Content

This part is pretty much just manual. Add the .m files or .wl files you want in the appropriate directories. One quirk of the BTools package loader is that it controls the context naming structure so make sure to only declare symbols before the Begin["`Private`"] and not try to give them a specific context.

The nice thing about this is that you don’t have to worry about how to load any of your subpackages. BTools will figure that out and set up auto-completions for you. I’ll go into this further later, but as an example take a look at how things are defined in my ChemTools package or in the PublicPacletServer interface package.

Building the Paclet

Go to the Dist tab on the App Manager palette and press “Bundle Paclet”. This will create a paclet and open it up for you. At that point you can do with it as you will.

If you’ve set up a paclet server the PacletServerBuilder stuff in BTools (or the Paclet Server Manager palette) you can push to that, too, with Publish. Same for pushing to GitHub if you set up a GitHub repo for the package. You can even push a new GitHub release with the Publish Release button.