Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace build.jl by Artifacts.toml #3023

Merged
merged 3 commits into from
Oct 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Artifacts.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[plotly]
git-tree-sha1 = "f03dd0451a05a5fdbbcb3e548998a9d7a1ab6368"
lazy = true

[[plotly.download]]
url = "https://cdn.plot.ly/plotly-1.54.2.min.js"
sha256 = "487f1da6b7a1f127de59af8a65bb3fe2c63d709f011afea82896bdce28ecc0f8"
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Measures = "442fdcdd-2543-5da2-b0f3-8c86c306513e"
NaNMath = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
PlotThemes = "ccf2f8ad-2431-5c83-bf29-c5338b663b6a"
PlotUtils = "995b91a9-d308-5afd-9ec6-746e21dbc043"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Expand Down
18 changes: 0 additions & 18 deletions deps/build.jl

This file was deleted.

11 changes: 0 additions & 11 deletions src/Plots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,6 @@ import JSON

using Requires

if isfile(joinpath(@__DIR__, "..", "deps", "deps.jl"))
include(joinpath(@__DIR__, "..", "deps", "deps.jl"))
else
# This is a bit dirty, but I don't really see why anyone should be forced
# to build Plots, while it will just include exactly the below line
# as long as `ENV["PLOTS_HOST_DEPENDENCY_LOCAL"] = "true"` is not set.
# If the above env is set + `plotly_local_file_path == ""``,
# it will warn in the __init__ function to run build
const plotly_local_file_path = ""
end

export
grid,
bbox,
Expand Down
2 changes: 1 addition & 1 deletion src/backends/plotly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ html_body(plt::Plot{PlotlyBackend}) = plotly_html_body(plt)
const ijulia_initialized = Ref(false)

function plotly_html_head(plt::Plot)
local_file = ("file:///" * plotly_local_file_path)
local_file = ("file:///" * plotly_local_file_path[])
plotly =
use_local_dependencies[] ? local_file : "https://cdn.plot.ly/plotly-1.54.2.min.js"

Expand Down
2 changes: 1 addition & 1 deletion src/backends/web.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function standalone_html_window(plt::AbstractPlot)
old = use_local_dependencies[] # save state to restore afterwards
# if we open a browser ourself, we can host local files, so
# when we have a local plotly downloaded this is the way to go!
use_local_dependencies[] = isfile(plotly_local_file_path)
use_local_dependencies[] = isfile(plotly_local_file_path[])
filename = write_temp_html(plt)
open_browser_window(filename)
# restore for other backends
Expand Down
2 changes: 1 addition & 1 deletion src/ijulia.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const use_local_plotlyjs = Ref(false)

function _init_ijulia_plotting()
# IJulia is more stable with local file
use_local_plotlyjs[] = isfile(plotly_local_file_path)
use_local_plotlyjs[] = isfile(plotly_local_file_path[])

ENV["MPLBACKEND"] = "Agg"
end
Expand Down
22 changes: 15 additions & 7 deletions src/init.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using REPL
using Pkg.Artifacts

const plotly_local_file_path = Ref("")

function _plots_defaults()
if isdefined(Main, :PLOTS_DEFAULTS)
Expand Down Expand Up @@ -74,16 +76,22 @@ function __init__()
end
end

if haskey(ENV, "PLOTS_HOST_DEPENDENCY_LOCAL")
use_local_plotlyjs[] = ENV["PLOTS_HOST_DEPENDENCY_LOCAL"] == "true"
use_local_dependencies[] = isfile(plotly_local_file_path) && use_local_plotlyjs[]
if use_local_plotlyjs[] && !isfile(plotly_local_file_path)
@warn("PLOTS_HOST_DEPENDENCY_LOCAL is set to true, but no local plotly file found. run Pkg.build(\"Plots\") and make sure PLOTS_HOST_DEPENDENCY_LOCAL is set to true")
if get(ENV, "PLOTS_HOST_DEPENDENCY_LOCAL", "false") == true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This path is never taken, since what you get back is a the string "true" if you have set it to that, so that is never == true

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed that in #3067

artifact_toml = joinpath(@__DIR__, "Artifacts.toml")

plotly_sha = artifact_hash("plotly", artifact_toml)
if plotly_sha == nothing || !artifact_exists(plotly_sha)
plotly_sha = create_artifact() do artifact_dir
download("https://cdn.plot.ly/plotly-1.54.2.min.js", joinpath(artifact_dir, "plotly-1.54.2.min.js"))
end
end
else
use_local_dependencies[] = use_local_plotlyjs[]

plotly_local_file_path[] = joinpath(artifact_path(plotly_sha), "plotly-1.54.2.min.js")
use_local_plotlyjs[] = true
end

use_local_dependencies[] = use_local_plotlyjs[]


@require FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" begin
_show(io::IO, mime::MIME"image/png", plt::Plot{<:PDFBackends}) = _show_pdfbackends(io, mime, plt)
Expand Down