Skip to content

Commit 9569604

Browse files
committed
Make code work across Julia 1.6 and 1.7+
1 parent b85a6e1 commit 9569604

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

src/AutoBuild.jl

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,6 +1425,29 @@ const uuid_package = UUID("cfb74b52-ec16-5bb7-a574-95d9e393895e")
14251425
# For even more interesting historical reasons, we append an extra
14261426
# "_jll" to the name of the new package before computing its UUID.
14271427
jll_uuid(name) = bb_specific_uuid5(uuid_package, "$(name)_jll")
1428+
1429+
function find_uuid(ctx, pkg)
1430+
if Pkg.Types.has_uuid(pkgspec)
1431+
return pkg.uuid
1432+
else
1433+
@static if VERSION >= 1.7
1434+
uuids = Pkg.Types.registered_uuids(ctx.registries, depname)
1435+
else
1436+
uuids = Pkg.Types.registered_uuids(ctx, depname)
1437+
end
1438+
if isempty(uuids)
1439+
return nothing
1440+
end
1441+
if length(uuids) == 1
1442+
return first(uuids)
1443+
end
1444+
depname = getname(pkg)
1445+
error("""
1446+
Multiple UUIDs found for package `$(depname)`.
1447+
Use `PackageSpec(name = \"$(depname)\", uuid = ..." to specify the UUID explicitly.
1448+
""")
1449+
end
1450+
14281451
function build_project_dict(name, version, dependencies::Array{Dependency}, julia_compat::String=DEFAULT_JULIA_VERSION_SPEC; lazy_artifacts::Bool=false, kwargs...)
14291452
Pkg.Types.semver_spec(julia_compat) # verify julia_compat is valid
14301453
project = Dict(
@@ -1442,20 +1465,9 @@ function build_project_dict(name, version, dependencies::Array{Dependency}, juli
14421465
for dep in dependencies
14431466
pkgspec = getpkg(dep)
14441467
depname = getname(dep)
1445-
if Pkg.Types.has_uuid(pkgspec)
1446-
uuid = pkgspec.uuid
1447-
else
1448-
uuids = Pkg.Types.registered_uuids(ctx.registries, depname)
1449-
if isempty(uuids)
1450-
uuid = jll_uuid(depname)
1451-
elseif length(uuids) == 1
1452-
uuid = first(uuids)
1453-
else
1454-
error("""
1455-
Multiple UUIDs found for package `$(depname)`.
1456-
Use `PackageSpec(name = \"$(depname)\", uuid = ..." to specify the UUID explicitly.
1457-
""")
1458-
end
1468+
uuid = findname(ctx, pkgspec)
1469+
if uuid === nothing
1470+
uuid = jll_uuid(depname)
14591471
end
14601472
project["deps"][depname] = string(uuid)
14611473
if dep isa Dependency && length(dep.compat) > 0

0 commit comments

Comments
 (0)