# Providing Artifacts basics

**URL:** <https://discourse.julialang.org/t/providing-artifacts-basics/35459>\
**Category:** General Usage\
**Created:** [March 3, 2020, 12:00pm UTC](https://discourse.julialang.org/t/providing-artifacts-basics/35459 "2020-03-03T12:00:45Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![jw3126](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jw3126/32/3086_2.png) [@jw3126](https://discourse.julialang.org/u/jw3126)\
**Post date:** [March 3, 2020, 12:00pm UTC](https://discourse.julialang.org/t/providing-artifacts-basics/35459/1 "2020-03-03T12:00:45Z")

</div>

What is the recommended way to download and extract some binaries and build a simple Julia wrapper package around it? I read the excellent [blog post](https://julialang.org/blog/2019/11/artifacts/) on the artifact system, but it is still unclear how to proceed. In particular:

- Should I touch binary builder at all? I do not really want to build something, just download and extract.
- Where should the “build script” live? Just in the main package, or should there be a jll package?

### Background

I would like to be able to load and maybe save [.dhall](https://github.com/dhall-lang/dhall-haskell) files from Julia. Implementing `.dhall` in Julia is too much work, so I would like to call [existing tools](https://github.com/dhall-lang/dhall-haskell/releases), that translate .dhall to JSON under the hood.  
So what needs to be done is to download and extract these tools.

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [March 3, 2020, 12:49pm UTC](https://discourse.julialang.org/t/providing-artifacts-basics/35459/2 "2020-03-03T12:49:19Z")

</div>

This might help:

> <https://github.com/JuliaPackaging/Yggdrasil/blob/bd8ea634546785e0cfa6139562b7ac2c06ee1095/README.md#contributing>

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [March 3, 2020, 12:51pm UTC](https://discourse.julialang.org/t/providing-artifacts-basics/35459/3 "2020-03-03T12:51:07Z")

</div>

> [@jw3126](#):
>
> I would like to be able to load and maybe save [.dhall](https://github.com/dhall-lang/dhall-haskell) files from Julia. Implementing `.dhall` in Julia is too much work, so I would like to call [existing tools](https://github.com/dhall-lang/dhall-haskell/releases), that translate .dhall to JSON under the hood.

Oh, I’ve just seen it’s Haskell. Well, we haven’t used BinaryBuilder to build Haskell stuff, the only one who tried so far has been @oxinabox, but I think he had some problems back then

---

<div class="post-metadata">

**Author:** ![oxinabox](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oxinabox/32/206603_2.png) [@oxinabox](https://discourse.julialang.org/u/oxinabox)\
**Post date:** [March 3, 2020, 1:51pm UTC](https://discourse.julialang.org/t/providing-artifacts-basics/35459/4 "2020-03-03T13:51:30Z")

</div>

> [@giordano](#):
>
> @oxinabox, but I think he had some problems back then

The problem is Stack (a Haskell build tool) won’t work with musl.  
( there is an issue on there GitHub, where they are basically like _“Yep, its true. Don’t think we will ever have time to fix that”_)

@giordano was saying there is now a way to run BinaryBuilder for at least some platforms that does not use musl so that could work.

---

<div class="post-metadata">

**Author:** ![jw3126](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jw3126/32/3086_2.png) [@jw3126](https://discourse.julialang.org/u/jw3126)\
**Post date:** [March 3, 2020, 7:14pm UTC](https://discourse.julialang.org/t/providing-artifacts-basics/35459/5 "2020-03-03T19:14:47Z")

</div>

Thanks for the reply. I think I do not want to build anything at all (Or is there a reason not to simply reuse the binaries provided by the Dhall maintainers?). I think I want something much more simple. Namely download + extract binaries. My question is what is the recommended way to organize this? Will it involve BinaryBuilder/jll/Yggdrasil or do I just add a build script to my package?

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [March 3, 2020, 7:33pm UTC](https://discourse.julialang.org/t/providing-artifacts-basics/35459/6 "2020-03-03T19:33:18Z")

</div>

> [@jw3126](#):
>
> I think I do not want to build anything at all (Or is there a reason not to simply reuse the binaries provided by the Dhall maintainers?). I think I want something much more simple. Namely download + extract binaries.

Fair enough. So maybe you’re more interested in this discussion:

> [@Creating Artifacts.toml for existing tarball](https://discourse.julialang.org/t/creating-artifacts-toml-for-existing-tarball/33365):
>
> I’m trying to figure out how to create an Artifacts.toml to download some data that my package depends on. I’m creating a setup\_artifacts.jl script to create it. Here’s what I have so far: using Pkg.Artifacts using Pkg.GitTools using Tar toml = joinpath(@\_\_DIR\_\_, "Artifacts.toml") ir\_url = "https://tidmarsh.media.mit.edu/~sfr/tidmarsh\_irs.tar.gz" ir\_hash = create\_artifact() do artifact\_dir tarball = download(ir\_url) try global tarball\_hash = bytes2hex(GitTools.blob\_hash(tarba…

Examples of packages using Artifacts outside of BinaryBuilder include:

- [`Electron`](https://github.com/davidanthoff/Electron.jl) ([`Artifacts.toml`](https://github.com/davidanthoff/Electron.jl/blob/a8af976d47ca09cfef9b04276ae8a3f5bfb82678/Artifacts.toml))
- [`ObjectDetector.jl`](https://github.com/r3tex/ObjectDetector.jl) ([`Artifacts.toml`](https://github.com/r3tex/ObjectDetector.jl/blob/023d4e93b83b18ce57a76fee7d90c5c6f3dbba39/Artifacts.toml), [`generate_artifacts.jl`](https://github.com/r3tex/ObjectDetector.jl/blob/023d4e93b83b18ce57a76fee7d90c5c6f3dbba39/dev/artifacts/generate_artifacts.jl))
- [`FIGlet.jl`](https://github.com/kdheepak/FIGlet.jl) ([`Artifacts.toml`](https://github.com/kdheepak/FIGlet.jl/blob/cad3c106ccd5c53afc7250e255825876441e5fa2/Artifacts.toml))

---

<div class="post-metadata">

**Author:** ![jw3126](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jw3126/32/3086_2.png) [@jw3126](https://discourse.julialang.org/u/jw3126)\
**Post date:** [March 3, 2020, 8:45pm UTC](https://discourse.julialang.org/t/providing-artifacts-basics/35459/7 "2020-03-03T20:45:52Z")

</div>

Thanks for the great reply. I loosly followed [GitHub - r3tex/ObjectDetector.jl: Pure Julia implementations of single-pass object detection neural networks.](https://github.com/r3tex/ObjectDetector.jl) and created [this](https://github.com/jw3126/Dhall.jl)

However it [fails](https://travis-ci.com/jw3126/Dhall.jl/builds/151617936) with e.g.

```julia
Unable to automatically install 'dhall' from '/home/travis/build/jw3126/Dhall.jl/Artifacts.toml'

```

Any ideas how to debug this? Here are the relevant files:

- [Artifacts.toml](https://github.com/jw3126/Dhall.jl/blob/master/Artifacts.toml)
- [Usage](https://github.com/jw3126/Dhall.jl/blob/master/src/Dhall.jl)
- [setup script](https://github.com/jw3126/Dhall.jl/blob/master/dev/setup_artifacts.jl)

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [March 4, 2020, 12:07am UTC](https://discourse.julialang.org/t/providing-artifacts-basics/35459/8 "2020-03-04T00:07:30Z")

</div>

> [@jw3126](#):
>
> Any ideas how to debug this?

```julia
using Pkg.Artifacts
download_artifact(Base.SHA1("f296f1c3f770aaade98d2f1dfa960c89dee06318"), "https://github.com/dhall-lang/dhall-haskell/releases/download/1.30.0/dhall-1.30.0-x86_64-linux.tar.bz2", "79b121880de426ef6a7ffd665e0754c5ad71871d"; verbose=true)

```

---

<div class="post-metadata">

**Author:** ![Alec\_Loudenback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alec_loudenback/32/278_2.png) [@Alec\_Loudenback](https://discourse.julialang.org/u/Alec_Loudenback)\
**Post date:** [March 4, 2020, 2:02am UTC](https://discourse.julialang.org/t/providing-artifacts-basics/35459/9 "2020-03-04T02:02:50Z")

</div>

Is this also the recommended way to include data with a Package? Currently, I have just included a bunch of XML files in my repo.

---

<div class="post-metadata">

**Author:** ![jw3126](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jw3126/32/3086_2.png) [@jw3126](https://discourse.julialang.org/u/jw3126)\
**Post date:** [March 4, 2020, 7:22am UTC](https://discourse.julialang.org/t/providing-artifacts-basics/35459/10 "2020-03-04T07:22:49Z")

</div>

This fails, still I don’t know why:

```julia
julia> download_artifact(Base.SHA1("f296f1c3f770aaade98d2f1dfa960c89dee06318"), "https://github.com/dhall-lang/dhall-haskell/releases/download/1.30.0/dhall-1.30.0-x86_64-linux.tar.bz2", "79b121880de426ef6a7ffd665e0754c5ad71871d"; verbose=true)
[ Info: Downloading https://github.com/dhall-lang/dhall-haskell/releases/download/1.30.0/dhall-1.30.0-x86_64-linux.tar.bz2 to /tmp/jl_XWc0do-download.bz2...
######################################################################## 100,0%##O#- #                                                                       
false

```

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [March 4, 2020, 10:30am UTC](https://discourse.julialang.org/t/providing-artifacts-basics/35459/11 "2020-03-04T10:30:12Z")

</div>

Sorry, I got the last argument wrong:

```julia
download_artifact(Base.SHA1("f296f1c3f770aaade98d2f1dfa960c89dee06318"), "https://github.com/dhall-lang/dhall-haskell/releases/download/1.30.0/dhall-1.30.0-x86_64-linux.tar.bz2", "6845421de9c3cc40f4140a1278c408df8ef49bf8086ee7f37730d2eda8ce9402"; verbose=true)

```

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [March 4, 2020, 10:31am UTC](https://discourse.julialang.org/t/providing-artifacts-basics/35459/12 "2020-03-04T10:31:35Z")

</div>

Yes, with the caveat that this only works with Julia v1.3+

---

<div class="post-metadata">

**Author:** ![jw3126](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jw3126/32/3086_2.png) [@jw3126](https://discourse.julialang.org/u/jw3126)\
**Post date:** [March 4, 2020, 11:40am UTC](https://discourse.julialang.org/t/providing-artifacts-basics/35459/13 "2020-03-04T11:40:05Z")

</div>

Thanks for all the help, it works now!
