Skip to content

Commit 3fa89b9

Browse files
switch to using RegistryInstances.jl (#457)
1 parent e278592 commit 3fa89b9

File tree

4 files changed

+23
-19
lines changed

4 files changed

+23
-19
lines changed

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
2020
OutputCollectors = "6c11c7d4-943b-4e2b-80de-f2cfc2930a8c"
2121
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
2222
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
23+
RegistryInstances = "2792f1a3-b283-48e8-9a74-f99dce5104f3"
2324
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
2425
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
2526
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
@@ -56,6 +57,7 @@ Printf = "1.7"
5657
ProgressMeter = "1"
5758
REPL = "1.7"
5859
Random = "1.7"
60+
RegistryInstances = "0.1"
5961
SHA = "0.7, 1"
6062
Scratch = "1.0"
6163
SimpleBufferStream = "1"

src/BinaryBuilderBase.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ using Base.BinaryPlatforms
55
using Downloads
66
using JSON, OutputCollectors, Scratch
77
import HistoricalStdlibVersions
8+
using RegistryInstances: reachable_registries, registry_info, uuids_from_name
89

910
# Re-export useful stuff from Base.BinaryPlatforms:
1011
export HostPlatform, platform_dlext, valid_dl_path, arch, libc,

src/Prefix.jl

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -597,23 +597,37 @@ Given a JLL name and registered version, return a `PackageSpec` that, when passe
597597
]
598598
"""
599599
function get_addable_spec(name::AbstractString, version::VersionNumber;
600-
ctx = Pkg.Types.Context(), verbose::Bool = false)
600+
verbose::Bool = false)
601601
@debug "Getting addable spec" name version
602602
# Zeroth, update the registry
603603
update_registry(verbose ? stdout : devnull)
604+
605+
# Get registries using RegistryInstances
606+
registries = reachable_registries()
607+
604608
# First, resolve the UUID
605-
uuid = first(Pkg.Types.registry_resolve!(ctx.registries, Pkg.Types.PackageSpec(;name))).uuid
609+
uuid = nothing
610+
for reg in registries
611+
uuids = uuids_from_name(reg, name)
612+
if !isempty(uuids)
613+
uuid = first(uuids)
614+
break
615+
end
616+
end
617+
if uuid === nothing
618+
error("Unable to find package $name in any registry")
619+
end
606620
@debug "Resolved UUID" name uuid
607621

608622
# Next, determine the tree hash from the registry
609623
repo_urls = Set{String}()
610624
tree_hashes = Set{Base.SHA1}()
611-
for reg in ctx.registries
625+
for reg in registries
612626
if !haskey(reg, uuid)
613627
continue
614628
end
615629

616-
pkg_info = registry_info(reg, reg[uuid])
630+
pkg_info = registry_info(reg[uuid])
617631
if pkg_info.repo !== nothing
618632
push!(repo_urls, pkg_info.repo)
619633
end
@@ -630,7 +644,7 @@ function get_addable_spec(name::AbstractString, version::VersionNumber;
630644
@error("Unable to find dependency!",
631645
name,
632646
version,
633-
registries=ctx.registries,
647+
registries,
634648
)
635649
error("Unable to find dependency!")
636650
end
@@ -639,7 +653,7 @@ function get_addable_spec(name::AbstractString, version::VersionNumber;
639653
name,
640654
version,
641655
tree_hashes,
642-
registries=ctx.registries,
656+
registries,
643657
)
644658
error("Multiple treehashes found!")
645659
end

src/compat.jl

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,3 @@ if !isdefined(Pkg.Types, :stdlib_version)
2929
else
3030
const stdlib_version = Pkg.Types.stdlib_version
3131
end
32-
33-
if isdefined(Pkg, :Registry) && isdefined(Pkg.Registry, :registry_info)
34-
const _Pkg_registry_info = Pkg.Registry.registry_info
35-
elseif isdefined(Pkg, :RegistryHandling) && isdefined(Pkg.RegistryHandling, :registry_info)
36-
const _Pkg_registry_info = Pkg.RegistryHandling.registry_info
37-
end
38-
39-
# Handle Pkg.jl signature change: registry_info(pkg) -> registry_info(registry, pkg)
40-
if @isdefined(_Pkg_registry_info) && hasmethod(_Pkg_registry_info, Tuple{Pkg.Registry.PkgEntry})
41-
registry_info(::Pkg.Registry.RegistryInstance, pkg::Pkg.Registry.PkgEntry) = _Pkg_registry_info(pkg)
42-
else
43-
const registry_info = _Pkg_registry_info
44-
end

0 commit comments

Comments
 (0)