From b8a61e3493dcc3a3e38abcee56e43f559322f432 Mon Sep 17 00:00:00 2001 From: Kristoffer Date: Wed, 23 Feb 2022 21:19:53 +0100 Subject: [PATCH 1/3] respect versions in sysimage --- CHANGELOG.md | 7 +++++++ docs/src/api.md | 1 + src/Operations.jl | 24 +++++++++++++++++++++++- src/Pkg.jl | 14 ++++++++++++++ src/Resolve/graphtype.jl | 6 ++++++ src/Types.jl | 20 ++++++++++++++++++-- test/new.jl | 39 ++++++++++++++++++++++++++++++++++++++- 7 files changed, 107 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b26b36842..24a00d2bff 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. + 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 9bb6e5584d..f2c3a5f3e3 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 # @@ -389,6 +389,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}() @@ -456,6 +457,17 @@ 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 + pkgid = Base.PkgId(uuid, pkg.name) + if PKGORIGIN_HAVE_VERSION && RESPECT_SYSIMAGE_VERSIONS[] && Base.in_sysimage(pkgid) + pkgorigin = get(Base.pkgorigins, pkgid, nothing) + if pkgorigin !== nothing && pkgorigin.version !== nothing + if v !== pkgorigin.version + continue + end + end + end + all_compat_u[v] = compat_info union!(uuids, keys(compat_info)) end @@ -1857,6 +1869,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 @@ -2055,6 +2075,8 @@ function print_status(env::EnvCache, old_env::Union{Nothing,EnvCache}, registrie printstyled(io, " ( Date: Sat, 26 Feb 2022 14:52:09 +0100 Subject: [PATCH 2/3] only respect sysimage if `julia_version` is not set --- src/Operations.jl | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Operations.jl b/src/Operations.jl index f2c3a5f3e3..e8f7992870 100644 --- a/src/Operations.jl +++ b/src/Operations.jl @@ -458,12 +458,14 @@ function deps_graph(env::EnvCache, registries::Vector{Registry.RegistryInstance} end # Skip package version that are not the same as external packages in sysimage - pkgid = Base.PkgId(uuid, pkg.name) - if PKGORIGIN_HAVE_VERSION && RESPECT_SYSIMAGE_VERSIONS[] && Base.in_sysimage(pkgid) - pkgorigin = get(Base.pkgorigins, pkgid, nothing) - if pkgorigin !== nothing && pkgorigin.version !== nothing - if v !== pkgorigin.version - continue + 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 From 8e77c68157160cd60efc5cdb4f788b033f23b390 Mon Sep 17 00:00:00 2001 From: Kristoffer Carlsson Date: Sat, 26 Feb 2022 16:19:25 +0100 Subject: [PATCH 3/3] Add how to disable --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24a00d2bff..066210dc66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ 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. + 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 ======================