Skip to content

Commit 6584bb0

Browse files
committed
delay loading of Pkg until necessary
1 parent 3c53190 commit 6584bb0

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/toplevel_generators.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ function generate_imports(src_name)
4141
using Libdl, Artifacts, JLLWrappers.Preferences, Base.BinaryPlatforms
4242
using Artifacts: load_artifacts_toml, unpack_platform
4343
using Base.BinaryPlatforms: triplet, select_platform
44-
import Pkg
4544
if !@isdefined(augment_platform!)
4645
augment_platform!(platform) = platform
4746
end
@@ -81,7 +80,6 @@ This method generates the toplevel definitions common to all JLL packages, such
8180
`is_available()`, the `PATH` and `LIBPATH` symbols, etc....
8281
"""
8382
function generate_toplevel_definitions(src_name, __source__)
84-
pkg_dir = dirname(String(__source__.file))
8583
return quote
8684
"""
8785
is_available()
@@ -172,7 +170,9 @@ function generate_wrapper_load(src_name, pkg_uuid, __source__)
172170
end
173171

174172
if VERSION >= v"1.6"
175-
function ensure_artifact_installed(platform=host_platform)
173+
function install_current_artifact(platform=host_platform)
174+
# Avoid loading Pkg by default, to keep the latency down if we can
175+
local Pkg = Base.require(Base.PkgId(UUID((0x44cfe95a_1eb2_52ea, 0xb672_e2afdf69b78f)), "Pkg"))
176176
Pkg.Artifacts.ensure_artifact_installed($(src_name), joinpath($(pkg_dir), "..", "Artifacts.toml"); platform=platform, pkg_uuid=$(pkg_uuid))
177177
end
178178
end

src/wrapper_generators.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ macro generate_wrapper_header(src_name)
2929
catch
3030
# 1.6 does not call `.pkg/select_artifacts.jl`
3131
# 1.7+ User might switch the tag, without calling `Pkg.instantiate()`
32-
ensure_artifact_installed(host_platform)
32+
install_current_artifact(host_platform)
3333
return find_artifact_dir()
3434
end
3535
end

0 commit comments

Comments
 (0)