[ANN] ArtifactUtils.jl – Artifacts for the People!

Many may not know this, but the Artifacts system is actually really useful outside of BinaryBuilder.jl as well, for shipping tarballs in Julia projects in a straightforward way. The only hurdle currently, is that it’s quite awkward to create an Artifacts.toml file for use in a package or project, if you already have an existing tarball. That is why it can be quite tempting to use BinaryBuilder infrastructure for this, which is really overkill here and unnecessarily adds the hassle of having to go through Yggdrasil for any new releases.
That is why I am happy to announce ArtifactUtils.jl, which exports a function add_artifact!, that makes creating an Artifacts.toml file for providing tarballs in Julia projects a breeze. You only need a .tar.gz file, that’s hosted somewhere. (You can use GitHub releases for this, for example. Here, we use the JuliaMono font as an example, which has tarballs already hosted on GitHub.) From the README:

julia> using ArtifactUtils, Pkg.Artifacts # Pkg.Artifacts provides the artifact string macro

julia> add_artifact!(
           "Artifacts.toml",
           "JuliaMono",
           "https://github.com/cormullion/juliamono/releases/download/v0.021/JuliaMono.tar.gz",
           force=true,
       )
SHA1("888cda53d12753313f13b607a2655448bfc11be5")

julia> artifact"JuliaMono"
Downloading artifact: JuliaMono
curl: (22) The requested URL returned error: 404 Not Found
Downloading artifact: JuliaMono
######################################################################## 100.0%#=#=#
"/home/simeon/.julia/artifacts/888cda53d12753313f13b607a2655448bfc11be5"

julia> run(`ls $ans`);
JuliaMono-Black.ttf	JuliaMono-Bold.ttf	 JuliaMono-Light.ttf	JuliaMono-RegularLatin.ttf  LICENSE
JuliaMono-BoldLatin.ttf  JuliaMono-ExtraBold.ttf  JuliaMono-Medium.ttf	JuliaMono-Regular.ttf

Just add this Artifacts.toml to your Julia project and use artifact"JuliaMono" anywhere in your code, to get access to its containing files. The directory the tarball gets extracted to is supposed to be immutable, so this is not meant for modifying the downloaded files, it is possible to provide overrides for developing artifacts though.
Be sure to check out the docs as well! Currently, this package only contains a single function add_artifact!, but feel free to let me know, if there is some other Artifacts functionality, you feel is missing from the current Pkg.Artifacts API.
Pretty much all of the credit here goes to the Pkg developers though, who did amazing work in implementing the Artifacts system! This really just provides a small convenience function over that. For reference, this package evolved out of this Pkg PR.

34 Likes

Thank you! This was enough to get me over the artifact hump and allowed me to get rid of the data within my repository for my package. Feels good!

image

5 Likes