From 123cadff450470d5e51017e035a8f2057741a125 Mon Sep 17 00:00:00 2001 From: Panagiotis Georgakopoulos Date: Thu, 29 Feb 2024 14:28:44 +0530 Subject: [PATCH] feat: avoid adding packages that exist in the sysimage --- src/packages/Packages.jl | 2 +- src/packages/PkgCompat.jl | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/packages/Packages.jl b/src/packages/Packages.jl index 2e74e7cbaa..461a7df87e 100644 --- a/src/packages/Packages.jl +++ b/src/packages/Packages.jl @@ -106,7 +106,7 @@ function sync_nbpkg_core( new_packages = String.(external_package_names(new_topology)) # search all cells for imports and usings removed = setdiff(old_packages, new_packages) - added = setdiff(new_packages, old_packages) + added = setdiff(new_packages, old_packages, PkgCompat.sysimage_module_names()) # Avoid adding the modules of the sysimage can_skip = isempty(removed) && isempty(added) && notebook.nbpkg_ctx_instantiated iolistener = let diff --git a/src/packages/PkgCompat.jl b/src/packages/PkgCompat.jl index f0e857fc00..d20b6de33a 100644 --- a/src/packages/PkgCompat.jl +++ b/src/packages/PkgCompat.jl @@ -401,6 +401,14 @@ function project(ctx::PkgContext) end end +function sysimage_module_names() + @static if isdefined(Base, Symbol("_sysimage_modules")) + getproperty.(Base._sysimage_modules, :name) + else + String[] + end +end + # 🐸 "Public API", but using PkgContext "Find a package in the manifest. Return `nothing` if not found." _get_manifest_entry(ctx::PkgContext, package_name::AbstractString) =