Skip to content

Commit

Permalink
Split into explicit register!()/unregister!()
Browse files Browse the repository at this point in the history
  • Loading branch information
staticfloat committed Jun 3, 2024
1 parent fd89c49 commit 956ee65
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/HistoricalStdlibVersions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ let
end
end

function __init__()
function register!()
if isdefined(Pkg.Types, :STDLIBS_BY_VERSION)
unregister!()
if isdefined(Pkg.Types, :StdlibInfo)
# We can directly use the datatypes in this package
append!(empty!(Pkg.Types.STDLIBS_BY_VERSION), STDLIBS_BY_VERSION)
merge!(empty!(Pkg.Types.UNREGISTERED_STDLIBS), UNREGISTERED_STDLIBS)
append!(Pkg.Types.STDLIBS_BY_VERSION, STDLIBS_BY_VERSION)
merge!(Pkg.Types.UNREGISTERED_STDLIBS, UNREGISTERED_STDLIBS)
else
# We have to convert our `StdlibInfo` types into the more limited (name, version) format
# from earlier julias. Those julias are unable to resolve dependencies of stdlibs properly.
empty!(Pkg.Types.STDLIBS_BY_VERSION)
for (version, stdlibs) in STDLIBS_BY_VERSION
push!(Pkg.Types.STDLIBS_BY_VERSION, version => Dict{UUID,Tuple{String,Union{VersionNumber,Nothing}}}(
uuid => (info.name, info.version) for (uuid, info) in stdlibs
Expand All @@ -60,7 +60,6 @@ function __init__()
end
return nothing
end
empty!(Pkg.Types.UNREGISTERED_STDLIBS)
for uuid in UNREGISTERED_STDLIBS
info = find_info(uuid)
if info === nothing
Expand All @@ -72,4 +71,15 @@ function __init__()
end
end
end

function unregister!()
empty!(Pkg.Types.STDLIBS_BY_VERSION)
empty!(Pkg.Types.UNREGISTERED_STDLIBS)
end

function __init__()
if get(ENV, "HISTORICAL_STDLIB_VERSIONS_AUTO_REGISTER", "true") == "true"
register!()
end
end
end # module HistoricalStdlibVersions

0 comments on commit 956ee65

Please sign in to comment.