Skip to content
This repository has been archived by the owner on Jul 13, 2021. It is now read-only.

Commit

Permalink
Switch to using Artifacts for assets/
Browse files Browse the repository at this point in the history
Makes `AbstractPlotting` more amenable to inclusion in a relocated
system image where the original source directories may not exist
anymore.
  • Loading branch information
MichaelHatherly committed May 16, 2021
1 parent 185de01 commit 4601024
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ phases.0001_print.jpg
**/._*
Manifest.toml
!docs/Manifest.toml
/build

\.DS_Store
6 changes: 6 additions & 0 deletions Artifacts.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[assets]
git-tree-sha1 = "a74800f299f6bdade309e459b999442f303aa64d"

[[assets.download]]
sha256 = "7ccfd273ff2ac996059d9019ff317202bdc69aef394fe450be557df9aae81733"
url = "https://github.com/JuliaPlots/AbstractPlotting.jl/releases/download/assets-0.1.0/assets-0.1.0.tar.gz"
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ version = "0.18.2"

[deps]
Animations = "27a7e980-b3e6-11e9-2bcd-0b925532e340"
Artifacts = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
ColorBrewer = "a2cac450-b92f-5266-8821-25eda20663c8"
ColorSchemes = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
Expand Down
33 changes: 33 additions & 0 deletions artifacts.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Artifact generator for the assets directory.

using Pkg.Artifacts
using URIs

version = v"0.1.0"
host = "https://github.com/JuliaPlots/AbstractPlotting.jl/releases/download"

build_path = joinpath(@__DIR__, "build")

ispath(build_path) && rm(build_path, force=true, recursive=true)
mkpath(build_path)

product_hash = create_artifact() do artifact_dir
cp(joinpath(@__DIR__, "assets"), artifact_dir; force = true)
end

archive_filename = "assets-$version.tar.gz"
artifact_toml = joinpath(@__DIR__, "Artifacts.toml")
download_hash = archive_artifact(product_hash, joinpath(build_path, archive_filename))

bind_artifact!(
artifact_toml,
"assets",
product_hash,
force = true,
download_info = Tuple[
(
"$host/assets-$(escapeuri(string(version)))/$archive_filename",
download_hash,
),
],
)
3 changes: 2 additions & 1 deletion src/AbstractPlotting.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module AbstractPlotting

using Artifacts
using Random
using FFMPEG # get FFMPEG on any system!
using Observables, GeometryBasics, IntervalSets, PlotUtils
Expand Down Expand Up @@ -242,7 +243,7 @@ export cgrad, available_gradients, showgradients

export Pattern

assetpath(files...) = normpath(joinpath(@__DIR__, "..", "assets", files...))
assetpath(files...) = normpath(joinpath(artifact"assets", files...))

export assetpath
# default icon for Makie
Expand Down
2 changes: 1 addition & 1 deletion src/conversions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ function convert_attribute(x::Union{Symbol, String}, k::key"font")
end
end

fontpath = joinpath(@__DIR__, "..", "assets", "fonts")
fontpath = assetpath("fonts")
font = FreeTypeAbstraction.findfont(str; additional_fonts=fontpath)
if font === nothing
@warn("Could not find font $str, using Dejavu Sans")
Expand Down

0 comments on commit 4601024

Please sign in to comment.