-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Artifacts: avoid reflection hacks to access ensure_artifact_installed
Packages should never access Base.loaded_modules() to call functions from it, as it can be brittle and create future incompatibilities, so instead we require the user to explicitly declare a dependency on the lazy-download machinery, if they requiring the ability to use it (for lazy artifacts). As a deprecation, if the user has `using Pkg`, that will be used instead, with a depwarn.
- Loading branch information
Showing
13 changed files
with
160 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/artifacts/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Artifacts: with_artifacts_directory | ||
# using Pkg.Artifacts: ensure_all_artifacts_installed | ||
using Pkg.Artifacts: load_artifacts_toml, ensure_artifact_installed | ||
let | ||
tempdir = joinpath(@__DIR__, "artifacts") | ||
toml = joinpath(@__DIR__, "Artifacts.toml") | ||
unused = Base.BinaryPlatforms.Platform(string(Sys.ARCH), "linux") | ||
with_artifacts_directory(tempdir) do | ||
# ensure_all_artifacts_installed(toml; include_lazy=false) | ||
dict = load_artifacts_toml(toml) | ||
for (name, meta) in dict | ||
if meta isa Array | ||
for meta in meta | ||
get(meta, "lazy", false) && continue | ||
ensure_artifact_installed(name, meta, toml; platform=unused) | ||
end | ||
else; meta::Dict | ||
get(meta, "lazy", false) && continue | ||
ensure_artifact_installed(name, meta, toml; platform=unused) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name = "LazyArtifacts" | ||
uuid = "4af54fe1-eca0-43a8-85a7-787d91b784e3" | ||
|
||
[deps] | ||
Artifacts = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" | ||
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" | ||
|
||
[extras] | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
|
||
[targets] | ||
test = ["Test"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# This file is a part of Julia. License is MIT: https://julialang.org/license | ||
|
||
module LazyArtifacts | ||
|
||
# reexport the Artifacts API | ||
using Artifacts: Artifacts, | ||
artifact_exists, artifact_path, artifact_meta, artifact_hash, | ||
select_downloadable_artifacts, find_artifacts_toml, @artifact_str | ||
export artifact_exists, artifact_path, artifact_meta, artifact_hash, | ||
select_downloadable_artifacts, find_artifacts_toml, @artifact_str | ||
|
||
# define a function for satisfying lazy Artifact downloads | ||
using Pkg.Artifacts: ensure_artifact_installed | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../Artifacts/test/Artifacts.toml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using LazyArtifacts | ||
using Test | ||
|
||
mktempdir() do tempdir | ||
LazyArtifacts.Artifacts.with_artifacts_directory(tempdir) do | ||
socrates_dir = artifact"socrates" | ||
@test isdir(socrates_dir) | ||
ex = @test_throws ErrorException artifact"c_simple" | ||
@test startswith(ex.value.msg, "Artifact \"c_simple\" was not installed correctly. ") | ||
end | ||
end | ||
|
||
module Deprecations | ||
using Artifacts, Pkg | ||
using Test | ||
mktempdir() do tempdir | ||
Artifacts.with_artifacts_directory(tempdir) do | ||
socrates_dir = @test_logs( | ||
(:warn, "using Pkg instead of using LazyArtifacts is deprecated"), | ||
artifact"socrates") | ||
@test isdir(socrates_dir) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters