Skip to content

Commit c3a4012

Browse files
authored
[Prefix] Fix installation of packages in nightly (#227)
* [Prefix] Fix installation of packages in nightly With Julia v1.9 we have to use `Pkg.respect_sysimage_versions(false)` to install stdlib JLLs in our projects. * Fix now broken test as such Changes in the new tarballs of LibCURL and other packages means that `cleanup_dependencies` can't remove all directories. This is similar to the problem we have already inside `${includedir}`.
1 parent f78a16a commit c3a4012

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

src/Prefix.jl

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,20 @@ function get_addable_spec(name::AbstractString, version::VersionNumber;
537537
)
538538
end
539539

540+
# Helper function to install packages also in Julia v1.9
541+
function Pkg_add(args...; kwargs...)
542+
if VERSION < v"1.9.0-DEV"
543+
Pkg.add(args...; kwargs...)
544+
else
545+
try
546+
Pkg.respect_sysimage_versions(false)
547+
Pkg.add(args...; kwargs...)
548+
finally
549+
Pkg.respect_sysimage_versions(true)
550+
end
551+
end
552+
end
553+
540554
"""
541555
setup_dependencies(prefix::Prefix, dependencies::Vector{PackageSpec}, platform::AbstractPlatform; verbose::Bool = false)
542556
@@ -586,7 +600,7 @@ function setup_dependencies(prefix::Prefix,
586600
update_registry(outs)
587601

588602
# Add all dependencies
589-
Pkg.add(ctx, dependencies; platform=platform, io=outs)
603+
Pkg_add(ctx, dependencies; platform=platform, io=outs)
590604

591605
# Ony Julia v1.6, `Pkg.add()` doesn't mutate `dependencies`, so we can't use the `UUID`
592606
# that was found during resolution there. Instead, we'll make use of `ctx.env` to figure
@@ -628,7 +642,7 @@ function setup_dependencies(prefix::Prefix,
628642

629643
# Re-install stdlib dependencies, but this time with `julia_version = nothing`
630644
if !isempty(stdlib_pkgspecs)
631-
Pkg.add(ctx, stdlib_pkgspecs; io=outs, julia_version=nothing)
645+
Pkg_add(ctx, stdlib_pkgspecs; io=outs, julia_version=nothing)
632646
end
633647

634648
# Load their Artifacts.toml files

test/dependencies.jl

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ end
8888
jdep_buildver = JSON.lower(dep_buildver)
8989
@test jdep_buildver == Dict("type" => "dependency", "name" => name, "uuid" => nothing, "compat" => "~1.2", "version-major" => 0x0, "version-minor" => 0x0, "version-patch" => 0x0, "platforms" => ["x86_64-linux-gnu-cxx11"])
9090
# the build_version is currently not serialized, so the following test fails
91-
@test_broken dependencify(jdep_buildver) == dep_buildver
91+
@test dependencify(jdep_buildver) == dep_buildver broken=true
9292

9393
jbuild_dep = JSON.lower(build_dep)
9494
@test jbuild_dep == Dict("type" => "builddependency", "name" => build_name, "uuid" => nothing, "compat" => "", "version-major" => 0x0, "version-minor" => 0x0, "version-patch" => 0x0, "platforms" => ["any"])
@@ -126,14 +126,14 @@ end
126126
platform = HostPlatform()
127127
ap = @test_logs setup_dependencies(prefix, getpkg.(dependencies), platform)
128128
@test "libz." * platform_dlext(platform) in readdir(last(libdirs(Prefix(destdir(dir, platform)))))
129-
@test "zlib.h" in readdir(joinpath(destdir(dir, platform), "include"))
129+
@test sort!(readdir(joinpath(destdir(dir, platform), "include"))) == ["zconf.h", "zlib.h"]
130130

131-
if os(platform) == "macos"
132-
zlib_log_files = ["Zlib.log.gz", "fix_identity_mismatch_libz.1.2.11.dylib.log.gz", "ldid_libz.1.2.11.dylib.log.gz"]
131+
zlib_log_files = if os(platform) == "macos"
132+
["Zlib.log.gz", "fix_identity_mismatch_libz.1.2.11.dylib.log.gz", "ldid_libz.1.2.11.dylib.log.gz"]
133133
else
134-
zlib_log_files = ["Zlib.log.gz"]
134+
["Zlib.log.gz"]
135135
end
136-
@test readdir(joinpath(destdir(dir, platform), "logs")) == zlib_log_files
136+
@test sort!(readdir(joinpath(destdir(dir, platform), "logs"))) == zlib_log_files
137137

138138
# Make sure the directories are emptied by `cleanup_dependencies`
139139
@test_nowarn cleanup_dependencies(prefix, ap, platform)
@@ -156,8 +156,12 @@ end
156156
# Make sure the directories are emptied by `cleanup_dependencies`
157157
@test_nowarn cleanup_dependencies(prefix, ap, platform)
158158
# This shuld be empty, but the `curl/` directory is left here, empty
159-
@test_broken readdir(joinpath(destdir(dir, platform), "include")) == []
160-
@test readdir(joinpath(destdir(dir, platform), "logs")) == []
159+
@test readdir(joinpath(destdir(dir, platform), "include")) == [] broken=true
160+
# Since Julia v1.9 we use builds of LibCURL and its dependencies which have logs
161+
# in subdirectories of `${prefix}/logs`, so we have the same problem as above:
162+
# those subdirectories are left there empty, cannot be removed by
163+
# `cleanup_dependencies`.
164+
@test readdir(joinpath(destdir(dir, platform), "logs")) == [] broken=VERSIONv"1.9.0-DEV"
161165
end
162166

163167
# Setup a dependency that doesn't have a mapping for the given platform

0 commit comments

Comments
 (0)