Skip to content

Commit f78a16a

Browse files
authored
[Prefix] Fix installation of dependencies from local directories (#225)
If the provided dependency has already a path, propagate it to the list of installed JLLs in `setup_dependencies`.
1 parent adda098 commit f78a16a

File tree

3 files changed

+52
-10
lines changed

3 files changed

+52
-10
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "BinaryBuilderBase"
22
uuid = "7f725544-6523-48cd-82d1-3fa08ff4056e"
33
authors = ["Elliot Saba <staticfloat@gmail.com>"]
4-
version = "1.6.0"
4+
version = "1.6.1"
55

66
[deps]
77
CodecZlib = "944b1d66-785c-5afd-91f1-9de20f533193"

src/Prefix.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -603,14 +603,16 @@ function setup_dependencies(prefix::Prefix,
603603
name=pkg.name,
604604
uuid,
605605
tree_hash=pkg.tree_hash,
606+
path=pkg.path,
606607
) for (uuid, pkg) in ctx.env.manifest if uuid installed_jll_uuids
607608
]
608609

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

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

637641
# Skip dependencies that didn't get installed?
638642
if dep_path === nothing

test/dependencies.jl

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
using Test
22
using Pkg, Base.BinaryPlatforms
33
using BinaryBuilderBase
4-
using BinaryBuilderBase: getname, getpkg, dependencify, destdir, PKG_VERSIONS, get_addable_spec
4+
using BinaryBuilderBase: getname, getpkg, dependencify, destdir, PKG_VERSIONS, get_addable_spec, cached_git_clone
55
using JSON
6+
using LibGit2
67

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

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

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

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

@@ -204,16 +205,53 @@ end
204205

205206
# Test that this is not instantiatable with either Julia v1.5 or v1.6
206207
platform = Platform("x86_64", "linux"; julia_version=v"1.5")
207-
ap = @test_throws Pkg.Resolve.ResolverError setup_dependencies(prefix, getpkg.(dependencies), platform)
208+
@test_throws Pkg.Resolve.ResolverError setup_dependencies(prefix, getpkg.(dependencies), platform)
208209
platform = Platform("x86_64", "linux"; julia_version=v"1.6")
209-
ap = @test_throws Pkg.Resolve.ResolverError setup_dependencies(prefix, getpkg.(dependencies), platform)
210+
@test_throws Pkg.Resolve.ResolverError setup_dependencies(prefix, getpkg.(dependencies), platform)
210211

211212
# If we don't give a `julia_version`, then we are FULLY UNSHACKLED.
212213
platform = Platform("x86_64", "linux")
213-
ap = @test_logs setup_dependencies(prefix, getpkg.(dependencies), platform)
214+
@test_logs setup_dependencies(prefix, getpkg.(dependencies), platform)
214215
@test isfile(joinpath(destdir(dir, platform), "lib", "libgmp.so.10.3.2"))
215216
@test isfile(joinpath(destdir(dir, platform), "lib", "libmpfr.so.6.1.0"))
216217
end
218+
219+
# Dependency as a local directory
220+
with_temp_project() do dir
221+
mktempdir() do pkgdir
222+
prefix = Prefix(dir)
223+
# Clone if necessary the remote repository and check out its
224+
# working directory in a temporary space.
225+
cache_dir = cached_git_clone("https://github.com/JuliaBinaryWrappers/HelloWorldC_jll.jl")
226+
LibGit2.with(LibGit2.clone(cache_dir, pkgdir)) do repo
227+
LibGit2.checkout!(repo, "c7f2e95d9c04e218931c14954ecd31ebde72cca5")
228+
end
229+
dependencies = [
230+
PackageSpec(
231+
name="HelloWorldC_jll",
232+
path=pkgdir,
233+
),
234+
]
235+
platform = Platform("x86_64", "linux"; libc="glibc")
236+
@test_logs setup_dependencies(prefix, dependencies, platform)
237+
@test readdir(joinpath(destdir(dir, platform), "bin")) == ["hello_world"]
238+
end
239+
end
240+
241+
# Dependency as a remote repository
242+
with_temp_project() do dir
243+
prefix = Prefix(dir)
244+
dependencies = [
245+
PackageSpec(
246+
name="HelloWorldC_jll",
247+
url="https://github.com/JuliaBinaryWrappers/HelloWorldC_jll.jl",
248+
rev="c7f2e95d9c04e218931c14954ecd31ebde72cca5",
249+
),
250+
]
251+
platform = Platform("x86_64", "linux"; libc="glibc")
252+
@test_logs setup_dependencies(prefix, dependencies, platform)
253+
@test readdir(joinpath(destdir(dir, platform), "bin")) == ["hello_world"]
254+
end
217255
end
218256
end
219257

0 commit comments

Comments
 (0)