From bab306bda8670bf55af8184884e79604c81931e8 Mon Sep 17 00:00:00 2001 From: Kristoffer Carlsson Date: Sat, 26 Feb 2022 21:41:05 +0100 Subject: [PATCH] respect versions in sysimage (#3002) (cherry picked from commit 31af27451035511c9b245061d9e743ed549f39fa) --- CHANGELOG.md | 7 +++++++ docs/src/api.md | 1 + src/Operations.jl | 26 +++++++++++++++++++++++++- src/Pkg.jl | 14 ++++++++++++++ src/Resolve/graphtype.jl | 6 ++++++ src/Types.jl | 20 ++++++++++++++++++-- test/new.jl | 39 ++++++++++++++++++++++++++++++++++++++- 7 files changed, 109 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b26b36842..066210dc66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +Pkg v1.9 Release Notes +======================= + +- Pkg will now respect the version of packages put into the sysimage using e.g. PackageCompiler. For example, + if version 1.3.2 of package A is in the sysimage, Pkg will always install that version when adding the package, + or when the packge is installed as a dependency to some other package. This can be disabled by calling `Pkg.respect_sysimage_versions(false)`. + Pkg v1.8 Release Notes ====================== diff --git a/docs/src/api.md b/docs/src/api.md index cd0c636086..cb6e203ab3 100644 --- a/docs/src/api.md +++ b/docs/src/api.md @@ -43,6 +43,7 @@ Pkg.status Pkg.compat Pkg.precompile Pkg.offline +Pkg.respect_sysimage_versions Pkg.setprotocol! Pkg.dependencies Pkg.project diff --git a/src/Operations.jl b/src/Operations.jl index c8f37bd964..0ae2df86a9 100644 --- a/src/Operations.jl +++ b/src/Operations.jl @@ -14,7 +14,7 @@ import ..Artifacts: ensure_artifact_installed, artifact_names, extract_all_hashe artifact_exists, select_downloadable_artifacts using Base.BinaryPlatforms import ...Pkg -import ...Pkg: pkg_server, Registry, pathrepr, can_fancyprint, printpkgstyle, stderr_f, OFFLINE_MODE, UPDATED_REGISTRY_THIS_SESSION +import ...Pkg: pkg_server, Registry, pathrepr, can_fancyprint, printpkgstyle, stderr_f, OFFLINE_MODE, UPDATED_REGISTRY_THIS_SESSION, RESPECT_SYSIMAGE_VERSIONS ######### # Utils # @@ -392,6 +392,7 @@ end get_or_make!(d::Dict{K,V}, k::K) where {K,V} = get!(d, k) do; V() end const JULIA_UUID = UUID("1222c4b2-2114-5bfd-aeef-88e4692bbb3e") +const PKGORIGIN_HAVE_VERSION = :version in fieldnames(Base.PkgOrigin) function deps_graph(env::EnvCache, registries::Vector{Registry.RegistryInstance}, uuid_to_name::Dict{UUID,String}, reqs::Resolve.Requires, fixed::Dict{UUID,Resolve.Fixed}, julia_version) uuids = Set{UUID}() @@ -459,6 +460,19 @@ function deps_graph(env::EnvCache, registries::Vector{Registry.RegistryInstance} is_package_downloaded(env.project_file, pkg_spec) || continue end + # Skip package version that are not the same as external packages in sysimage + if PKGORIGIN_HAVE_VERSION && RESPECT_SYSIMAGE_VERSIONS[] && julia_version == VERSION + pkgid = Base.PkgId(uuid, pkg.name) + if Base.in_sysimage(pkgid) + pkgorigin = get(Base.pkgorigins, pkgid, nothing) + if pkgorigin !== nothing && pkgorigin.version !== nothing + if v != pkgorigin.version + continue + end + end + end + end + all_compat_u[v] = compat_info union!(uuids, keys(compat_info)) end @@ -1859,6 +1873,14 @@ function status_compat_info(pkg::PackageSpec, env::EnvCache, regs::Vector{Regist max_version == v"0" && return nothing pkg.version >= max_version && return nothing + pkgid = Base.PkgId(pkg.uuid, pkg.name) + if PKGORIGIN_HAVE_VERSION && RESPECT_SYSIMAGE_VERSIONS[] && Base.in_sysimage(pkgid) + pkgorigin = get(Base.pkgorigins, pkgid, nothing) + if pkgorigin !== nothing && pkg.version !== nothing && pkg.version == pkgorigin.version + return ["sysimage"], max_version, max_version_in_compat + end + end + # Check compat of project if pkg.version == max_version_in_compat && max_version_in_compat != max_version return ["compat"], max_version, max_version_in_compat @@ -2057,6 +2079,8 @@ function print_status(env::EnvCache, old_env::Union{Nothing,EnvCache}, registrie printstyled(io, " (