Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions ext/HistoricaStdlibGenerator/generate_historical_stdlibs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,20 +111,24 @@ function get_stdlibs(scratch_dir, julia_installer_name)
end

# This will give us a dictionary of UUID => (name, version) mappings for all standard libraries
stdlibs = Dict{Base.UUID, Tuple}(uuid => (name, nothing) for (uuid, name) in eval(Meta.parse(stdlibs_str)))
if jlvers < v"1.8"
stdlibs = Dict{Base.UUID, Tuple}(uuid => (name, nothing) for (uuid, name) in eval(Meta.parse(stdlibs_str)))

# We're going to try and get versions for each stdlib:
stdlib_path = readchomp(`$(jlexe) $(jlflags) -e 'import Pkg; print(Pkg.Types.stdlib_path(""))'`)
for uuid in keys(stdlibs)
# If this stdlib has a `Project.toml`, try to parse it for its version field
name = first(stdlibs[uuid])
project_path = joinpath(stdlib_path, name, "Project.toml")
if isfile(project_path)
d = TOML.parsefile(project_path)
if haskey(d, "version")
stdlibs[uuid] = (name, VersionNumber(d["version"]))
# We're going to try and get versions for each stdlib:
stdlib_path = readchomp(`$(jlexe) $(jlflags) -e 'import Pkg; print(Pkg.Types.stdlib_path(""))'`)
for uuid in keys(stdlibs)
# If this stdlib has a `Project.toml`, try to parse it for its version field
name = first(stdlibs[uuid])
project_path = joinpath(stdlib_path, name, "Project.toml")
if isfile(project_path)
d = TOML.parsefile(project_path)
if haskey(d, "version")
stdlibs[uuid] = (name, VersionNumber(d["version"]))
end
end
end
else
stdlibs = Dict{Base.UUID, Tuple}(uuid => (name, version) for (uuid, (name, version)) in eval(Meta.parse(stdlibs_str)))
end

