Skip to content

Commit

Permalink
[Prefix] Fix installation of dependencies from local directories (#225)
Browse files Browse the repository at this point in the history
If the provided dependency has already a path, propagate it to the list of
installed JLLs in `setup_dependencies`.
  • Loading branch information
giordano authored Feb 27, 2022
1 parent adda098 commit f78a16a
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "BinaryBuilderBase"
uuid = "7f725544-6523-48cd-82d1-3fa08ff4056e"
authors = ["Elliot Saba <[email protected]>"]
version = "1.6.0"
version = "1.6.1"

[deps]
CodecZlib = "944b1d66-785c-5afd-91f1-9de20f533193"
Expand Down
10 changes: 7 additions & 3 deletions src/Prefix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -603,14 +603,16 @@ function setup_dependencies(prefix::Prefix,
name=pkg.name,
uuid,
tree_hash=pkg.tree_hash,
path=pkg.path,
) for (uuid, pkg) in ctx.env.manifest if uuid installed_jll_uuids
]

# Check for stdlibs lurking in the installed JLLs
stdlib_pkgspecs = PackageSpec[]
for dep in installed_jlls
# If the `tree_hash` is `nothing`, then this JLL was treated as an stdlib
if dep.tree_hash === nothing
# If the dependency doesn't have a path yet and the `tree_hash` is
# `nothing`, then this JLL is probably an stdlib.
if dep.path === nothing && dep.tree_hash === nothing
# Figure out what version this stdlib _should_ be at for this version
dep.version = stdlib_version(dep.uuid, julia_version)

Expand All @@ -632,7 +634,9 @@ function setup_dependencies(prefix::Prefix,
# Load their Artifacts.toml files
for dep in installed_jlls
name = getname(dep)
dep_path = Pkg.Operations.find_installed(name, dep.uuid, dep.tree_hash)
# If the package has a path, use it, otherwise ask Pkg where it
# should have been installed.
dep_path = dep.path !== nothing ? dep.path : Pkg.Operations.find_installed(name, dep.uuid, dep.tree_hash)

# Skip dependencies that didn't get installed?
if dep_path === nothing
Expand Down
50 changes: 44 additions & 6 deletions test/dependencies.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using Test
using Pkg, Base.BinaryPlatforms
using BinaryBuilderBase
using BinaryBuilderBase: getname, getpkg, dependencify, destdir, PKG_VERSIONS, get_addable_spec
using BinaryBuilderBase: getname, getpkg, dependencify, destdir, PKG_VERSIONS, get_addable_spec, cached_git_clone
using JSON
using LibGit2

# Define equality between dependencies, in order to carry out the tests below
Base.:(==)(a::AbstractDependency, b::AbstractDependency) = getpkg(a) == getpkg(b)
Expand Down Expand Up @@ -179,7 +180,7 @@ end
platform = Platform("x86_64", "linux"; julia_version=v"1.5")

# Test that a particular version of GMP is installed
ap = @test_logs setup_dependencies(prefix, getpkg.(dependencies), platform)
@test_logs setup_dependencies(prefix, getpkg.(dependencies), platform)
@test isfile(joinpath(destdir(dir, platform), "lib", "libgmp.so.10.3.2"))
end

Expand All @@ -190,7 +191,7 @@ end
platform = Platform("x86_64", "linux"; julia_version=v"1.6")

# Test that a particular version of GMP is installed
ap = @test_logs setup_dependencies(prefix, getpkg.(dependencies), platform)
@test_logs setup_dependencies(prefix, getpkg.(dependencies), platform)
@test isfile(joinpath(destdir(dir, platform), "lib", "libgmp.so.10.4.0"))
end

Expand All @@ -204,16 +205,53 @@ end

# Test that this is not instantiatable with either Julia v1.5 or v1.6
platform = Platform("x86_64", "linux"; julia_version=v"1.5")
ap = @test_throws Pkg.Resolve.ResolverError setup_dependencies(prefix, getpkg.(dependencies), platform)
@test_throws Pkg.Resolve.ResolverError setup_dependencies(prefix, getpkg.(dependencies), platform)
platform = Platform("x86_64", "linux"; julia_version=v"1.6")
ap = @test_throws Pkg.Resolve.ResolverError setup_dependencies(prefix, getpkg.(dependencies), platform)
@test_throws Pkg.Resolve.ResolverError setup_dependencies(prefix, getpkg.(dependencies), platform)

# If we don't give a `julia_version`, then we are FULLY UNSHACKLED.
platform = Platform("x86_64", "linux")
ap = @test_logs setup_dependencies(prefix, getpkg.(dependencies), platform)
@test_logs setup_dependencies(prefix, getpkg.(dependencies), platform)
@test isfile(joinpath(destdir(dir, platform), "lib", "libgmp.so.10.3.2"))
@test isfile(joinpath(destdir(dir, platform), "lib", "libmpfr.so.6.1.0"))
end

# Dependency as a local directory
with_temp_project() do dir
mktempdir() do pkgdir
prefix = Prefix(dir)
# Clone if necessary the remote repository and check out its
# working directory in a temporary space.
cache_dir = cached_git_clone("https://github.com/JuliaBinaryWrappers/HelloWorldC_jll.jl")
LibGit2.with(LibGit2.clone(cache_dir, pkgdir)) do repo
LibGit2.checkout!(repo, "c7f2e95d9c04e218931c14954ecd31ebde72cca5")
end
dependencies = [
PackageSpec(
name="HelloWorldC_jll",
path=pkgdir,
),
]
platform = Platform("x86_64", "linux"; libc="glibc")
@test_logs setup_dependencies(prefix, dependencies, platform)
@test readdir(joinpath(destdir(dir, platform), "bin")) == ["hello_world"]
end
end

# Dependency as a remote repository
with_temp_project() do dir
prefix = Prefix(dir)
dependencies = [
PackageSpec(
name="HelloWorldC_jll",
url="https://github.com/JuliaBinaryWrappers/HelloWorldC_jll.jl",
rev="c7f2e95d9c04e218931c14954ecd31ebde72cca5",
),
]
platform = Platform("x86_64", "linux"; libc="glibc")
@test_logs setup_dependencies(prefix, dependencies, platform)
@test readdir(joinpath(destdir(dir, platform), "bin")) == ["hello_world"]
end
end
end

Expand Down

2 comments on commit f78a16a

@giordano
Copy link
Member Author

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/55578

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.6.1 -m "<description of version>" f78a16add67f313e8774550ed035688eeb872a93
git push origin v1.6.1

Please sign in to comment.