Skip to content

Commit

Permalink
[Prefix] Fix installation of packages in nightly (#227)
Browse files Browse the repository at this point in the history
* [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}`.
  • Loading branch information
giordano authored Mar 1, 2022
1 parent f78a16a commit c3a4012
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
18 changes: 16 additions & 2 deletions src/Prefix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,20 @@ function get_addable_spec(name::AbstractString, version::VersionNumber;
)
end

# Helper function to install packages also in Julia v1.9
function Pkg_add(args...; kwargs...)
if VERSION < v"1.9.0-DEV"
Pkg.add(args...; kwargs...)
else
try
Pkg.respect_sysimage_versions(false)
Pkg.add(args...; kwargs...)
finally
Pkg.respect_sysimage_versions(true)
end
end
end

"""
setup_dependencies(prefix::Prefix, dependencies::Vector{PackageSpec}, platform::AbstractPlatform; verbose::Bool = false)
Expand Down Expand Up @@ -586,7 +600,7 @@ function setup_dependencies(prefix::Prefix,
update_registry(outs)

# Add all dependencies
Pkg.add(ctx, dependencies; platform=platform, io=outs)
Pkg_add(ctx, dependencies; platform=platform, io=outs)

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

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

# Load their Artifacts.toml files
Expand Down
20 changes: 12 additions & 8 deletions test/dependencies.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ end
jdep_buildver = JSON.lower(dep_buildver)
@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"])
# the build_version is currently not serialized, so the following test fails
@test_broken dependencify(jdep_buildver) == dep_buildver
@test dependencify(jdep_buildver) == dep_buildver broken=true

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

if os(platform) == "macos"
zlib_log_files = ["Zlib.log.gz", "fix_identity_mismatch_libz.1.2.11.dylib.log.gz", "ldid_libz.1.2.11.dylib.log.gz"]
zlib_log_files = if os(platform) == "macos"
["Zlib.log.gz", "fix_identity_mismatch_libz.1.2.11.dylib.log.gz", "ldid_libz.1.2.11.dylib.log.gz"]
else
zlib_log_files = ["Zlib.log.gz"]
["Zlib.log.gz"]
end
@test readdir(joinpath(destdir(dir, platform), "logs")) == zlib_log_files
@test sort!(readdir(joinpath(destdir(dir, platform), "logs"))) == zlib_log_files

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

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

0 comments on commit c3a4012

Please sign in to comment.