From f00f8dee8e91d6438a7a7c570e22ea4db21f5d6d Mon Sep 17 00:00:00 2001 From: Mark Kittisopikul Date: Tue, 1 Nov 2022 11:49:42 -0400 Subject: [PATCH 01/26] Add old builder script at a GRPrefrences submodule --- src/build.jl | 279 +++++++++++++++++++++++++++++++++++++++++++++ src/preferences.jl | 23 +++- 2 files changed, 301 insertions(+), 1 deletion(-) create mode 100644 src/build.jl diff --git a/src/build.jl b/src/build.jl new file mode 100644 index 00000000..1c9c724e --- /dev/null +++ b/src/build.jl @@ -0,0 +1,279 @@ +""" + GR.Preferences.Builder is a Module that contains the GR bulid script. + + The main purpose is to select a binary provider and store that choice in + (Local)Preferences.jl. + + When included from Main, the Builder module will invoke Builder.build(). + Otherwise, Builder.__init__() will do nothing. + + GR.Builder.build() can be invoked manually. +""" +module Builder + +using Pkg +using UUIDs +using Preferences + +const GR_UUID = UUID("28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71") + +function get_grdir() + if "GRDIR" in keys(ENV) + grdir = ENV["GRDIR"] + have_dir = length(grdir) > 0 + if have_dir + have_dir = isdir(joinpath(grdir, "fonts")) + end + else + have_dir = false + for d in (homedir(), "/opt", "/usr/local", "/usr") + grdir = joinpath(d, "gr") + if isdir(joinpath(grdir, "fonts")) + have_dir = true + break + end + end + end + if have_dir + @info("Found existing GR run-time in $grdir") + end + have_dir ? grdir : nothing +end + +function get_version() + version = v"0.69.1" + try + @static if VERSION >= v"1.4.0-DEV.265" + v = string(Pkg.dependencies()[Base.UUID("28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71")].version) + else + v = Pkg.API.installed()["GR"] + end + catch + end + if "GRDIR" in keys(ENV) + if length(ENV["GRDIR"]) == 0 + version = "latest" + end + end + version +end + +function get_os_release(key) + value = try + String(read(pipeline(`cat /etc/os-release`, `grep ^$key=`, `cut -d= -f2`)))[1:end-1] + catch + "" + end + replace(value, "\"" => "") +end + +function try_download(url, file) + try + download(url, file) + true + catch + false + end +end + +# use_system_binary and use_jll_binary are from ../src/preferences.jl +# Consider refactoring so we can just load ../src/preferences.jl by using a UUID explicitly there +use_system_binary(grdir; export_prefs = false, force = false) = set_preferences!( + GR_UUID, + "binary" => "system", + "grdir" => grdir, + export_prefs = export_prefs, + force = force +) + +use_jll_binary(; export_prefs = false, force = false) = set_preferences!( + GR_UUID, + "binary" => "GR_jll", + "grdir" => nothing, + export_prefs = export_prefs, + force = force +) + + +function __init__() + # Only build on module load if being included into Main + parent = parentmodule(@__MODULE__) + @debug "Build.__init__" parent + if parent == Main + build() + end +end + +""" + build() + + Run the bulid process for GR. Can be invoked as GR.Builder.build() + or via Pkg.build("GR) + + To set a provider set ENV["JULIA_GR_PROVIDER"] to either + 1. "GR" + 2. "BinaryBuilder" + + or `delete!(ENV, "JULIA_GR_PROVIDER")` to select default. + + Also delete or set `ENV["GRDIR"] = ""` +""" +function build(provider::String = "GR") + +current_dir = pwd() +cd(joinpath(@__DIR__, "..", "deps")) + +try + +grdir = get_grdir() + +#= +if haskey(ENV, "JULIA_GR_PROVIDER") + provider = ENV["JULIA_GR_PROVIDER"] +elseif grdir === nothing + provider = "BinaryBuilder" +else + provider = "GR" +end +=# + +if provider == "BinaryBuilder" + # Set GR_jll preference + @info "GR provider is BinaryBuilder" provider + use_jll_binary(; force = true) + return +elseif provider == "GR" + # Set system preference + @info "GR provider is GR" provider +else + @error("""Unrecognized JULIA_GR_PROVIDER \"$provider\". + To fix this, set ENV[\"JULIA_GR_PROVIDER\"] to \"BinaryBuilder\" or \"GR\" + and rerun Pkg.build(\"GR\").""") + error("Unrecognized JULIA_GR_PROVIDER \"$provider\"") + return +end + +if Sys.KERNEL == :NT + os = :Windows +else + os = Sys.KERNEL +end + +if grdir === nothing + arch = Sys.ARCH + if os == :Linux && arch == :x86_64 + if isfile("/etc/redhat-release") + rel = String(read(pipeline(`cat /etc/redhat-release`, `sed s/.\*release\ //`, `sed s/\ .\*//`)))[1:end-1] + if rel > "7.0" + os = "Redhat" + end + elseif isfile("/etc/os-release") + id = get_os_release("ID") + id_like = get_os_release("ID_LIKE") + if id == "ubuntu" || id == "pop" || id_like == "ubuntu" + os = "Ubuntu" + elseif id == "debian" || id_like == "debian" + os = "Debian" + elseif id == "arch" || id_like == "arch" || id_like == "archlinux" + os = "ArchLinux" + elseif id == "opensuse-tumbleweed" + os = "CentOS" + end + end + elseif os == :Linux && arch in [:i386, :i686] + arch = :i386 + elseif os == :Linux && arch == :arm + id = get_os_release("ID") + if id == "raspbian" + os = "Debian" + end + arch = "armhf" + elseif os == :Linux && arch == :aarch64 + id = get_os_release("ID") + id_like = get_os_release("ID_LIKE") + if id == "debian" || id_like == "debian" || id == "archarm" || id_like == "arch" + os = "Debian" + end + end + version = get_version() + tarball = "gr-$version-$os-$arch.tar.gz" + rm("downloads", force=true, recursive=true) + @info("Downloading pre-compiled GR $version $os binary", pwd()) + mkpath("downloads") + file = "downloads/$tarball" + if version != "latest" + ok = try_download("https://github.com/sciapp/gr/releases/download/v$version/$tarball", file) + else + ok = false + end + if !ok + if !try_download("https://gr-framework.org/downloads/$tarball", file) + @info("Using insecure connection") + if !try_download("http://gr-framework.org/downloads/$tarball", file) + @info("Cannot download GR run-time") + end + end + end + if os == :Windows + home = Sys.BINDIR + if VERSION > v"1.3.0-" + home = joinpath(Sys.BINDIR, "..", "libexec") + end + success(`$home/7z x downloads/$tarball -y`) + rm("downloads/$tarball") + tarball = tarball[1:end-3] + success(`$home/7z x $tarball -y -ttar`) + rm(tarball) + else + run(`tar xzf downloads/$tarball`) + rm("downloads/$tarball") + end + if os == :Darwin + app = joinpath("gr", "Applications", "GKSTerm.app") + run(`/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -f $app`) + try + @static if VERSION >= v"1.4.0-DEV.265" + have_qml = haskey(Pkg.dependencies(),Base.UUID("2db162a6-7e43-52c3-8d84-290c1c42d82a")) + else + have_qml = haskey(Pkg.API.installed(), "QML") + end + if have_qml + @eval import QML + qt = QML.qt_prefix_path() + path = joinpath(qt, "Frameworks") + if isdir(path) + qt5plugin = joinpath(pwd(), "gr", "lib", "qt5plugin.so") + run(`install_name_tool -add_rpath $path $qt5plugin`) + @info("Using Qt " * splitdir(qt)[end] * " at " * qt) + end + end + catch + end + end +end + +if os == :Linux || os == :FreeBSD + global grdir + try + if grdir === nothing + grdir = joinpath(pwd(), "gr") + end + gksqt = joinpath(grdir, "bin", "gksqt") + res = read(`ldd $gksqt`, String) + if occursin("not found", res) + @warn("Missing dependencies for GKS QtTerm. Did you install the Qt5 run-time?") + @warn("Please refer to https://gr-framework.org/julia.html for further information.") + end + catch + end +end + +catch err + rethrow(err) +finally + cd(current_dir) +end # try + +end # __build__() + +end # module Builder diff --git a/src/preferences.jl b/src/preferences.jl index 38d8ed17..aae51166 100644 --- a/src/preferences.jl +++ b/src/preferences.jl @@ -5,6 +5,7 @@ module GRPreferences catch err @debug "import GR_jll failed" err end + include("build.jl") const grdir = Ref{Union{Nothing,String}}() const gksqt = Ref{Union{Nothing,String}}() @@ -14,13 +15,17 @@ module GRPreferences const libGKS = Ref{Union{Nothing,String}}() const libpath = Ref{Union{Nothing,String}}() - lib_path(grdir, lib) = + lib_path(grdir::AbstractString, lib::AbstractString) = if Sys.iswindows() joinpath(grdir, "bin", lib) else joinpath(grdir, "lib", lib) end + # Default grdir to deps/gr if nothing + lib_path(grdir::Nothing, lib::AbstractString) = + lib_path(joinpath(@__DIR__, "..", "deps", "gr")) + gksqt_path(grdir) = if Sys.iswindows() joinpath(grdir, "bin", "gksqt.exe") @@ -30,6 +35,10 @@ module GRPreferences joinpath(grdir, "bin", "gksqt") end + # Default grdir to deps/gr if nothing + gksqt_path(grdir::Nothing) = + gksqt_path(joinpath(@__DIR__, "..", "deps", "gr")) + function __init__() binary = @load_preference("binary", haskey(ENV, "GRDIR") ? "system" : "GR_jll") if binary == "GR_jll" @@ -68,4 +77,16 @@ module GRPreferences export_prefs = export_prefs, force = force ) + + function use_deps_binary(; export_prefs = false, force = false) + ENV["JULIA_GR_PROVIDER"] = "GR" + Builder.build() + set_preferences!( + GRPreferences, + "binary" => "system", + "grdir" => abspath(joinpath(@__DIR__, "..", "deps", "gr")), + export_prefs = export_prefs, + force = force + ) + end end From 09117200ae02b64b2c076d8b8162efd97d78b077 Mon Sep 17 00:00:00 2001 From: Mark Kittisopikul Date: Tue, 1 Nov 2022 11:56:42 -0400 Subject: [PATCH 02/26] Make sure deps directory is created --- src/build.jl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/build.jl b/src/build.jl index 1c9c724e..3a44b626 100644 --- a/src/build.jl +++ b/src/build.jl @@ -121,7 +121,9 @@ end function build(provider::String = "GR") current_dir = pwd() -cd(joinpath(@__DIR__, "..", "deps")) +deps_dir = joinpath(@__DIR__, "..", "deps", "gr") +mkpath(deps_dir) +cd(deps_dir) try From 351aa87553cc6173cb0e0b2c0d183e810ea197b9 Mon Sep 17 00:00:00 2001 From: Mark Kittisopikul Date: Tue, 1 Nov 2022 12:13:31 -0400 Subject: [PATCH 03/26] Cleanup some old code --- src/build.jl | 6 ++---- src/preferences.jl | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/build.jl b/src/build.jl index 3a44b626..3e0eed33 100644 --- a/src/build.jl +++ b/src/build.jl @@ -1,5 +1,5 @@ """ - GR.Preferences.Builder is a Module that contains the GR bulid script. + GR.GRPreferences.Builder is a Module that contains the GR build script. The main purpose is to select a binary provider and store that choice in (Local)Preferences.jl. @@ -110,11 +110,9 @@ end Run the bulid process for GR. Can be invoked as GR.Builder.build() or via Pkg.build("GR) - To set a provider set ENV["JULIA_GR_PROVIDER"] to either + Set provider to either 1. "GR" 2. "BinaryBuilder" - - or `delete!(ENV, "JULIA_GR_PROVIDER")` to select default. Also delete or set `ENV["GRDIR"] = ""` """ diff --git a/src/preferences.jl b/src/preferences.jl index aae51166..3d0e8513 100644 --- a/src/preferences.jl +++ b/src/preferences.jl @@ -79,8 +79,7 @@ module GRPreferences ) function use_deps_binary(; export_prefs = false, force = false) - ENV["JULIA_GR_PROVIDER"] = "GR" - Builder.build() + Builder.build("GR") set_preferences!( GRPreferences, "binary" => "system", From 2f41c771f5a173837cb2c56e6ceb1a0809616cce Mon Sep 17 00:00:00 2001 From: Mark Kittisopikul Date: Tue, 1 Nov 2022 17:45:53 -0400 Subject: [PATCH 04/26] Refactor build.jl into downloader.jl --- Project.toml | 4 +- src/build.jl | 279 ----------------------------------- src/downloader.jl | 356 +++++++++++++++++++++++++++++++++++++++++++++ src/preferences.jl | 10 +- 4 files changed, 364 insertions(+), 285 deletions(-) delete mode 100644 src/build.jl create mode 100644 src/downloader.jl diff --git a/Project.toml b/Project.toml index a0d865f1..b1092cf2 100644 --- a/Project.toml +++ b/Project.toml @@ -17,11 +17,13 @@ Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b" Sockets = "6462fe0b-24de-5631-8697-dd941f90decc" +Tar = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" +p7zip_jll = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" [compat] -Preferences = "1" HTTP = "0.8, 0.9, 1" JSON = "0.20, 0.21, 1" +Preferences = "1" julia = "1.6" diff --git a/src/build.jl b/src/build.jl deleted file mode 100644 index 3e0eed33..00000000 --- a/src/build.jl +++ /dev/null @@ -1,279 +0,0 @@ -""" - GR.GRPreferences.Builder is a Module that contains the GR build script. - - The main purpose is to select a binary provider and store that choice in - (Local)Preferences.jl. - - When included from Main, the Builder module will invoke Builder.build(). - Otherwise, Builder.__init__() will do nothing. - - GR.Builder.build() can be invoked manually. -""" -module Builder - -using Pkg -using UUIDs -using Preferences - -const GR_UUID = UUID("28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71") - -function get_grdir() - if "GRDIR" in keys(ENV) - grdir = ENV["GRDIR"] - have_dir = length(grdir) > 0 - if have_dir - have_dir = isdir(joinpath(grdir, "fonts")) - end - else - have_dir = false - for d in (homedir(), "/opt", "/usr/local", "/usr") - grdir = joinpath(d, "gr") - if isdir(joinpath(grdir, "fonts")) - have_dir = true - break - end - end - end - if have_dir - @info("Found existing GR run-time in $grdir") - end - have_dir ? grdir : nothing -end - -function get_version() - version = v"0.69.1" - try - @static if VERSION >= v"1.4.0-DEV.265" - v = string(Pkg.dependencies()[Base.UUID("28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71")].version) - else - v = Pkg.API.installed()["GR"] - end - catch - end - if "GRDIR" in keys(ENV) - if length(ENV["GRDIR"]) == 0 - version = "latest" - end - end - version -end - -function get_os_release(key) - value = try - String(read(pipeline(`cat /etc/os-release`, `grep ^$key=`, `cut -d= -f2`)))[1:end-1] - catch - "" - end - replace(value, "\"" => "") -end - -function try_download(url, file) - try - download(url, file) - true - catch - false - end -end - -# use_system_binary and use_jll_binary are from ../src/preferences.jl -# Consider refactoring so we can just load ../src/preferences.jl by using a UUID explicitly there -use_system_binary(grdir; export_prefs = false, force = false) = set_preferences!( - GR_UUID, - "binary" => "system", - "grdir" => grdir, - export_prefs = export_prefs, - force = force -) - -use_jll_binary(; export_prefs = false, force = false) = set_preferences!( - GR_UUID, - "binary" => "GR_jll", - "grdir" => nothing, - export_prefs = export_prefs, - force = force -) - - -function __init__() - # Only build on module load if being included into Main - parent = parentmodule(@__MODULE__) - @debug "Build.__init__" parent - if parent == Main - build() - end -end - -""" - build() - - Run the bulid process for GR. Can be invoked as GR.Builder.build() - or via Pkg.build("GR) - - Set provider to either - 1. "GR" - 2. "BinaryBuilder" - - Also delete or set `ENV["GRDIR"] = ""` -""" -function build(provider::String = "GR") - -current_dir = pwd() -deps_dir = joinpath(@__DIR__, "..", "deps", "gr") -mkpath(deps_dir) -cd(deps_dir) - -try - -grdir = get_grdir() - -#= -if haskey(ENV, "JULIA_GR_PROVIDER") - provider = ENV["JULIA_GR_PROVIDER"] -elseif grdir === nothing - provider = "BinaryBuilder" -else - provider = "GR" -end -=# - -if provider == "BinaryBuilder" - # Set GR_jll preference - @info "GR provider is BinaryBuilder" provider - use_jll_binary(; force = true) - return -elseif provider == "GR" - # Set system preference - @info "GR provider is GR" provider -else - @error("""Unrecognized JULIA_GR_PROVIDER \"$provider\". - To fix this, set ENV[\"JULIA_GR_PROVIDER\"] to \"BinaryBuilder\" or \"GR\" - and rerun Pkg.build(\"GR\").""") - error("Unrecognized JULIA_GR_PROVIDER \"$provider\"") - return -end - -if Sys.KERNEL == :NT - os = :Windows -else - os = Sys.KERNEL -end - -if grdir === nothing - arch = Sys.ARCH - if os == :Linux && arch == :x86_64 - if isfile("/etc/redhat-release") - rel = String(read(pipeline(`cat /etc/redhat-release`, `sed s/.\*release\ //`, `sed s/\ .\*//`)))[1:end-1] - if rel > "7.0" - os = "Redhat" - end - elseif isfile("/etc/os-release") - id = get_os_release("ID") - id_like = get_os_release("ID_LIKE") - if id == "ubuntu" || id == "pop" || id_like == "ubuntu" - os = "Ubuntu" - elseif id == "debian" || id_like == "debian" - os = "Debian" - elseif id == "arch" || id_like == "arch" || id_like == "archlinux" - os = "ArchLinux" - elseif id == "opensuse-tumbleweed" - os = "CentOS" - end - end - elseif os == :Linux && arch in [:i386, :i686] - arch = :i386 - elseif os == :Linux && arch == :arm - id = get_os_release("ID") - if id == "raspbian" - os = "Debian" - end - arch = "armhf" - elseif os == :Linux && arch == :aarch64 - id = get_os_release("ID") - id_like = get_os_release("ID_LIKE") - if id == "debian" || id_like == "debian" || id == "archarm" || id_like == "arch" - os = "Debian" - end - end - version = get_version() - tarball = "gr-$version-$os-$arch.tar.gz" - rm("downloads", force=true, recursive=true) - @info("Downloading pre-compiled GR $version $os binary", pwd()) - mkpath("downloads") - file = "downloads/$tarball" - if version != "latest" - ok = try_download("https://github.com/sciapp/gr/releases/download/v$version/$tarball", file) - else - ok = false - end - if !ok - if !try_download("https://gr-framework.org/downloads/$tarball", file) - @info("Using insecure connection") - if !try_download("http://gr-framework.org/downloads/$tarball", file) - @info("Cannot download GR run-time") - end - end - end - if os == :Windows - home = Sys.BINDIR - if VERSION > v"1.3.0-" - home = joinpath(Sys.BINDIR, "..", "libexec") - end - success(`$home/7z x downloads/$tarball -y`) - rm("downloads/$tarball") - tarball = tarball[1:end-3] - success(`$home/7z x $tarball -y -ttar`) - rm(tarball) - else - run(`tar xzf downloads/$tarball`) - rm("downloads/$tarball") - end - if os == :Darwin - app = joinpath("gr", "Applications", "GKSTerm.app") - run(`/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -f $app`) - try - @static if VERSION >= v"1.4.0-DEV.265" - have_qml = haskey(Pkg.dependencies(),Base.UUID("2db162a6-7e43-52c3-8d84-290c1c42d82a")) - else - have_qml = haskey(Pkg.API.installed(), "QML") - end - if have_qml - @eval import QML - qt = QML.qt_prefix_path() - path = joinpath(qt, "Frameworks") - if isdir(path) - qt5plugin = joinpath(pwd(), "gr", "lib", "qt5plugin.so") - run(`install_name_tool -add_rpath $path $qt5plugin`) - @info("Using Qt " * splitdir(qt)[end] * " at " * qt) - end - end - catch - end - end -end - -if os == :Linux || os == :FreeBSD - global grdir - try - if grdir === nothing - grdir = joinpath(pwd(), "gr") - end - gksqt = joinpath(grdir, "bin", "gksqt") - res = read(`ldd $gksqt`, String) - if occursin("not found", res) - @warn("Missing dependencies for GKS QtTerm. Did you install the Qt5 run-time?") - @warn("Please refer to https://gr-framework.org/julia.html for further information.") - end - catch - end -end - -catch err - rethrow(err) -finally - cd(current_dir) -end # try - -end # __build__() - -end # module Builder diff --git a/src/downloader.jl b/src/downloader.jl new file mode 100644 index 00000000..99eb04ea --- /dev/null +++ b/src/downloader.jl @@ -0,0 +1,356 @@ +""" + GR.GRPreferences.Downloader is a Module that contains the GR download script. + +GR.GRPreferences.Downloader.download() can be invoked manually. +""" +module Downloader + +using Pkg +using UUIDs +using Tar +using p7zip_jll + +const version = v"0.69.1" +const GR_UUID = UUID("28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71") + + +""" + get_grdir() + +Try to locate an existing GR install. The search will look +in the following places: +1. ENV["GRDIR"] +2. ~/gr +3. /opt/gr +4. /usr/local/gr +5. /usr/gr + +It will confirm the install by checking for the existence of a fonts +subdirectory. + +The function will return a `String` representing one of the paths above +or `nothing` if a GR install is not located in any of those locations. +""" +function get_grdir() + if "GRDIR" in keys(ENV) + grdir = ENV["GRDIR"] + have_dir = length(grdir) > 0 + if have_dir + have_dir = isdir(joinpath(grdir, "fonts")) + end + else + have_dir = false + for d in (homedir(), "/opt", "/usr/local", "/usr") + grdir = joinpath(d, "gr") + if isdir(joinpath(grdir, "fonts")) + have_dir = true + break + end + end + end + if have_dir + @info("Found existing GR run-time in $grdir") + end + return have_dir ? grdir : nothing +end + +""" + get_version() + +Get the version of GR.jl package. + +If ENV["GRDIR"] exists and non-empty, this will return "latest" +""" +function get_version() + _version = version + if "GRDIR" in keys(ENV) + if isempty(ENV["GRDIR"]) + _version = "latest" + end + end + return _version +end + +""" + get_os_release(key) + +Grep for key in /etc/os-release +""" +function get_os_release(key) + value = "" + try + #String(read(pipeline(`cat /etc/os-release`, `grep ^$key=`, `cut -d= -f2`)))[1:end-1] + for line in readlines("/etc/os-release") + if startswith(line, "$key=") + value = split(line, "=")[2] + end + end + catch + end + return replace(value, "\"" => "") +end + +""" + get_os_and_arch() + +Figure out which specific operating system this, including the specific Linux distribution. +""" +function get_os_and_arch() + if Sys.iswindows() + os = "Windows" + else + os = string(Sys.KERNEL) + end + + arch = Sys.ARCH + + if Sys.islinux() && Sys.ARCH == :x86_64 + if isfile("/etc/redhat-release") + # example = "Red Hat Enterprise Linux Server release 6.5 (Santiago)" + #= + rel = String( + read( + pipeline( + `cat /etc/redhat-release`, + `sed s/.\*release\ //`, + `sed s/\ .\*//`, + ), + ), + )[1:end-1] + =# + rel = read("/etc/redhat-release", String) + rel = replace(rel, r".*release " => "", r" .*" => "") + rel = strip(rel) + if rel > "7.0" + os = "Redhat" + end + elseif isfile("/etc/os-release") + #= + example = """ + PRETTY_NAME="Ubuntu 22.04.1 LTS" + NAME="Ubuntu" + VERSION_ID="22.04" + VERSION="22.04.1 LTS (Jammy Jellyfish)" + VERSION_CODENAME=jammy + ID=ubuntu + ID_LIKE=debian + HOME_URL="https://www.ubuntu.com/" + SUPPORT_URL="https://help.ubuntu.com/" + BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" + PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" + UBUNTU_CODENAME=jammy + """ + =# + id = get_os_release("ID") + id_like = get_os_release("ID_LIKE") + if id == "ubuntu" || id == "pop" || id_like == "ubuntu" + os = "Ubuntu" + elseif id == "debian" || id_like == "debian" + os = "Debian" + elseif id == "arch" || id_like == "arch" || id_like == "archlinux" + os = "ArchLinux" + elseif id == "opensuse-tumbleweed" + os = "CentOS" + end + end + elseif Sys.islinux() && Sys.ARCH in [:i386, :i686] + arch = :i386 + elseif Sys.islinux() && Sys.ARCH == :arm + id = get_os_release("ID") + if id == "raspbian" + os = "Debian" + end + arch = "armhf" + elseif Sys.islinux() && Sys.ARCH == :aarch64 + id = get_os_release("ID") + id_like = get_os_release("ID_LIKE") + if id == "debian" || + id_like == "debian" || + id == "archarm" || + id_like == "arch" + os = "Debian" + end + end + + return os, arch +end + +""" + try_download(url, file) + +Try to download url to file. Return `true` if successful, or `false` otherwise. +""" +function try_download(url, file) + try + Base.download(url, file) + true + catch err + rethrow() + false + end +end + +""" + check_dependencies(grdir::String) + +Check dependencies using ldd on Linux and FreeBSD +""" +function check_dependencies(grdir::String) + try + gksqt = joinpath(grdir, "bin", "gksqt") + res = read(`ldd $gksqt`, String) + if occursin("not found", res) + @warn( + "Missing dependencies for GKS QtTerm. Did you install the Qt5 run-time?" + ) + @warn( + "Please refer to https://gr-framework.org/julia.html for further information." + ) + end + catch + # Fail silently + end +end + +""" + apple_install(grdir::String) + +Register launch services and install rpath for qt5plugin.so +""" +function apple_install(grdir::String) + app = joinpath(grdir, "Applications", "GKSTerm.app") + run( + `/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -f $app`, + ) + try + @static if VERSION >= v"1.4.0-DEV.265" + have_qml = haskey( + Pkg.dependencies(), + UUID("2db162a6-7e43-52c3-8d84-290c1c42d82a"), + ) + else + have_qml = haskey(Pkg.API.installed(), "QML") + end + # Set rpath of gr/lib/qt5plugin.so to that of QML + if have_qml + @eval import QML + qt = QML.qt_prefix_path() + path = joinpath(qt, "Frameworks") + if isdir(path) + qt5plugin = joinpath(grdir, "lib", "qt5plugin.so") + run(`install_name_tool -add_rpath $path $qt5plugin`) + @info("Using Qt " * splitdir(qt)[end] * " at " * qt) + end + end + catch + # Fail silently + end +end + + +""" + get_default_install_dir() + +Return the default install directory where we have write permissions. +Currently, this is the deps directory of the GR package: +`joinpath(pathof(GR), "..", "deps")` +""" +function get_default_install_dir() + return joinpath(@__DIR__, "..", "deps") +end + +""" + download_tarball(version, os, arch, downloads_dir = mktempdir()) + +Download tarball to downloads_dir. +""" +function download_tarball(version, os, arch, downloads_dir = mktempdir()) + tarball = "gr-$version-$os-$arch.tar.gz" + file = joinpath(downloads_dir, tarball) + + @info("Downloading pre-compiled GR $version $os binary", file) + # Download versioned tarballs from Github + if version != "latest" + ok = try_download( + "https://github.com/sciapp/gr/releases/download/v$version/$tarball", + file, + ) + else + ok = false + end + + # Download latest tarball from gr-framework.org + if !ok + if !try_download("https://gr-framework.org/downloads/$tarball", file) + @warn("Using insecure connection") + if !try_download("http://gr-framework.org/downloads/$tarball", file) + error("Cannot download GR run-time") + end + end + end + + return file +end + +""" + download(install_dir) + +Download tarball from https://github.com/sciapp/gr/releases and extract the +tarball into install_dir. +""" +function download(install_dir = get_default_install_dir()) + + # Save the current directory so we can change back to it later + current_dir = pwd() + + # Configure directories + destination_dir = joinpath(install_dir, "gr") + + # Ensure the working directory exists + mkpath(install_dir) + + # Check for an existing installation + grdir = get_grdir() + + # We did not find an existing installation + if isnothing(grdir) + + # Identify the following so we can download a proper tarball + # 1. version (version of the GR package) + version = get_version() + # 2. os (operating system) + # 3. arch (processor architecture) + os, arch = get_os_and_arch() + + # Download the tarball + mktempdir() do downloads_dir + file = download_tarball(version, os, arch, downloads_dir) + + # Extract the tarball + rm(destination_dir; force=true, recursive=true) + mktempdir() do extract_dir + Tar.extract(`$(p7zip_jll.p7zip()) x $file -so`, extract_dir) + mv(joinpath(extract_dir, "gr"), destination_dir) + end + rm(file) + end + + # Address Mac specific framework and rpath issues + if Sys.isapple() + apple_install(destination_dir) + end + + grdir = destination_dir + end # if isnothing(grdir) + + # Check dependencies when using Linux or FreeBSD + if Sys.islinux() || Sys.isfreebsd() + check_dependencies(grdir) + end + + @info "grdir" grdir + return grdir + +end # download() + +end # module Builder diff --git a/src/preferences.jl b/src/preferences.jl index 3d0e8513..78239828 100644 --- a/src/preferences.jl +++ b/src/preferences.jl @@ -5,7 +5,7 @@ module GRPreferences catch err @debug "import GR_jll failed" err end - include("build.jl") + include("downloader.jl") const grdir = Ref{Union{Nothing,String}}() const gksqt = Ref{Union{Nothing,String}}() @@ -24,7 +24,7 @@ module GRPreferences # Default grdir to deps/gr if nothing lib_path(grdir::Nothing, lib::AbstractString) = - lib_path(joinpath(@__DIR__, "..", "deps", "gr")) + lib_path(joinpath(@__DIR__, "..", "deps", "gr"), lib) gksqt_path(grdir) = if Sys.iswindows() @@ -78,12 +78,12 @@ module GRPreferences force = force ) - function use_deps_binary(; export_prefs = false, force = false) - Builder.build("GR") + function use_upstream_binary(; export_prefs = false, force = false) + grdir = Downloader.download() set_preferences!( GRPreferences, "binary" => "system", - "grdir" => abspath(joinpath(@__DIR__, "..", "deps", "gr")), + "grdir" => grdir, export_prefs = export_prefs, force = force ) From 5322ba6faf7b7413ffccaca89f29479700e29cbb Mon Sep 17 00:00:00 2001 From: Mark Kittisopikul Date: Tue, 1 Nov 2022 19:44:29 -0400 Subject: [PATCH 05/26] Implement JLL overrides --- Project.toml | 2 + src/downloader.jl | 2 +- src/preferences.jl | 168 ++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 153 insertions(+), 19 deletions(-) diff --git a/Project.toml b/Project.toml index b1092cf2..fe72b3d3 100644 --- a/Project.toml +++ b/Project.toml @@ -4,6 +4,7 @@ author = ["Josef Heinen (@jheinen)"] version = "0.69.5" [deps] +Artifacts = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab" GR_jll = "d2c73de3-f751-5644-a686-071e5b155ba9" @@ -17,6 +18,7 @@ Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b" Sockets = "6462fe0b-24de-5631-8697-dd941f90decc" +TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76" Tar = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" diff --git a/src/downloader.jl b/src/downloader.jl index 99eb04ea..e7547ac3 100644 --- a/src/downloader.jl +++ b/src/downloader.jl @@ -256,7 +256,7 @@ Currently, this is the deps directory of the GR package: `joinpath(pathof(GR), "..", "deps")` """ function get_default_install_dir() - return joinpath(@__DIR__, "..", "deps") + return abspath(joinpath(@__DIR__, "..", "deps")) end """ diff --git a/src/preferences.jl b/src/preferences.jl index 78239828..12e42b2c 100644 --- a/src/preferences.jl +++ b/src/preferences.jl @@ -1,5 +1,7 @@ module GRPreferences using Preferences + using Artifacts + using TOML try import GR_jll catch err @@ -62,24 +64,18 @@ module GRPreferences end end - use_system_binary(grdir; export_prefs = false, force = false) = set_preferences!( - GRPreferences, - "binary" => "system", - "grdir" => grdir, - export_prefs = export_prefs, - force = force - ) - - use_jll_binary(; export_prefs = false, force = false) = set_preferences!( - GRPreferences, - "binary" => "GR_jll", - "grdir" => nothing, - export_prefs = export_prefs, - force = force - ) - - function use_upstream_binary(; export_prefs = false, force = false) - grdir = Downloader.download() + """ + use_system_binary(grdir; export_prefs = false, force = false, override = :depot) + + Use the system binaries located at `grdir`. + See `Preferences.set_preferences!` for the `export_prefs` and `force` keywords. + + The override keyword can be either: + * :depot, Override GR_jll using the depot Overrides.toml + * :project, Override GR_jll using the project Preferences.toml + * (:depot, :project), Overide GR_jll in both the depot and the project + """ + function use_system_binary(grdir; export_prefs = false, force = false, override = :depot) set_preferences!( GRPreferences, "binary" => "system", @@ -87,5 +83,141 @@ module GRPreferences export_prefs = export_prefs, force = force ) + if override isa Symbol + override = (override,) + end + if :depot in override + override_depot(grdir) + end + if :project in override + override_project(grdir; force) + end + @info "Please restart Julia to change the GR binary configuration." + end + + + """ + use_jll_binary(; export_prefs = false, force = false) + + Use GR_jll in the its standard configuration from BinaryBuilder.org. + + See `Preferences.set_preferences!` for the `export_prefs` and `force` keywords. + """ + function use_jll_binary(; export_prefs = false, force = false) + set_preferences!( + GRPreferences, + "binary" => "GR_jll", + "grdir" => nothing, + export_prefs = export_prefs, + force = force + ) + unoverride_depot() + unoverride_project(; force) + @info "Please restart Julia to change the GR binary configuration." + end + + + """ + use_upstream_binary([install_dir]; export_prefs = false, force = false, override = :depot) + + Download the binaries from https://github.com/sciapp/gr/ and configure GR to use those. + + A directory "gr" will be placed within `install_dir` containing the upstream binaries. + By default install_dir will be `joinpath(pathof(GR), "deps")`. + + See `use_system_binary` for details. + """ + function use_upstream_binary(args...; export_prefs = false, force = false, override = :depot) + grdir = Downloader.download(args...) + use_system_binary(grdir; export_prefs, force, override) + end + + """ + get_override_toml_path() + + Get the path the depot's Overrides.toml + """ + function get_override_toml_path() + override_toml_path = joinpath(Artifacts.artifacts_dirs()[1], "Overrides.toml") + end + + """ + override_depot([grdir]) + + Override GR_jll in the DEPOT_PATH[1]/artifacts/Overrides.toml with `grdir`. + """ + function override_depot(grdir = grdir[]) + override_toml_path = get_override_toml_path() + override_dict = if isfile(override_toml_path) + TOML.parsefile(override_toml_path) + else + Dict{String,Any}() + end + override_dict["d2c73de3-f751-5644-a686-071e5b155ba9"] = Dict("GR" => grdir) + open(override_toml_path, "w") do io + TOML.print(io, override_dict) + end + end + + """ + unoverride_depot() + + Remove the override for GR_jll in DEPOT_PATH[1]/artifats/Overrides.toml + """ + function unoverride_depot() + override_toml_path = get_override_toml_path() + override_dict = if isfile(override_toml_path) + TOML.parsefile(override_toml_path) + else + Dict{String,Any}() + end + delete!(override_dict, "d2c73de3-f751-5644-a686-071e5b155ba9") + open(override_toml_path, "w") do io + TOML.print(io, override_dict) + end + end + + """ + override_project([grdir]) + + Override individual GR_jll artifacts in the (Local)Preferences.toml of the project. + """ + function override_project(grdir = grdir[]; force = false) + mod = if isdefined(@__MODULE__, :GR_jll) + GR_jll + else + Base.UUID("d2c73de3-f751-5644-a686-071e5b155ba9") + end + set_preferences!( + GR_jll, + "libGR_path" => lib_path(grdir, "libGR"), + "libGR3_path" => lib_path(grdir, "libGR3"), + "libGRM_path" => lib_path(grdir, "libGRM"), + "libGKS_path" => lib_path(grdir, "libGKS"), + "gksqt_path" => gksqt_path(grdir); + force + ) + end + + """ + unoverride_project() + + Remove overrides for GR_jll artifacts in the (Local)Preferences.toml of the project. + """ + function unoverride_project(; force = false) + mod = if isdefined(@__MODULE__, :GR_jll) + GR_jll + else + Base.UUID("d2c73de3-f751-5644-a686-071e5b155ba9") + end + delete_preferences!( + GR_jll, + "libGR_path", + "libGR3_path", + "libGRM_path", + "libGKS_path", + "gksqt_path"; + force + ) end end From 941b490d191f870c14431b203540486bef227208 Mon Sep 17 00:00:00 2001 From: Mark Kittisopikul Date: Wed, 2 Nov 2022 12:51:17 -0400 Subject: [PATCH 06/26] Add a friendly suggestion to use `force = true` --- src/preferences.jl | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/src/preferences.jl b/src/preferences.jl index 12e42b2c..0a9cba89 100644 --- a/src/preferences.jl +++ b/src/preferences.jl @@ -76,13 +76,19 @@ module GRPreferences * (:depot, :project), Overide GR_jll in both the depot and the project """ function use_system_binary(grdir; export_prefs = false, force = false, override = :depot) - set_preferences!( - GRPreferences, - "binary" => "system", - "grdir" => grdir, - export_prefs = export_prefs, - force = force - ) + try + set_preferences!( + GRPreferences, + "binary" => "system", + "grdir" => grdir, + export_prefs = export_prefs, + force = force + ) + catch err + if err isa ArgumentError + throw(ArgumentError("Could not set GR system binary preference. Consider using the `force = true` keyword argument.")) + end + end if override isa Symbol override = (override,) end @@ -104,13 +110,19 @@ module GRPreferences See `Preferences.set_preferences!` for the `export_prefs` and `force` keywords. """ function use_jll_binary(; export_prefs = false, force = false) - set_preferences!( - GRPreferences, - "binary" => "GR_jll", - "grdir" => nothing, - export_prefs = export_prefs, - force = force - ) + try + set_preferences!( + GRPreferences, + "binary" => "GR_jll", + "grdir" => nothing, + export_prefs = export_prefs, + force = force + ) + catch err + if err isa ArgumentError + throw(ArgumentError("Could not set GR jll binary preference. Consider using the `force = true` keyword argument.")) + end + end unoverride_depot() unoverride_project(; force) @info "Please restart Julia to change the GR binary configuration." From 3151f4f1085f4139d01eb56af7baaa71bfd10328 Mon Sep 17 00:00:00 2001 From: Mark Kittisopikul Date: Wed, 2 Nov 2022 12:59:32 -0400 Subject: [PATCH 07/26] Use GR_jll's UUID rather than the GR_jll symbol in case GR_jll fails to load --- src/preferences.jl | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/preferences.jl b/src/preferences.jl index 0a9cba89..95c9315e 100644 --- a/src/preferences.jl +++ b/src/preferences.jl @@ -195,13 +195,8 @@ module GRPreferences Override individual GR_jll artifacts in the (Local)Preferences.toml of the project. """ function override_project(grdir = grdir[]; force = false) - mod = if isdefined(@__MODULE__, :GR_jll) - GR_jll - else - Base.UUID("d2c73de3-f751-5644-a686-071e5b155ba9") - end set_preferences!( - GR_jll, + Base.UUID("d2c73de3-f751-5644-a686-071e5b155ba9"), # GR_jll "libGR_path" => lib_path(grdir, "libGR"), "libGR3_path" => lib_path(grdir, "libGR3"), "libGRM_path" => lib_path(grdir, "libGRM"), @@ -217,13 +212,8 @@ module GRPreferences Remove overrides for GR_jll artifacts in the (Local)Preferences.toml of the project. """ function unoverride_project(; force = false) - mod = if isdefined(@__MODULE__, :GR_jll) - GR_jll - else - Base.UUID("d2c73de3-f751-5644-a686-071e5b155ba9") - end delete_preferences!( - GR_jll, + Base.UUID("d2c73de3-f751-5644-a686-071e5b155ba9"), # GR_jll "libGR_path", "libGR3_path", "libGRM_path", From c240f95ba52f9dbd06102ca649ecb9507b1ed8b0 Mon Sep 17 00:00:00 2001 From: Mark Kittisopikul Date: Wed, 2 Nov 2022 13:25:55 -0400 Subject: [PATCH 08/26] Add a force keyword to download --- src/downloader.jl | 15 +++++++++++---- src/preferences.jl | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/downloader.jl b/src/downloader.jl index e7547ac3..ae30ea22 100644 --- a/src/downloader.jl +++ b/src/downloader.jl @@ -298,7 +298,7 @@ end Download tarball from https://github.com/sciapp/gr/releases and extract the tarball into install_dir. """ -function download(install_dir = get_default_install_dir()) +function download(install_dir = get_default_install_dir(); force = false) # Save the current directory so we can change back to it later current_dir = pwd() @@ -309,8 +309,13 @@ function download(install_dir = get_default_install_dir()) # Ensure the working directory exists mkpath(install_dir) - # Check for an existing installation - grdir = get_grdir() + if force + # Download regardless if an existing installation exists + grdir = nothing + else + # Check for an existing installation + grdir = get_grdir() + end # We did not find an existing installation if isnothing(grdir) @@ -327,7 +332,9 @@ function download(install_dir = get_default_install_dir()) file = download_tarball(version, os, arch, downloads_dir) # Extract the tarball - rm(destination_dir; force=true, recursive=true) + if isdir(destination_dir) || force + rm(destination_dir; force=force, recursive=true) + end mktempdir() do extract_dir Tar.extract(`$(p7zip_jll.p7zip()) x $file -so`, extract_dir) mv(joinpath(extract_dir, "gr"), destination_dir) diff --git a/src/preferences.jl b/src/preferences.jl index 95c9315e..6c4cd415 100644 --- a/src/preferences.jl +++ b/src/preferences.jl @@ -140,7 +140,7 @@ module GRPreferences See `use_system_binary` for details. """ function use_upstream_binary(args...; export_prefs = false, force = false, override = :depot) - grdir = Downloader.download(args...) + grdir = Downloader.download(args...; force) use_system_binary(grdir; export_prefs, force, override) end From 994807f4a571cd9aad29d21afe35ecc6a8e11c2c Mon Sep 17 00:00:00 2001 From: Mark Kittisopikul Date: Wed, 2 Nov 2022 13:34:44 -0400 Subject: [PATCH 09/26] Add repair instructions to GR_jll import failure message. --- src/preferences.jl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/preferences.jl b/src/preferences.jl index 6c4cd415..796cfae5 100644 --- a/src/preferences.jl +++ b/src/preferences.jl @@ -5,7 +5,12 @@ module GRPreferences try import GR_jll catch err - @debug "import GR_jll failed" err + @debug """ + import GR_jll failed. + Consider using `GR.GRPreferences.use_jll_binary()` or + `GR.GRPreferences.use_upstream_binary()` to repair. + Importing GR a second time will allow use of these functions. + """ end include("downloader.jl") From 18296191819fcbc3da98f0b82f957c2a51c5ab05 Mon Sep 17 00:00:00 2001 From: Mark Kittisopikul Date: Wed, 2 Nov 2022 14:24:50 -0400 Subject: [PATCH 10/26] Apply suggestions from code review Mostly style and conciseness Co-authored-by: t-bltg --- src/downloader.jl | 35 ++++++++++++++++------------------- src/preferences.jl | 8 ++------ 2 files changed, 18 insertions(+), 25 deletions(-) diff --git a/src/downloader.jl b/src/downloader.jl index ae30ea22..e5d3d23b 100644 --- a/src/downloader.jl +++ b/src/downloader.jl @@ -200,12 +200,10 @@ function check_dependencies(grdir::String) gksqt = joinpath(grdir, "bin", "gksqt") res = read(`ldd $gksqt`, String) if occursin("not found", res) - @warn( - "Missing dependencies for GKS QtTerm. Did you install the Qt5 run-time?" - ) - @warn( - "Please refer to https://gr-framework.org/julia.html for further information." - ) + @warn """ + Missing dependencies for GKS QtTerm. Did you install the Qt5 run-time ? + Please refer to https://gr-framework.org/julia.html for further information. + """ end catch # Fail silently @@ -223,13 +221,13 @@ function apple_install(grdir::String) `/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -f $app`, ) try - @static if VERSION >= v"1.4.0-DEV.265" - have_qml = haskey( + have_qml = @static if VERSION >= v"1.4.0-DEV.265" + haskey( Pkg.dependencies(), UUID("2db162a6-7e43-52c3-8d84-290c1c42d82a"), ) else - have_qml = haskey(Pkg.API.installed(), "QML") + haskey(Pkg.API.installed(), "QML") end # Set rpath of gr/lib/qt5plugin.so to that of QML if have_qml @@ -255,9 +253,8 @@ Return the default install directory where we have write permissions. Currently, this is the deps directory of the GR package: `joinpath(pathof(GR), "..", "deps")` """ -function get_default_install_dir() - return abspath(joinpath(@__DIR__, "..", "deps")) -end +get_default_install_dir() = + abspath(joinpath(@__DIR__, "..", "deps")) """ download_tarball(version, os, arch, downloads_dir = mktempdir()) @@ -270,19 +267,19 @@ function download_tarball(version, os, arch, downloads_dir = mktempdir()) @info("Downloading pre-compiled GR $version $os binary", file) # Download versioned tarballs from Github - if version != "latest" - ok = try_download( + ok = if version != "latest" + try_download( "https://github.com/sciapp/gr/releases/download/v$version/$tarball", file, ) else - ok = false + false end # Download latest tarball from gr-framework.org if !ok if !try_download("https://gr-framework.org/downloads/$tarball", file) - @warn("Using insecure connection") + @warn "Using insecure connection" if !try_download("http://gr-framework.org/downloads/$tarball", file) error("Cannot download GR run-time") end @@ -309,12 +306,12 @@ function download(install_dir = get_default_install_dir(); force = false) # Ensure the working directory exists mkpath(install_dir) - if force + grdir = if force # Download regardless if an existing installation exists - grdir = nothing + nothing else # Check for an existing installation - grdir = get_grdir() + get_grdir() end # We did not find an existing installation diff --git a/src/preferences.jl b/src/preferences.jl index 796cfae5..05a546a5 100644 --- a/src/preferences.jl +++ b/src/preferences.jl @@ -97,12 +97,8 @@ module GRPreferences if override isa Symbol override = (override,) end - if :depot in override - override_depot(grdir) - end - if :project in override - override_project(grdir; force) - end + :depot in override && override_depot(grdir) + :project in override && override_project(grdir; force) @info "Please restart Julia to change the GR binary configuration." end From a0f724008bbcb9d6bb617ad6ead5eccedf021c1c Mon Sep 17 00:00:00 2001 From: Mark Kittisopikul Date: Wed, 2 Nov 2022 15:07:37 -0400 Subject: [PATCH 11/26] Apply suggestions from code review More concise! Co-authored-by: t-bltg --- src/downloader.jl | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/src/downloader.jl b/src/downloader.jl index e5d3d23b..8b6cc4fd 100644 --- a/src/downloader.jl +++ b/src/downloader.jl @@ -48,9 +48,7 @@ function get_grdir() end end end - if have_dir - @info("Found existing GR run-time in $grdir") - end + have_dir && @info "Found existing GR run-time in $grdir" return have_dir ? grdir : nothing end @@ -96,11 +94,7 @@ end Figure out which specific operating system this, including the specific Linux distribution. """ function get_os_and_arch() - if Sys.iswindows() - os = "Windows" - else - os = string(Sys.KERNEL) - end + os = Sys.iswindows() ? "Windows" : string(Sys.KERNEL) arch = Sys.ARCH @@ -277,13 +271,10 @@ function download_tarball(version, os, arch, downloads_dir = mktempdir()) end # Download latest tarball from gr-framework.org - if !ok - if !try_download("https://gr-framework.org/downloads/$tarball", file) - @warn "Using insecure connection" - if !try_download("http://gr-framework.org/downloads/$tarball", file) - error("Cannot download GR run-time") - end - end + if !ok && !try_download("https://gr-framework.org/downloads/$tarball", file) + @warn "Using insecure connection" + try_download("http://gr-framework.org/downloads/$tarball", file) || + error("Cannot download GR run-time") end return file @@ -340,17 +331,13 @@ function download(install_dir = get_default_install_dir(); force = false) end # Address Mac specific framework and rpath issues - if Sys.isapple() - apple_install(destination_dir) - end + Sys.isapple() && apple_install(destination_dir) grdir = destination_dir end # if isnothing(grdir) # Check dependencies when using Linux or FreeBSD - if Sys.islinux() || Sys.isfreebsd() - check_dependencies(grdir) - end + (Sys.islinux() || Sys.isfreebsd()) && check_dependencies(grdir) @info "grdir" grdir return grdir From 6802ac6a74078c7d25e958b9778900c8338c851f Mon Sep 17 00:00:00 2001 From: Mark Kittisopikul Date: Wed, 2 Nov 2022 15:29:26 -0400 Subject: [PATCH 12/26] Add diagnostics function --- src/preferences.jl | 49 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/src/preferences.jl b/src/preferences.jl index 05a546a5..d9415de8 100644 --- a/src/preferences.jl +++ b/src/preferences.jl @@ -223,4 +223,53 @@ module GRPreferences force ) end + + """ + diagnostics() + + Output diagnostics about preferences and overrides for GR and GR_jll. + """ + function diagnostics() + # GR Preferences + binary = @load_preference("binary") + grdir = @load_preference("grdir") + + # GR_jll Preferences + GR_jll_uuid = Base.UUID("d2c73de3-f751-5644-a686-071e5b155ba9") + libGR_path = load_preference(GR_jll_uuid, "libGR_path") + libGR3_path = load_preference(GR_jll_uuid, "libGR3_path") + libGRM_path = load_preference(GR_jll_uuid, "libGRM_path") + libGKS_path = load_preference(GR_jll_uuid, "libGKS_path") + gksqt_path = load_preference(GR_jll_uuid, "gksqt_path") + + # Override.toml in DEPOT_PATH + override_toml_path = get_override_toml_path() + override_dict = if isfile(override_toml_path) + TOML.parsefile(override_toml_path) + else + Dict{String,Any}() + end + gr_jll_override_dict = get(override_dict, string(GR_jll_uuid), Dict{String,Any}()) + resolved_grdir = haskey(ENV, "GRDIR") ? ENV["GRDIR"] : grdir + + # Output + @info "GRDIR Environment Variable" get(ENV, "GRDIR", missing) + @info "GR Preferences" binary grdir + isnothing(resolved_grdir) || + @info "resolved_grdir" isdir(resolved_grdir) isdir.(joinpath.((resolved_grdir,), ("bin", "lib", "include", "fonts"))) + @info "GR_jll Preferences" libGR_path libGR3_path libGRM_path libGKS_path gksqt_path + @info "GR_jll Override.toml" override_toml_path isfile(override_toml_path) gr_jll_override_dict + + if(isdefined(@__MODULE__, :GR_jll)) + @info "GR_jll" GR_jll.libGR_path GR_jll.libGR3_path GR_jll.libGRM_path GR_jll.libGKS_path GR_jll.gksqt_path + else + @info "GR_jll is not loaded" + end + + return (; + binary, grdir, + libGR_path, libGR3_path, libGRM_path, libGKS_path, gksqt_path, + override_toml_path, gr_jll_override_dict + ) + end end From 5f6fc70dbd8bed98484bb6d0ccc90fc134059dbe Mon Sep 17 00:00:00 2001 From: Mark Kittisopikul Date: Wed, 2 Nov 2022 16:26:52 -0400 Subject: [PATCH 13/26] Allow install_dir to include "gr" basename, use parent as install_dir --- src/downloader.jl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/downloader.jl b/src/downloader.jl index 8b6cc4fd..d65a4c6b 100644 --- a/src/downloader.jl +++ b/src/downloader.jl @@ -288,13 +288,14 @@ tarball into install_dir. """ function download(install_dir = get_default_install_dir(); force = false) - # Save the current directory so we can change back to it later - current_dir = pwd() - + # If the install_dir path ends in gr, then install in the parent dir + # Use a trailing slash if you really want the install in gr/gr + basename(install_dir) == "gr" && (install_dir = dirname(install_dir)) + # Configure directories destination_dir = joinpath(install_dir, "gr") - # Ensure the working directory exists + # Ensure the install directory exists mkpath(install_dir) grdir = if force From fe6ccffd7525f59404e1eaeb2e781b1e81590478 Mon Sep 17 00:00:00 2001 From: Mark Kittisopikul Date: Wed, 2 Nov 2022 17:29:11 -0400 Subject: [PATCH 14/26] Reinitialize GRPreferences.jl after changing binaries --- src/preferences.jl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/preferences.jl b/src/preferences.jl index d9415de8..c075e4e1 100644 --- a/src/preferences.jl +++ b/src/preferences.jl @@ -99,6 +99,7 @@ module GRPreferences end :depot in override && override_depot(grdir) :project in override && override_project(grdir; force) + __init__() @info "Please restart Julia to change the GR binary configuration." end @@ -126,6 +127,7 @@ module GRPreferences end unoverride_depot() unoverride_project(; force) + __init__() @info "Please restart Julia to change the GR binary configuration." end @@ -256,7 +258,7 @@ module GRPreferences @info "GRDIR Environment Variable" get(ENV, "GRDIR", missing) @info "GR Preferences" binary grdir isnothing(resolved_grdir) || - @info "resolved_grdir" isdir(resolved_grdir) isdir.(joinpath.((resolved_grdir,), ("bin", "lib", "include", "fonts"))) + @info "resolved_grdir" resolved_dir isdir(resolved_grdir) isdir.(joinpath.((resolved_grdir,), ("bin", "lib", "include", "fonts"))) @info "GR_jll Preferences" libGR_path libGR3_path libGRM_path libGKS_path gksqt_path @info "GR_jll Override.toml" override_toml_path isfile(override_toml_path) gr_jll_override_dict From 6fc46ea21a179dcbfc2db916b4e3162de2b124ba Mon Sep 17 00:00:00 2001 From: Mark Kittisopikul Date: Wed, 2 Nov 2022 22:39:54 -0400 Subject: [PATCH 15/26] Fix resolved_dir in diagnostics --- src/preferences.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/preferences.jl b/src/preferences.jl index c075e4e1..a3dbdafb 100644 --- a/src/preferences.jl +++ b/src/preferences.jl @@ -258,7 +258,7 @@ module GRPreferences @info "GRDIR Environment Variable" get(ENV, "GRDIR", missing) @info "GR Preferences" binary grdir isnothing(resolved_grdir) || - @info "resolved_grdir" resolved_dir isdir(resolved_grdir) isdir.(joinpath.((resolved_grdir,), ("bin", "lib", "include", "fonts"))) + @info "resolved_grdir" resolved_grdir isdir(resolved_grdir) isdir.(joinpath.((resolved_grdir,), ("bin", "lib", "include", "fonts"))) @info "GR_jll Preferences" libGR_path libGR3_path libGRM_path libGKS_path gksqt_path @info "GR_jll Override.toml" override_toml_path isfile(override_toml_path) gr_jll_override_dict From 833468ea97bc558434317223e56cf7ba51d73a4f Mon Sep 17 00:00:00 2001 From: Mark Kittisopikul Date: Wed, 2 Nov 2022 22:57:37 -0400 Subject: [PATCH 16/26] Fix svgplugin.dll issues on Windows --- src/funcptrs.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/funcptrs.jl b/src/funcptrs.jl index 17fdf312..e7f0a484 100644 --- a/src/funcptrs.jl +++ b/src/funcptrs.jl @@ -33,6 +33,8 @@ function load_libs(always::Bool = false) libGR_handle[] = Libdl.dlopen(GRPreferences.libGR[]) libGR3_handle[] = Libdl.dlopen(GRPreferences.libGR3[]) libGRM_handle[] = Libdl.dlopen(GRPreferences.libGRM[]) + # Fix svgplugin.dll loading issues on Windows, why? + Libdl.dlopen(joinpath(GRPreferences.libpath[], "svgplugin")) lp = GRPreferences.libpath[] if Sys.iswindows() ENV["PATH"] = join((lp, get(ENV, "PATH", "")), ';') From 9a74f89599726d2983ab44e676ef311e1687b63f Mon Sep 17 00:00:00 2001 From: Mark Kittisopikul Date: Wed, 2 Nov 2022 22:59:15 -0400 Subject: [PATCH 17/26] Pin GR_jll version to 0.69.1 --- Project.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Project.toml b/Project.toml index fe72b3d3..e3153a46 100644 --- a/Project.toml +++ b/Project.toml @@ -28,4 +28,5 @@ p7zip_jll = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" HTTP = "0.8, 0.9, 1" JSON = "0.20, 0.21, 1" Preferences = "1" +GR_jll = "0.69.1" julia = "1.6" From 38cb1c8d4d71e01f99293d479d1776363fd09633 Mon Sep 17 00:00:00 2001 From: Mark Kittisopikul Date: Wed, 2 Nov 2022 23:00:29 -0400 Subject: [PATCH 18/26] Fix libpath on Windows, maybe? --- src/preferences.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/preferences.jl b/src/preferences.jl index a3dbdafb..de6c6daf 100644 --- a/src/preferences.jl +++ b/src/preferences.jl @@ -63,7 +63,7 @@ module GRPreferences libGR3[] = lib_path(grdir[], "libGR3") libGRM[] = lib_path(grdir[], "libGRM") libGKS[] = lib_path(grdir[], "libGKS") - libpath[] = joinpath(grdir[], "lib") + libpath[] = lib_path(grdir[], "") else error("Unknown GR binary: $binary") end From 84c69aea04b92693035d06e44ad9e2ed62d2171f Mon Sep 17 00:00:00 2001 From: Mark Kittisopikul Date: Wed, 2 Nov 2022 23:19:30 -0400 Subject: [PATCH 19/26] Add README documentation for GRPreferences --- README.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/README.md b/README.md index f1f5a5b5..d2399c39 100644 --- a/README.md +++ b/README.md @@ -80,3 +80,43 @@ However, if you want to permanently use your own GR run-time, you have to set th Please note that with the method shown here, `GR_jll` is not imported. +### Switching binaries via GR.GRPreferences + +To aid in switching between BinaryBuilder and upstream framework binaries, the `GR.GRPReferences` module implements three methods `use_system_binary()`, `use_upstream_binary()`, and `use_jll_binary()`. These use [Preferences.jl](https://github.com/JuliaPackaging/Preferences.jl) to configure GR.jl +and GR_jll.jl. + +To use an existing GR install, invoke `use_system_binary`. + +```julia +using GR +GR.GRPreferences.use_system_binary("/path/to/gr"; force = true) +``` + +To download and switch to [upstream binaries](https://github.com/sciapp/gr/releases) invoke `use_upstream_binary`. + +```julia +using GR # repeat this if there is an error +GR.GRPreferences.use_upstream_binary(; force = true) +``` + +`use_system_binary` and `use_upstream_binary` accept an `override` keyword. This may be set to one of the following: +* `:depot` (default) - Use Overrides.toml in the Julia depot. This normally resides in `.julia/artifacts/Overrides.toml` +* `:project` - Use LocalPreferences.toml. This is usually located near the Project.toml of your active project environment. +* `(:depot, :project)` - Use both of the override mechanisms above. + +To switch back to BinaryBuilder binaries supplied with [GR_jll](https://github.com/JuliaBinaryWrappers/GR_jll.jl), invoke `use_jll_binary`: + +```julia +using GR # repeat this if there is an error +GR.GRPreferences.use_jll_binary(; force = true) +``` + +This will reset both the `:depot` and `:project` override mechanisms above. + +If you encounter difficulties switching between binaries, the `diagnostics()` function will provide useful information. +Please include this information when asking for assistance. + +```julia +using GR +GR.GRPreferences.diagnostics() +``` \ No newline at end of file From 24723949334412d909c2d37f0ee4001345e72464 Mon Sep 17 00:00:00 2001 From: Mark Kittisopikul Date: Wed, 2 Nov 2022 23:39:29 -0400 Subject: [PATCH 20/26] Fix funcptrs.jl --- src/funcptrs.jl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/funcptrs.jl b/src/funcptrs.jl index e7f0a484..3964c956 100644 --- a/src/funcptrs.jl +++ b/src/funcptrs.jl @@ -34,7 +34,9 @@ function load_libs(always::Bool = false) libGR3_handle[] = Libdl.dlopen(GRPreferences.libGR3[]) libGRM_handle[] = Libdl.dlopen(GRPreferences.libGRM[]) # Fix svgplugin.dll loading issues on Windows, why? - Libdl.dlopen(joinpath(GRPreferences.libpath[], "svgplugin")) + @static if Sys.iswindows() + Libdl.dlopen(joinpath(dirname(GRPreferences.libGR[]), "svgplugin")) + end lp = GRPreferences.libpath[] if Sys.iswindows() ENV["PATH"] = join((lp, get(ENV, "PATH", "")), ';') From ea529f5534d6cdffa4ffbbc1615b6263cd1f22a8 Mon Sep 17 00:00:00 2001 From: Mark Kittisopikul Date: Thu, 3 Nov 2022 00:22:53 -0400 Subject: [PATCH 21/26] Resolve svgplugin issues by rebuilding LIBPATH --- src/funcptrs.jl | 4 ---- src/preferences.jl | 9 +++++++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/funcptrs.jl b/src/funcptrs.jl index 3964c956..17fdf312 100644 --- a/src/funcptrs.jl +++ b/src/funcptrs.jl @@ -33,10 +33,6 @@ function load_libs(always::Bool = false) libGR_handle[] = Libdl.dlopen(GRPreferences.libGR[]) libGR3_handle[] = Libdl.dlopen(GRPreferences.libGR3[]) libGRM_handle[] = Libdl.dlopen(GRPreferences.libGRM[]) - # Fix svgplugin.dll loading issues on Windows, why? - @static if Sys.iswindows() - Libdl.dlopen(joinpath(dirname(GRPreferences.libGR[]), "svgplugin")) - end lp = GRPreferences.libpath[] if Sys.iswindows() ENV["PATH"] = join((lp, get(ENV, "PATH", "")), ';') diff --git a/src/preferences.jl b/src/preferences.jl index de6c6daf..4cdbc5a9 100644 --- a/src/preferences.jl +++ b/src/preferences.jl @@ -55,6 +55,15 @@ module GRPreferences libGR3[] = GR_jll.libGR3 libGRM[] = GR_jll.libGRM libGKS[] = GR_jll.libGKS + + # Because GR_jll does not dlopen as of 0.69.1+1, we need to append + # the LIBPATH_list similar to JLLWrappers.@init_library_product + push!(GR_jll.LIBPATH_list, dirname(GR_jll.libGR)) + # Recompute LIBPATH similar to JLLWrappers.@generate_init_footer + unique!(GR_jll.LIBPATH_list) + pathsep = GR_jll.JLLWrappers.pathsep + GR_jll.LIBPATH[] = join(vcat(GR_jll.LIBPATH_list, Base.invokelatest(GR_jll.JLLWrappers.get_julia_libpaths))::Vector{String}, pathsep) + libpath[] = GR_jll.LIBPATH[] elseif binary == "system" grdir[] = haskey(ENV, "GRDIR") ? ENV["GRDIR"] : @load_preference("grdir") From fbbada02d9318f4f81752dbb6304295ef2889b8a Mon Sep 17 00:00:00 2001 From: Mark Kittisopikul Date: Thu, 3 Nov 2022 00:45:56 -0400 Subject: [PATCH 22/26] Apply suggestions from code review --- src/downloader.jl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/downloader.jl b/src/downloader.jl index d65a4c6b..75ab76c4 100644 --- a/src/downloader.jl +++ b/src/downloader.jl @@ -34,8 +34,7 @@ or `nothing` if a GR install is not located in any of those locations. function get_grdir() if "GRDIR" in keys(ENV) grdir = ENV["GRDIR"] - have_dir = length(grdir) > 0 - if have_dir + if (have_dir = !isempty(grdir)) have_dir = isdir(joinpath(grdir, "fonts")) end else From 1390e5dd652034f83a2559c7f598f9c6b9f2e44d Mon Sep 17 00:00:00 2001 From: Mark Kittisopikul Date: Thu, 3 Nov 2022 00:59:58 -0400 Subject: [PATCH 23/26] Improve Overrides.toml diagnostic --- src/preferences.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/preferences.jl b/src/preferences.jl index 4cdbc5a9..cacb79ed 100644 --- a/src/preferences.jl +++ b/src/preferences.jl @@ -269,7 +269,7 @@ module GRPreferences isnothing(resolved_grdir) || @info "resolved_grdir" resolved_grdir isdir(resolved_grdir) isdir.(joinpath.((resolved_grdir,), ("bin", "lib", "include", "fonts"))) @info "GR_jll Preferences" libGR_path libGR3_path libGRM_path libGKS_path gksqt_path - @info "GR_jll Override.toml" override_toml_path isfile(override_toml_path) gr_jll_override_dict + @info "GR_jll Override.toml" override_toml_path isfile(override_toml_path) get(gr_jll_override_dict, "GR", nothing) if(isdefined(@__MODULE__, :GR_jll)) @info "GR_jll" GR_jll.libGR_path GR_jll.libGR3_path GR_jll.libGRM_path GR_jll.libGKS_path GR_jll.gksqt_path From 9a82ca6c38d6ce0aae7f29353c9e721e52788fd6 Mon Sep 17 00:00:00 2001 From: Mark Kittisopikul Date: Thu, 3 Nov 2022 01:00:28 -0400 Subject: [PATCH 24/26] Rename get_override to get_overrides --- src/preferences.jl | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/preferences.jl b/src/preferences.jl index cacb79ed..5a6441d6 100644 --- a/src/preferences.jl +++ b/src/preferences.jl @@ -157,12 +157,12 @@ module GRPreferences end """ - get_override_toml_path() + get_overrides_toml_path() Get the path the depot's Overrides.toml """ - function get_override_toml_path() - override_toml_path = joinpath(Artifacts.artifacts_dirs()[1], "Overrides.toml") + function get_overrides_toml_path() + overrides_toml_path = joinpath(Artifacts.artifacts_dirs()[1], "Overrides.toml") end """ @@ -171,14 +171,14 @@ module GRPreferences Override GR_jll in the DEPOT_PATH[1]/artifacts/Overrides.toml with `grdir`. """ function override_depot(grdir = grdir[]) - override_toml_path = get_override_toml_path() - override_dict = if isfile(override_toml_path) - TOML.parsefile(override_toml_path) + overrides_toml_path = get_overrides_toml_path() + override_dict = if isfile(overrides_toml_path) + TOML.parsefile(overrides_toml_path) else Dict{String,Any}() end override_dict["d2c73de3-f751-5644-a686-071e5b155ba9"] = Dict("GR" => grdir) - open(override_toml_path, "w") do io + open(overrides_toml_path, "w") do io TOML.print(io, override_dict) end end @@ -189,14 +189,14 @@ module GRPreferences Remove the override for GR_jll in DEPOT_PATH[1]/artifats/Overrides.toml """ function unoverride_depot() - override_toml_path = get_override_toml_path() - override_dict = if isfile(override_toml_path) - TOML.parsefile(override_toml_path) + overrides_toml_path = get_overrides_toml_path() + override_dict = if isfile(overrides_toml_path) + TOML.parsefile(overrides_toml_path) else Dict{String,Any}() end delete!(override_dict, "d2c73de3-f751-5644-a686-071e5b155ba9") - open(override_toml_path, "w") do io + open(overrides_toml_path, "w") do io TOML.print(io, override_dict) end end @@ -254,9 +254,9 @@ module GRPreferences gksqt_path = load_preference(GR_jll_uuid, "gksqt_path") # Override.toml in DEPOT_PATH - override_toml_path = get_override_toml_path() - override_dict = if isfile(override_toml_path) - TOML.parsefile(override_toml_path) + overrides_toml_path = get_overrides_toml_path() + override_dict = if isfile(overrides_toml_path) + TOML.parsefile(overrides_toml_path) else Dict{String,Any}() end @@ -269,7 +269,7 @@ module GRPreferences isnothing(resolved_grdir) || @info "resolved_grdir" resolved_grdir isdir(resolved_grdir) isdir.(joinpath.((resolved_grdir,), ("bin", "lib", "include", "fonts"))) @info "GR_jll Preferences" libGR_path libGR3_path libGRM_path libGKS_path gksqt_path - @info "GR_jll Override.toml" override_toml_path isfile(override_toml_path) get(gr_jll_override_dict, "GR", nothing) + @info "GR_jll Overrides.toml" overrides_toml_path isfile(overrides_toml_path) get(gr_jll_override_dict, "GR", nothing) if(isdefined(@__MODULE__, :GR_jll)) @info "GR_jll" GR_jll.libGR_path GR_jll.libGR3_path GR_jll.libGRM_path GR_jll.libGKS_path GR_jll.gksqt_path @@ -280,7 +280,7 @@ module GRPreferences return (; binary, grdir, libGR_path, libGR3_path, libGRM_path, libGKS_path, gksqt_path, - override_toml_path, gr_jll_override_dict + overrides_toml_path, gr_jll_override_dict ) end end From 375a59fa6c5b00965f2452cd1171e3e5b1a0a960 Mon Sep 17 00:00:00 2001 From: Mark Kittisopikul Date: Thu, 3 Nov 2022 01:12:29 -0400 Subject: [PATCH 25/26] Add some GRPreferences tests --- test/runtests.jl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/runtests.jl b/test/runtests.jl index 05879a15..f35cd691 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -255,3 +255,12 @@ end @timev basic_tests("single-page PDF files", fig="pdf") @timev basic_tests("SVG output", fig="svg") @timev basic_tests("PNG images", fig="png") + +GR.GRPreferences.download(pwd(); force = true) +GR.GRPreferences.download(joinpath(pwd(), "gr"); force = true) +readdir("gr") .|> println +GR.GRPreferences.download(; force = true) +GR.GRPreferences.use_upstream_binary(; force = true) +GR.GRPreferences.diagnostics() +GR.GRPreferences.use_jll_binary(; force = true) +GR.GRPreferences.diagnostics() \ No newline at end of file From 005b721753beb8e2af7dc6d2eb459128ad3fe466 Mon Sep 17 00:00:00 2001 From: Mark Kittisopikul Date: Thu, 3 Nov 2022 01:21:14 -0400 Subject: [PATCH 26/26] Fix tests --- test/runtests.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index f35cd691..78551a0b 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -256,10 +256,10 @@ end @timev basic_tests("SVG output", fig="svg") @timev basic_tests("PNG images", fig="png") -GR.GRPreferences.download(pwd(); force = true) -GR.GRPreferences.download(joinpath(pwd(), "gr"); force = true) +GR.GRPreferences.Downloader.download(pwd(); force = true) +GR.GRPreferences.Downloader.download(joinpath(pwd(), "gr"); force = true) readdir("gr") .|> println -GR.GRPreferences.download(; force = true) +GR.GRPreferences.Downloader.download(; force = true) GR.GRPreferences.use_upstream_binary(; force = true) GR.GRPreferences.diagnostics() GR.GRPreferences.use_jll_binary(; force = true)