Skip to content

Commit

Permalink
Add Artifacts as a standard library
Browse files Browse the repository at this point in the history
Imports `Pkg.Artifacts` into its own stdlib, Artifacts.  Includes the loading
and locating pieces of `Pkg.Artifacts`, but not the pieces for downloading and
installing artifacts, which still reside within Pkg.  Scripts that want to
generate artifacts should still use `Pkg.Artifacts`, but scripts that just want
to use artifacts that have already been generated are free to simply
`using Artifacts`, which should cut down on time to first load by a nice chunk.
If a package attempts to `@artifact"foo"` on an artifact that does not exist
the `Artifacts` module will dynamically load `Pkg` and invoke the downloading
routines through an inference barrier.

Also adds two new (minor) features:

* Slash-indexing: by popular demand, supports indexing into files within
  artifacts in one convenient syntax: `@artifact"FFMPEG/bin/ffmpeg"`
  will automatically perform the `joinpath()` for you after looking up
  the `FFMPEG` artifact.

* Compile-time constancy; when `@artifact_str` is given a constant
  `String`, it optimizes the generated code by looking up the
  appropriate hash at compile-time and embedding just that hash into the
  resultant code, saving on both lookup time and objects that must be
  serialized to the eventual precompilation `.ji` file.
  • Loading branch information
staticfloat committed Sep 10, 2020
1 parent 9d13114 commit 44db8d8
Show file tree
Hide file tree
Showing 9 changed files with 908 additions and 2 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ Standard library changes
* The `Pkg.BinaryPlatforms` module has been moved into `Base` as `Base.BinaryPlatforms` and heavily reworked.
Applications that want to be compatible with the old API should continue to import `Pkg.BinaryPlatforms`,
however new users should use `Base.BinaryPlatforms` directly. ([#37320])
* The `Pkg.Artifacts` module has been imported as a separate standard library. It is still available as
`Pkg.Artifacts`, however starting from Julia v1.6+, packages may import simply `Artifacts` without importing
all of `Pkg` alongside. ([#37320])

#### LinearAlgebra
* New method `LinearAlgebra.issuccess(::CholeskyPivoted)` for checking whether pivoted Cholesky factorization was successful ([#36002]).
Expand Down
1 change: 1 addition & 0 deletions base/sysimg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ let
:Distributed,
:SharedArrays,
:TOML,
:Artifacts,
:Pkg,
:Test,
:REPL,
Expand Down
15 changes: 15 additions & 0 deletions contrib/generate_precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,21 @@ if Distributed !== nothing
"""
end

Artifacts = get(Base.loaded_modules,
Base.PkgId(Base.UUID("56f22d72-fd6d-98f1-02f0-08ddc0907c33"), "Artifacts"),
nothing)
if Artifacts !== nothing
precompile_script *= """
using Artifacts, Base.BinaryPlatforms
artifacts_toml = abspath($(repr(joinpath(Sys.STDLIB, "Artifacts", "test", "Artifacts.toml"))))
cd(() -> @artifact_str("c_simple"), dirname(artifacts_toml))
artifacts = Artifacts.load_artifacts_toml(artifacts_toml)
platforms = [Artifacts.unpack_platform(e, "c_simple", artifacts_toml) for e in artifacts["c_simple"]]
best_platform = select_platform(Dict(p => triplet(p) for p in platforms))
"""
end


Pkg = get(Base.loaded_modules,
Base.PkgId(Base.UUID("44cfe95a-1eb2-52ea-b672-e2afdf69b78f"), "Pkg"),
nothing)
Expand Down
8 changes: 8 additions & 0 deletions stdlib/Artifacts/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name = "Artifacts"
uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
Loading

0 comments on commit 44db8d8

Please sign in to comment.