return (jlvers, stdlibs)
Expand Down
12 changes: 6 additions & 6 deletions src/HistoricalStdlibs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -626,16 +626,16 @@ const STDLIBS_BY_VERSION = [
UUID("f43a241f-c20a-4ad4-852c-f6b1247861c6") => ("Downloads", v"1.5.1"),
UUID("7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee") => ("FileWatching", nothing),
UUID("9fa8497b-333b-5362-9e8d-4d0656e87820") => ("Future", nothing),
UUID("781609d7-10c4-51f6-84f2-b8444358ff6d") => ("GMP_jll", v"6.2.1+0"),
UUID("781609d7-10c4-51f6-84f2-b8444358ff6d") => ("GMP_jll", v"6.2.1+1"),
UUID("b77e0a4c-d291-57a0-90e8-8db25a27a240") => ("InteractiveUtils", nothing),
UUID("47c5dbc3-30ba-59ef-96a6-123e260183d9") => ("LLVMLibUnwind_jll", v"11.0.1+1"),
UUID("47c5dbc3-30ba-59ef-96a6-123e260183d9") => ("LLVMLibUnwind_jll", v"12.0.1+0"),
UUID("4af54fe1-eca0-43a8-85a7-787d91b784e3") => ("LazyArtifacts", nothing),
UUID("b27032c2-a3e7-50c8-80cd-2d36dbcbfd21") => ("LibCURL", v"0.6.3"),
UUID("deac9b47-8bc7-5906-a0fe-35ac56dc84c0") => ("LibCURL_jll", v"7.73.0+4"),
UUID("76f85450-5226-5b5a-8eaa-529ad045b433") => ("LibGit2", nothing),
UUID("e37daf67-58a4-590a-8e99-b0245dd2ffc5") => ("LibGit2_jll", v"1.2.3+0"),
UUID("29816b5a-b9ab-546f-933c-edad1886dfa8") => ("LibSSH2_jll", v"1.9.1+2"),
UUID("183b4373-6708-53ba-ad28-60e28bb38547") => ("LibUV_jll", v"2.0.1+3"),
UUID("183b4373-6708-53ba-ad28-60e28bb38547") => ("LibUV_jll", v"2.0.1+4"),
UUID("745a5e78-f969-53e9-954f-d19f2f74f4e3") => ("LibUnwind_jll", v"1.3.2+0"),
UUID("8f399da3-3557-5675-b5ff-fb832c97cbdb") => ("Libdl", nothing),
UUID("37e2e46d-f89d-539d-b4ee-838fcccc9c8e") => ("LinearAlgebra", nothing),
Expand All @@ -646,15 +646,15 @@ const STDLIBS_BY_VERSION = [
UUID("a63ad114-7e13-5084-954f-fe012c677804") => ("Mmap", nothing),
UUID("14a3606d-f60d-562e-9121-12d972cd8159") => ("MozillaCACerts_jll", v"2020.7.22"),
UUID("ca575930-c2e3-43a9-ace4-1e988b2c1908") => ("NetworkOptions", v"1.2.0"),
UUID("4536629a-c528-5b80-bd46-f80d51c5b363") => ("OpenBLAS_jll", v"0.3.13+7"),
UUID("4536629a-c528-5b80-bd46-f80d51c5b363") => ("OpenBLAS_jll", v"0.3.17+2"),
UUID("05823500-19ac-5b8b-9628-191a04bc5112") => ("OpenLibm_jll", v"0.7.5+0"),
UUID("efcefdf7-47ab-520b-bdef-62a2eaa19f15") => ("PCRE2_jll", v"10.36.0+2"),
UUID("44cfe95a-1eb2-52ea-b672-e2afdf69b78f") => ("Pkg", v"1.8.0"),
UUID("de0858da-6303-5e67-8744-51eddeeeb8d7") => ("Printf", nothing),
UUID("9abbd945-dff8-562f-b5e8-e1ebf5ef1b79") => ("Profile", nothing),
UUID("3fa0cd96-eef1-5676-8a61-b3b8758bbffb") => ("REPL", nothing),
UUID("9a3f8284-a2c9-5f02-9a11-845980a1fd5c") => ("Random", nothing),
UUID("ea8e919c-243c-51af-8825-aaa63cd721ce") => ("SHA", nothing),
UUID("ea8e919c-243c-51af-8825-aaa63cd721ce") => ("SHA", v"0.7.0"),
UUID("9e88b42a-f829-5b0c-bbe9-9e923198166b") => ("Serialization", nothing),
UUID("1a1011a3-84de-559e-8e89-a11a2f7dc383") => ("SharedArrays", nothing),
UUID("6462fe0b-24de-5631-8697-dd941f90decc") => ("Sockets", nothing),
Expand All @@ -669,7 +669,7 @@ const STDLIBS_BY_VERSION = [
UUID("4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5") => ("Unicode", nothing),
UUID("83775a58-1f1d-513f-b197-d71354ab007a") => ("Zlib_jll", v"1.2.12+1"),
UUID("05ff407c-b0c1-5878-9df8-858cc2e60c36") => ("dSFMT_jll", v"2.2.4+1"),
UUID("8f36deef-c2a5-5394-99ed-8e07531fb29a") => ("libLLVM_jll", v"12.0.1+0"),
UUID("8f36deef-c2a5-5394-99ed-8e07531fb29a") => ("libLLVM_jll", v"12.0.1+4"),
UUID("8e850b90-86db-534c-a0d3-1478176c7d93") => ("libblastrampoline_jll", v"3.1.0+0"),
UUID("8e850ede-7688-5339-a07c-302acd2aaf8d") => ("nghttp2_jll", v"1.41.0+1"),
UUID("3f19e933-33d8-53b3-aaab-bd5110c3b7a0") => ("p7zip_jll", v"16.2.1+1"),
Expand Down
4 changes: 2 additions & 2 deletions src/Operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ function resolve_versions!(env::EnvCache, registries::Vector{Registry.RegistryIn
else
env.manifest.julia_version = VERSION
end
names = Dict{UUID, String}(uuid => stdlib for (uuid, stdlib) in stdlibs())
names = Dict{UUID, String}(uuid => name for (uuid, (name, version)) in stdlibs())
# recursive search for packages which are tracking a path
developed = collect_developed(env, pkgs)
# But we only want to use information for those packages that we don't know about
Expand Down Expand Up @@ -350,7 +350,7 @@ function resolve_versions!(env::EnvCache, registries::Vector{Registry.RegistryIn
# Fixed packages are not returned by resolve (they already have their version set)
pkg.version = vers[pkg.uuid]
else
name = is_stdlib(uuid) ? stdlibs()[uuid] : registered_name(registries, uuid)
name = is_stdlib(uuid) ? first(stdlibs()[uuid]) : registered_name(registries, uuid)
push!(pkgs, PackageSpec(;name=name, uuid=uuid, version=ver))
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/REPLMode/completions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function complete_add_dev(options, partial, i1, i2)
end
comps = vcat(comps, sort(complete_remote_package(partial)))
if !isempty(partial)
append!(comps, filter!(startswith(partial), collect(values(Types.stdlibs()))))
append!(comps, filter!(startswith(partial), first.(values(Types.stdlibs()))))
end
return comps, idx, !isempty(comps)
end
Expand Down
17 changes: 11 additions & 6 deletions src/Types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -380,16 +380,18 @@ is_project_uuid(env::EnvCache, uuid::UUID) = project_uuid(env) == uuid
# Context #
###########

const STDLIB = Ref{Dict{UUID,String}}()
const STDLIB = Ref{Dict{UUID,Tuple{String,Union{VersionNumber,Nothing}}}}()
function load_stdlib()
stdlib = Dict{UUID,String}()
stdlib = Dict{UUID,Tuple{String,Union{VersionNumber,Nothing}}}()
for name in readdir(stdlib_dir())
projfile = projectfile_path(stdlib_path(name); strict=true)
nothing === projfile && continue
project = parse_toml(projfile)
uuid = get(project, "uuid", nothing)
v_str = get(project, "version", nothing)
version = isnothing(v_str) ? nothing : VersionNumber(v_str)
nothing === uuid && continue
stdlib[UUID(uuid)] = name
stdlib[UUID(uuid)] = (name, version)
end
return stdlib
end
Expand All @@ -405,7 +407,10 @@ is_stdlib(uuid::UUID) = uuid in keys(stdlibs())
# Find the entry in `STDLIBS_BY_VERSION`
# that corresponds to the requested version, and use that.
# If we can't find one, defaults to `UNREGISTERED_STDLIBS`
function get_last_stdlibs(julia_version::VersionNumber)
function get_last_stdlibs(julia_version::VersionNumber; use_historical_for_current_version = false)
if !use_historical_for_current_version && julia_version == VERSION
return stdlibs()
end
last_stdlibs = UNREGISTERED_STDLIBS
for (version, stdlibs) in STDLIBS_BY_VERSION
if VersionNumber(julia_version.major, julia_version.minor, julia_version.patch) < version
Expand Down Expand Up @@ -894,12 +899,12 @@ function stdlib_resolve!(pkgs::AbstractVector{PackageSpec})
for pkg in pkgs
@assert has_name(pkg) || has_uuid(pkg)
if has_name(pkg) && !has_uuid(pkg)
for (uuid, name) in stdlibs()
for (uuid, (name, version)) in stdlibs()
name == pkg.name && (pkg.uuid = uuid)
end
end
if !has_name(pkg) && has_uuid(pkg)
name = get(stdlibs(), pkg.uuid, nothing)
name, version = get(stdlibs(), pkg.uuid, (nothing, nothing))
nothing !== name && (pkg.name = name)
end
end
Expand Down
8 changes: 3 additions & 5 deletions test/new.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2734,15 +2734,13 @@ using Pkg.Types: is_stdlib
end

@testset "STDLIBS_BY_VERSION up-to-date" begin
last_stdlibs = Pkg.Types.get_last_stdlibs(VERSION)
# Drop version numbers
last_stdlibs = Dict(uuid => name for (uuid, (name, vers)) in last_stdlibs)
last_stdlibs = Pkg.Types.get_last_stdlibs(VERSION, use_historical_for_current_version = true)
test_result = last_stdlibs == Pkg.Types.load_stdlib()
if !test_result
@error("STDLIBS_BY_VERSION out of date! Manually fix given the info below, or re-run generate_historical_stdlibs.jl!")
@show length(last_stdlibs) length(Pkg.Types.load_stdlib())
@show setdiff(last_stdlibs, Pkg.Types.load_stdlib())
@show setdiff(Pkg.Types.load_stdlib(), last_stdlibs)
@info "Current stdlib info (sorted):"
show(stdout, "text/plain", collect(sort(collect(pairs(Pkg.Types.load_stdlib())), by=(s->s[2][1]))))
end
@test test_result
end
Expand Down
13 changes: 13 additions & 0 deletions test/resolve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -508,4 +508,17 @@ end
end
end

@testset "Stdlib resolve smoketest" begin
# All stdlibs should be installable and resolvable
temp_pkg_dir() do dir
Pkg.activate(temp=true)
Pkg.add(map(first, values(Pkg.Types.load_stdlib()))) # add all stdlibs
iob = IOBuffer()
Pkg.resolve(io = iob)
str = String(take!(iob))
@test occursin(r"No Changes to .*Project.toml", str)
@test occursin(r"No Changes to .*Manifest.toml", str)
end
end

end # module