19866, "bmcdonald3", "[design] Proposal for Mason light", "2022-05-23T23:03:55Z"
Summary
Over the lifetime of mason, the only way to use a package in the mason registry required you to convert your entire project to be a full mason package itself and then use the mason build
, mason test
, etc. commands to build your project. While in the long term we would like to have all Chapel programs built in this way, that is not the world we live in today and not everything is currently possible with the mason build
command, for example, that can be done with a Makefile
.
As a first step to getting to that point of a more feature-rich mason build and getting some mason use in the wild by allowing some form of Mason Makefile integration, I am proposing what I am calling "Mason light" that allows dependencies to be used with just a toml
file. This allows the strength of the build reproducibility that mason/cargo offer without restricting how the program is built.
Mason light explained
Mason light projects can be created with the command mason new --light
. This creates a toml
file in the current directory that is designated as a light
package through a new type
field in the toml
file. Creating a mason light project will not require any changes to the project, it only adds an ability to version-control your dependencies and easily integrate them into your build process, whatever that looks like.
Adding dependencies to a mason light project is done in the exact same way that you would add dependencies to a mason package: through the mason add dep@ver
command.
Once all desired dependencies are added, running the mason build --light
command will generate the lock file, install the dependencies (if they aren't already there), and then output the necessary build flags to add to the chpl
command.
The commands that don't make sense for a mason light project (test, examples, etc.) are disabled with this initial implementation, until we come up with a story/use case for wanting those commands with a mason light project.
Design motivation
Rust's Cargo has two distinct type of crates, a library and a package. Libraries do not generate an executable, but just serve as a library that projects can call into, while packages will compile down to an executable and be ran as a regular program. This light form of mason can be thought of as a new type of Mason package in the same way that a Cargo library differs from a Cargo package.
So, today we just have mason packages, but after this proposal we will have mason packages and then mason light-packages; two distinct usages of mason.
Example
Given the program:
module MyProgram {
use DataStructures;
proc main() {
writeln("hello world");
}
}
- In the same directory, run
mason new --light
- Add the
DataStructures
dependency to the toml file throughmason add DataStructures@0.1.0
- Compile
MyProgram.chpl
like so:chpl MyProgram.chpl $(mason build --light)
Usage in Arkouda
Given the complexity of Arkouda's build process today, mason build
cannot support all that we want to do to build Arkouda, install external dependencies, etc., so this allows a way to get mason packages while keeping the existing Makefile logic.
The transition to mason packages in Arkouda (as far as usage goes) will be a simple change.
- Port Arkouda modules to mason packages
- In Arkouda's top-level directory run
mason new --light
to create the toml file - Add all the old modules with
mason add module@ver
- Add a
MASON_INCLUDES
to the Makefile that evaluates the resultmason build --light
- Add
MASON_INCLUDES
to the main Arkouda build command
Follow these steps and, presto, Arkouda is now using mason and we've got a mason user.