From 155f7a487d4d5bdaf53c4133feb01766a07c41f2 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Sun, 16 Feb 2025 10:23:01 -0500 Subject: [PATCH 01/11] use julia_version kwarg rather than ctx --- src/Prefix.jl | 14 +++++++------- test/dependencies.jl | 6 ++---- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/Prefix.jl b/src/Prefix.jl index 2e67c792..83b55637 100644 --- a/src/Prefix.jl +++ b/src/Prefix.jl @@ -597,7 +597,8 @@ function get_addable_spec(name::AbstractString, version::VersionNumber; uuid=uuid, #version=version, tree_hash=tree_hash_sha1, - repo=Pkg.Types.GitRepo(rev=git_commit_sha, source=valid_url), + rev=git_commit_sha, + url=valid_url, ) end @@ -669,18 +670,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: . - 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 @@ -718,7 +717,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 diff --git a/test/dependencies.jl b/test/dependencies.jl index 9f79f393..9c13cc0a 100644 --- a/test/dependencies.jl +++ b/test/dependencies.jl @@ -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 From 3375fcadd3d503af47ad20aecb4c300193975f84 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Sun, 23 Feb 2025 21:50:53 -0500 Subject: [PATCH 02/11] disable auto-precompilation on Pkg.add --- src/Prefix.jl | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Prefix.jl b/src/Prefix.jl index 83b55637..5d72a199 100644 --- a/src/Prefix.jl +++ b/src/Prefix.jl @@ -604,14 +604,18 @@ 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 From 9a9d48f49a691c19609bdbd8a81fa08cc9289218 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Tue, 25 Feb 2025 11:41:56 -0500 Subject: [PATCH 03/11] add __version fix --- src/Dependencies.jl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Dependencies.jl b/src/Dependencies.jl index b76ccf75..2e52ad32 100644 --- a/src/Dependencies.jl +++ b/src/Dependencies.jl @@ -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) From 07f0cf92eccf132f7ef4237f8bec64ce2ec23855 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Tue, 25 Feb 2025 12:00:22 -0500 Subject: [PATCH 04/11] fix tests --- test/dependencies.jl | 50 ++++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 30 deletions(-) diff --git a/test/dependencies.jl b/test/dependencies.jl index 9c13cc0a..752c6408 100644 --- a/test/dependencies.jl +++ b/test/dependencies.jl @@ -367,40 +367,30 @@ end end @testset "PackageSpec with version" begin + platform = Platform("x86_64", "linux"; libc="musl", cxxstring_abi="cxx11") # 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 - else - # For previous versions we don't expect errors and we - # want to see them. - rethrow() - end - end + @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) + ] + test_setup_dependencies(prefix, dependencies, platform) + # 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" + end + end + @testset "should error if build is missing from a specific VersionNumber" begin + with_temp_project() do dir + prefix = Prefix(dir) + dependencies = [ + PackageSpec(; name="CMake_jll", version = v"3.24.3") + ] + @test_throws test_setup_dependencies(prefix, dependencies, platform) 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" end end - end end From 78b4a3767004bc87e71f81857f58197501a7cfcf Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Tue, 25 Feb 2025 12:17:53 -0500 Subject: [PATCH 05/11] fix test_throws --- test/dependencies.jl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/dependencies.jl b/test/dependencies.jl index 752c6408..ef965caa 100644 --- a/test/dependencies.jl +++ b/test/dependencies.jl @@ -387,7 +387,9 @@ end dependencies = [ PackageSpec(; name="CMake_jll", version = v"3.24.3") ] - @test_throws test_setup_dependencies(prefix, dependencies, platform) + # Pkg needs improve its error message here, but assume that it will still throw a pkgerror + # https://github.com/JuliaLang/Pkg.jl/issues/4159 + @test_throws PKG_VERSIONS.PkgError test_setup_dependencies(prefix, dependencies, platform) end end end From be87e43183059ca578e5e6162b8aa488bf2c16ff Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Tue, 25 Feb 2025 12:30:19 -0500 Subject: [PATCH 06/11] Update dependencies.jl --- test/dependencies.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/dependencies.jl b/test/dependencies.jl index ef965caa..5e9803a0 100644 --- a/test/dependencies.jl +++ b/test/dependencies.jl @@ -389,7 +389,7 @@ end ] # Pkg needs improve its error message here, but assume that it will still throw a pkgerror # https://github.com/JuliaLang/Pkg.jl/issues/4159 - @test_throws PKG_VERSIONS.PkgError test_setup_dependencies(prefix, dependencies, platform) + @test_throws Pkg.Types.PkgError test_setup_dependencies(prefix, dependencies, platform) end end end From 7673b394ff9d3c394d127ea1b3a1c5d520fe9ca9 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Tue, 25 Feb 2025 12:50:03 -0500 Subject: [PATCH 07/11] narrow test to julia_version=nothing --- test/dependencies.jl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/dependencies.jl b/test/dependencies.jl index 5e9803a0..5d9220f9 100644 --- a/test/dependencies.jl +++ b/test/dependencies.jl @@ -367,7 +367,6 @@ end end @testset "PackageSpec with version" begin - platform = Platform("x86_64", "linux"; libc="musl", cxxstring_abi="cxx11") # Install a dependency with a specific version number. @testset for version in (v"3.24.3+0", "3.24.3") with_temp_project() do dir @@ -375,18 +374,20 @@ end 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 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" end end - @testset "should error if build is missing from a specific VersionNumber" begin + @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 @test_throws Pkg.Types.PkgError test_setup_dependencies(prefix, dependencies, platform) From 955144ff9b86c34edd3af41bce76409383c7253a Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Tue, 25 Feb 2025 13:12:19 -0500 Subject: [PATCH 08/11] handle different error types --- test/dependencies.jl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/dependencies.jl b/test/dependencies.jl index 5d9220f9..193b1a56 100644 --- a/test/dependencies.jl +++ b/test/dependencies.jl @@ -388,9 +388,13 @@ end 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 - @test_throws Pkg.Types.PkgError test_setup_dependencies(prefix, dependencies, platform) + # 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 = VERSION >= v"1.13.0-0" ? Pkg.Types.PkgError : MethodError + @test_throws error_type test_setup_dependencies(prefix, dependencies, platform) end end end From 0d67224a5c1ef6f5162a243e6ac41904423028cb Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Tue, 25 Feb 2025 13:18:27 -0500 Subject: [PATCH 09/11] unbroken fixed test --- test/dependencies.jl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/dependencies.jl b/test/dependencies.jl index 193b1a56..ede1371e 100644 --- a/test/dependencies.jl +++ b/test/dependencies.jl @@ -377,8 +377,7 @@ end 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 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" + @test readdir(joinpath(destdir(dir, platform), "bin")) == ["c_rehash", "cmake", "cpack", "ctest", "openssl"] end end @testset "should error if build is missing from a specific VersionNumber, with `julia_version=nothing`" begin From df79b11fb64d9ecea096ece23d84d73294265e30 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Tue, 25 Feb 2025 13:59:19 -0500 Subject: [PATCH 10/11] directly test setup_dependencies --- test/dependencies.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/dependencies.jl b/test/dependencies.jl index ede1371e..f4579c69 100644 --- a/test/dependencies.jl +++ b/test/dependencies.jl @@ -393,7 +393,7 @@ end # 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 = VERSION >= v"1.13.0-0" ? Pkg.Types.PkgError : MethodError - @test_throws error_type test_setup_dependencies(prefix, dependencies, platform) + @test_throws error_type setup_dependencies(prefix, dependencies, platform) end end end From 6119de1cfc30ba42193a2e1a81661643e7d3e4fd Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Tue, 25 Feb 2025 14:23:10 -0500 Subject: [PATCH 11/11] dial in the tests --- test/dependencies.jl | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/test/dependencies.jl b/test/dependencies.jl index f4579c69..dc8dcfb5 100644 --- a/test/dependencies.jl +++ b/test/dependencies.jl @@ -380,21 +380,33 @@ end @test readdir(joinpath(destdir(dir, platform), "bin")) == ["c_rehash", "cmake", "cpack", "ctest", "openssl"] end end - @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 = VERSION >= v"1.13.0-0" ? Pkg.Types.PkgError : MethodError - @test_throws error_type setup_dependencies(prefix, dependencies, platform) + 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 + KeyError + end + @test_throws error_type setup_dependencies(prefix, dependencies, platform) + end end + 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