@@ -22,7 +22,7 @@ using SHA
2222
2323export 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`
408409function 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
417418end
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
420425function 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)
441435end
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+
443449is_unregistered_stdlib (uuid:: UUID ) = haskey (UNREGISTERED_STDLIBS, uuid)
444450
445451Context! (kw_context:: Vector{Pair{Symbol,Any}} ):: Context =
0 commit comments