Showing posts with label julia. Show all posts
Showing posts with label julia. Show all posts

Sunday, September 27, 2020

Local Julia packages

I'm working on some Julia scripts and recently needed to write some utility functions usable from multiple files. I could be very careful with includes to make sure the file is included exactly once when needed, but that seemed rickety to me. I wanted it to be like a package I could confidently bring in with a using directive. Unfortunately this doesn't seem to be common in the Julia ecosystem and only really became possible (?) recently.

I had to make a subdirectory for the utility package containing a separate project with its own metadata. So the MyModule subdirectory had a Manifest.toml, Project.toml, and src subdirectory, containing MyModule.jl. The metadata files were created by the package manager, but I had to edit Project.toml to give the package a name and uuid. Then in the package environment for the root project, I ran develop MyModule to add the utility package as a development/local dependency.