Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ jobs:
squashfs: true
julia-version: "1.11"

# - runner: privileged
# squashfs: true
# julia-version: "nightly"
- runner: privileged
squashfs: true
julia-version: "nightly"

# Add a job that uses the unprivileged builder with unpacked shards
- runner: unprivileged
Expand Down
3 changes: 3 additions & 0 deletions src/Dependencies.jl
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,9 @@ patch(v::VersionNumber) = v.patch
major(v::Pkg.Types.VersionBound) = v.t[1]
minor(v::Pkg.Types.VersionBound) = v.t[2]
patch(v::Pkg.Types.VersionBound) = v.t[3]

# If a version in a PackageSpec is given as a string it signifies being a VersionSpec that Pkg will handle as such.
__version(v::AbstractString) = __version(PKG_VERSIONS.VersionSpec(v))
__version(v::VersionNumber) = v
__version(v::PKG_VERSIONS.VersionSpec) = v.ranges[1].lower
version(d::AbstractDependency) = __version(getpkg(d).version)
Expand Down
42 changes: 24 additions & 18 deletions src/Prefix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,10 @@ function setup(source::SetupSource{ArchiveSource}, targetdir, verbose; tar_flags
libpath = vcat(XZ_jll.LIBPATH_list, libpath)
end
if Zstd_jll.is_available()
path = vcat(dirname(Zstd_jll.zstd_path), path)
libpath = vcat(XZ_jll.LIBPATH_list, libpath)
# Zstd_jll became a stdlib in Julia v1.13.0 and the path variable changed name
zpath = isdefined(Zstd_jll, :libzstd_path) ? Zstd_jll.libzstd_path : Zstd_jll.zstd_path
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sigh. But also, this doesn't look right: the library and the executable are in two different directories.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For others following along: JuliaLang/julia#59198
Just need to wait for nightly to be 1a1270d977ba8aab7fcefe0d652f493bcc3dc44e

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

path = vcat(dirname(zpath), path)
libpath = vcat(Zstd_jll.LIBPATH_list, libpath)
end
unique!(filter!(!isempty, path))
unique!(filter!(!isempty, libpath))
Expand Down Expand Up @@ -608,22 +610,27 @@ function get_addable_spec(name::AbstractString, version::VersionNumber;
return Pkg.Types.PackageSpec(
name=name,
uuid=uuid,
#version=version,
# version=version, # cannot set this because build_tarballs will complain
tree_hash=tree_hash_sha1,
repo=Pkg.Types.GitRepo(rev=git_commit_sha, source=valid_url),
rev=git_commit_sha,
url=valid_url,
)
end

# Helper function to install packages also in Julia v1.8
function Pkg_add(args...; kwargs...)
@static if VERSION < v"1.8.0"
Pkg.add(args...; kwargs...)
else
try
Pkg.respect_sysimage_versions(false)
# we don't want to precompile packages during installation
# auto-precompilation also calls `Pkg.instantiate` which will warn about non-VERSION `julia_version` values
withenv("JULIA_PKG_PRECOMPILE_AUTO" => "false") do
@static if VERSION < v"1.8.0"
Pkg.add(args...; kwargs...)
finally
Pkg.respect_sysimage_versions(true)
else
try
Pkg.respect_sysimage_versions(false)
Pkg.add(args...; kwargs...)
finally
Pkg.respect_sysimage_versions(true)
end
end
end
end
Expand Down Expand Up @@ -662,7 +669,7 @@ function setup_dependencies(prefix::Prefix,
# We occasionally generate "illegal" package specs, where we provide both version and tree hash.
# we trust the treehash over the version, so drop the version for any that exists here:
function filter_redundant_version(p::PkgSpec)
if p.version !== nothing && p.tree_hash !== nothing
if p.version != PKG_VERSIONS.VersionSpec("*") && p.tree_hash !== nothing
return Pkg.Types.PackageSpec(;name=p.name, tree_hash=p.tree_hash, repo=p.repo)
end
Comment on lines -665 to 742
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was wrong, it's not nothing when unset.

julia> pspec = Pkg.PackageSpec(
           name = "LLVM_full_jll",
           uuid = Base.UUID("a3ccf953-465e-511d-b87f-60a6490c289d"),
           tree_hash = Pkg.Types.SHA1("14aa3ea8eb237d341af4f4571d91d17453d88d41"),
           url = "https://github.com/JuliaBinaryWrappers/LLVM_full_jll.jl.git",
           rev = "b0a36286a6a0e6f70324ceec1958a2bb494acdb4"
       )
PackageSpec(
  name = LLVM_full_jll
  uuid = a3ccf953-465e-511d-b87f-60a6490c289d
  tree_hash = 14aa3ea8eb237d341af4f4571d91d17453d88d41
  url = https://github.com/JuliaBinaryWrappers/LLVM_full_jll.jl.git
  rev = b0a36286a6a0e6f70324ceec1958a2bb494acdb4
  version = *
)

julia> pspec.version
VersionSpec("*")

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a regression test mentioning BBB in Pkg JuliaLang/Pkg.jl#4332

return p
Expand All @@ -682,18 +689,16 @@ function setup_dependencies(prefix::Prefix,
deps_project = joinpath(prefix, triplet(platform), ".project")
Pkg.activate(deps_project) do
# Update registry first, in case the jll packages we're looking for have just been registered/updated
ctx = Pkg.Types.Context(;julia_version)
outs = verbose ? stdout : devnull
update_registry(outs)

# Add all dependencies. Note: Pkg.add(ctx, deps) modifies in-place `deps` without
# notice. We need to `deepcopy` the argument to prevent it from modying our
# dependencies from under our feet: <https://github.com/JuliaLang/Pkg.jl/issues/3112>.
Pkg_add(ctx, deepcopy(dependencies); platform=platform, io=outs)
# Add all dependencies.
Pkg_add(dependencies; platform=platform, io=outs, julia_version=julia_version)

# 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
# out the UUIDs of all our packages.
ctx = Pkg.Types.Context()
dependency_uuids = Set([uuid for (uuid, pkg) in ctx.env.manifest if pkg.name ∈ dependencies_names])

# Some JLLs are also standard libraries that may be present in the manifest because
Expand Down Expand Up @@ -731,7 +736,8 @@ 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)
# TODO: shouldn't this take platform?
Pkg_add(stdlib_pkgspecs; io=outs, julia_version=nothing)
end

# Load their Artifacts.toml files
Expand Down
68 changes: 37 additions & 31 deletions test/dependencies.jl
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,8 @@ end
uuid="86de99a1-58d6-5da7-8064-bd56ce2e322c",
tree_hash=Base.SHA1("83481d62501cf2ef22bed745dbcedc4e75fa6e95"),
version=PKG_VERSIONS.VersionSpec("*"),
repo=Pkg.Types.GitRepo(
source="https://github.com/JuliaBinaryWrappers/LLVM_jll.jl.git",
rev="2772761b330d51146ace3125b26acdad0df4f30f",
),
url="https://github.com/JuliaBinaryWrappers/LLVM_jll.jl.git",
rev="2772761b330d51146ace3125b26acdad0df4f30f",
)

with_temp_project() do dir
Expand Down Expand Up @@ -370,39 +368,47 @@ end

@testset "PackageSpec with version" begin
# Install a dependency with a specific version number.
with_temp_project() do dir
prefix = Prefix(dir)
dependencies = [
PackageSpec(; name="CMake_jll", version = v"3.24.3")
]
platform = Platform("x86_64", "linux"; libc="musl", cxxstring_abi="cxx11")
if v"1.9" <= VERSION < v"1.11"
# For reasons I can't understand, in CI on GitHub Actions (and only
# there, can't reproduce the same behaviour locally) the error thrown
# inside the `setup_dependencies` "escapes" the `try` block. For lack of
# time to debug this stupid thing we just mark this step as broken and
# move on, it's really broken anyway.
@test false broken=true
else
try
test_setup_dependencies(prefix, dependencies, platform)
catch
if VERSION>=v"1.9"
# This test is expected to be broken on Julia v1.9+
@test false broken=true
@testset for version in (v"3.24.3+0", "3.24.3")
with_temp_project() do dir
prefix = Prefix(dir)
dependencies = [
PackageSpec(; name="CMake_jll", version = version)
]
platform = Platform("x86_64", "linux"; libc="musl", cxxstring_abi="cxx11")
test_setup_dependencies(prefix, dependencies, platform)
# The directory contains also executables from CMake dependencies.
@test readdir(joinpath(destdir(dir, platform), "bin")) == ["c_rehash", "cmake", "cpack", "ctest", "openssl"]
end
end
if VERSION >= v"1.9.0-0"
@testset "should error if build is missing from a specific VersionNumber, with `julia_version=nothing`" begin
with_temp_project() do dir
prefix = Prefix(dir)
dependencies = [
PackageSpec(; name="CMake_jll", version = v"3.24.3")
]
platform = Platform("x86_64", "linux"; libc="musl", cxxstring_abi="cxx11", julia_version=nothing)

# Pkg needs improve its error message here, but assume that it will still throw a pkgerror
# https://github.com/JuliaLang/Pkg.jl/issues/4159
# Before https://github.com/JuliaLang/Pkg.jl/pull/4151 this would throw a MethodError for `abspath(::Nothing)`
# So this test will need fixing if/when that gets backported
error_type = if VERSION >= v"1.13.0-0"
Pkg.Types.PkgError
elseif VERSION >= v"1.10.0-0"
MethodError
else
# For previous versions we don't expect errors and we
# want to see them.
rethrow()
KeyError
end
@test_throws error_type setup_dependencies(prefix, dependencies, platform)
end
end
# The directory contains also executables from CMake dependencies.
# Test will fail if `setup_dependencies` above failed.
@test readdir(joinpath(destdir(dir, platform), "bin")) == ["c_rehash", "cmake", "cpack", "ctest", "openssl"] broken=VERSION>=v"1.9"
else
# The above test doesn't throw before v1.9. Unclear why. Pkg misinterpreting a specific (incorrect)
# VersionNumber spec as a VersionSpec?
@test_broken false
end
end

end
end

Expand Down