Skip to content

Commit 1685f44

Browse files
authored
Revert "Revert "Enable installation of versioned historical stdlibs (#2614)" (#2635)" (#2636)
This reverts commit 807e36d.
1 parent 807e36d commit 1685f44

File tree

4 files changed

+52
-36
lines changed

4 files changed

+52
-36
lines changed

src/Operations.jl

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ function update_manifest!(env::EnvCache, pkgs::Vector{PackageSpec}, deps_map, ju
131131
entry = PackageEntry(;name = pkg.name, version = pkg.version, pinned = pkg.pinned,
132132
tree_hash = pkg.tree_hash, path = pkg.path, repo = pkg.repo, uuid=pkg.uuid)
133133
if is_stdlib(pkg.uuid, julia_version)
134-
# do not set version for stdlibs
135-
entry.version = nothing
134+
# Only set stdlib versions for versioned (external) stdlibs
135+
entry.version = stdlib_version(pkg.uuid, julia_version)
136136
end
137137
if Types.is_project(env, pkg)
138138
entry.deps = env.project.deps
@@ -384,6 +384,7 @@ function deps_graph(env::EnvCache, registries::Vector{Registry.RegistryInstance}
384384
union!(uuids, fixed_uuids)
385385
end
386386

387+
stdlibs_for_julia_version = Types.get_last_stdlibs(julia_version)
387388
seen = Set{UUID}()
388389

389390
# pkg -> version -> (dependency => compat):
@@ -399,13 +400,21 @@ function deps_graph(env::EnvCache, registries::Vector{Registry.RegistryInstance}
399400
for uuid in unseen
400401
push!(seen, uuid)
401402
uuid in keys(fixed) && continue
402-
all_compat_u = get_or_make!(all_compat, uuid)
403+
all_compat_u = get_or_make!(all_compat, uuid)
404+
405+
uuid_is_stdlib = false
406+
stdlib_name = ""
407+
stdlib_version = nothing
408+
if haskey(stdlibs_for_julia_version, uuid)
409+
uuid_is_stdlib = true
410+
stdlib_name, stdlib_version = stdlibs_for_julia_version[uuid]
411+
end
403412

404-
# If we're requesting resolution of a package that is an stdlib and is not registered,
405-
# we must special-case it here. This is further complicated by the fact that we can
406-
# ask this question relative to a particular Julia version.
407-
if is_unregistered_stdlib(uuid) || is_stdlib(uuid, julia_version)
408-
path = Types.stdlib_path(stdlibs()[uuid])
413+
# If we're requesting resolution of a package that is an unregistered stdlib (or one
414+
# that tracks no version information) we must special-case it here. This is further
415+
# complicated by the fact that we can ask this question relative to a Julia version.
416+
if is_unregistered_stdlib(uuid) || (uuid_is_stdlib && stdlib_version === nothing)
417+
path = Types.stdlib_path(stdlibs_for_julia_version[uuid][1])
409418
proj_file = projectfile_path(path; strict=true)
410419
@assert proj_file !== nothing
411420
proj = read_package(proj_file)

src/Types.jl

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ using SHA
2222

2323
export UUID, SHA1, VersionRange, VersionSpec,
2424
PackageSpec, PackageEntry, EnvCache, Context, GitRepo, Context!, Manifest, Project, err_rep,
25-
PkgError, pkgerror, has_name, has_uuid, is_stdlib, is_unregistered_stdlib, stdlibs, write_env, write_env_usage, parse_toml, find_registered!,
25+
PkgError, pkgerror, has_name, has_uuid, is_stdlib, stdlib_version, is_unregistered_stdlib, stdlibs, write_env, write_env_usage, parse_toml, find_registered!,
2626
project_resolve!, project_deps_resolve!, manifest_resolve!, registry_resolve!, stdlib_resolve!, handle_repos_develop!, handle_repos_add!, ensure_resolved,
2727
registered_name,
2828
manifest_info,
@@ -405,8 +405,9 @@ is_stdlib(uuid::UUID) = uuid in keys(stdlibs())
405405

406406
# Find the entry in `STDLIBS_BY_VERSION`
407407
# that corresponds to the requested version, and use that.
408+
# If we can't find one, defaults to `UNREGISTERED_STDLIBS`
408409
function get_last_stdlibs(julia_version::VersionNumber)
409-
last_stdlibs = Dict{UUID,String}()
410+
last_stdlibs = UNREGISTERED_STDLIBS
410411
for (version, stdlibs) in STDLIBS_BY_VERSION
411412
if VersionNumber(julia_version.major, julia_version.minor, julia_version.patch) < version
412413
break
@@ -415,6 +416,10 @@ function get_last_stdlibs(julia_version::VersionNumber)
415416
end
416417
return last_stdlibs
417418
end
419+
# If `julia_version` is set to `nothing`, that means (essentially) treat all registered
420+
# stdlibs as normal packages so that we get the latest versions of everything, ignoring
421+
# julia compat. So we set the list of stdlibs to that of only the unregistered stdlibs.
422+
get_last_stdlibs(::Nothing) = UNREGISTERED_STDLIBS
418423

419424
# Allow asking if something is an stdlib for a particular version of Julia
420425
function is_stdlib(uuid::UUID, julia_version::Union{VersionNumber, Nothing})
@@ -423,23 +428,24 @@ function is_stdlib(uuid::UUID, julia_version::Union{VersionNumber, Nothing})
423428
return is_stdlib(uuid)
424429
end
425430

426-
# If this UUID is known to be unregistered, always return `true`
427-
if haskey(UNREGISTERED_STDLIBS, uuid)
428-
return true
429-
end
430-
431-
# Otherwise, if the `julia_version` is `nothing`, all registered stdlibs
432-
# will be treated like normal packages.
433-
if julia_version === nothing
434-
return false
435-
end
436-
437431
last_stdlibs = get_last_stdlibs(julia_version)
438432
# Note that if the user asks for something like `julia_version = 0.7.0`, we'll
439433
# fall through with an empty `last_stdlibs`, which will always return `false`.
440434
return uuid in keys(last_stdlibs)
441435
end
442436

437+
# Return the version of a stdlib with respect to a particular Julia version, or
438+
# `nothing` if that stdlib is not versioned. We only store version numbers for
439+
# stdlibs that are external and thus could be installed from their repositories,
440+
# e.g. things like `GMP_jll`, `Tar`, etc...
441+
function stdlib_version(uuid::UUID, julia_version::Union{VersionNumber,Nothing})
442+
last_stdlibs = get_last_stdlibs(julia_version)
443+
if !(uuid in keys(last_stdlibs))
444+
return nothing
445+
end
446+
return last_stdlibs[uuid][2]
447+
end
448+
443449
is_unregistered_stdlib(uuid::UUID) = haskey(UNREGISTERED_STDLIBS, uuid)
444450

445451
Context!(kw_context::Vector{Pair{Symbol,Any}})::Context =

test/new.jl

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2667,16 +2667,6 @@ end
26672667
return only(deps[name])
26682668
end
26692669

2670-
isolate(loaded_depot=true) do
2671-
# Test that adding `NetworkOptions` results in a `Manifest.toml` with no version
2672-
# which means that it was treated as a standard library
2673-
Pkg.add("NetworkOptions")
2674-
block = get_manifest_block("NetworkOptions")
2675-
@test haskey(block, "uuid")
2676-
@test block["uuid"] == networkoptions_uuid
2677-
@test !haskey(block, "version")
2678-
end
2679-
26802670
isolate(loaded_depot=true) do
26812671
# Next, test that if we ask for `v1.5` it DOES have a version, and that GMP_jll installs v6.1.X
26822672
Pkg.add(["NetworkOptions", "GMP_jll"]; julia_version=v"1.5")
@@ -2698,7 +2688,7 @@ end
26982688
artifacts_toml = joinpath(gmp_jll_dir, "Artifacts.toml")
26992689
@test isfile(artifacts_toml)
27002690
meta = artifact_meta("GMP", artifacts_toml)
2701-
@test meta != nothing
2691+
@test meta !== nothing
27022692

27032693
gmp_artifact_path = artifact_path(Base.SHA1(meta["git-tree-sha1"]))
27042694
@test isdir(gmp_artifact_path)
@@ -2710,8 +2700,22 @@ end
27102700
end
27112701
end
27122702

2703+
# Next, test that if we ask for `v1.6`, GMP_jll gets `v6.2.0`, and for `v1.7`, it gets `v6.2.1`
2704+
function do_gmp_test(julia_version, gmp_version)
2705+
isolate(loaded_depot=true) do
2706+
Pkg.add("GMP_jll"; julia_version)
2707+
gmp_block = get_manifest_block("GMP_jll")
2708+
@test haskey(gmp_block, "uuid")
2709+
@test gmp_block["uuid"] == gmp_jll_uuid
2710+
@test haskey(gmp_block, "version")
2711+
@test startswith(gmp_block["version"], string(gmp_version))
2712+
end
2713+
end
2714+
do_gmp_test(v"1.6", v"6.2.0")
2715+
do_gmp_test(v"1.7", v"6.2.1")
2716+
27132717
isolate(loaded_depot=true) do
2714-
# Next, test that if we ask for `nothing`, NetworkOptions has a `version` but `LinearAlgebra` does.
2718+
# Next, test that if we ask for `nothing`, NetworkOptions has a `version` but `LinearAlgebra` does not.
27152719
Pkg.add(["LinearAlgebra", "NetworkOptions"]; julia_version=nothing)
27162720
no_block = get_manifest_block("NetworkOptions")
27172721
@test haskey(no_block, "uuid")

test/resolve.jl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,8 +435,6 @@ end
435435
return versions[idx]
436436
end
437437

438-
#=
439-
# DISABLED FOR NOW BECAUSE THE JLL INTO STDLIBS BROKE IT
440438
# First, we're going to resolve for specific versions of Julia, ensuring we get the right dep versions:
441439
Pkg.Registry.download_default_registries(Pkg.stdout_f())
442440
ctx = Pkg.Types.Context(;julia_version=v"1.5")
@@ -469,7 +467,6 @@ end
469467
mpfr = find_by_name(versions, "MPFR_jll")
470468
@test mpfr !== nothing
471469
@test mpfr.version.major == 4 && mpfr.version.minor == 0
472-
=#
473470
end
474471
end
475472

0 commit comments

Comments
 (0)