Skip to content

Commit

Permalink
Don't mutate project.deps during project write (#3591)
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth authored Aug 18, 2023
1 parent f4d64d2 commit 051ab5b
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 13 deletions.
3 changes: 1 addition & 2 deletions src/project.jl
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,7 @@ function destructure(project::Project)::Dict
entry!("uuid", project.uuid)
entry!("version", project.version)
entry!("manifest", project.manifest)
merge!(project.deps, project._deps_weak)
entry!("deps", project.deps)
entry!("deps", merge(project.deps, project._deps_weak))
entry!("weakdeps", project.weakdeps)
entry!("extras", project.extras)
entry!("compat", Dict(name => x.str for (name, x) in project.compat))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# This file is machine-generated - editing it directly is not advised

julia_version = "1.10.0-DEV"
julia_version = "1.11.0-DEV"
manifest_format = "2.0"
project_hash = "51e63007fdb8e0cae2b36f0e7b2acebf7b7432a5"
project_hash = "c0b34a2f360e3789aa008772cc2c162a8e9d9850"

[[deps.Adapt]]
deps = ["LinearAlgebra"]
Expand All @@ -16,7 +16,7 @@ uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
[[deps.CompilerSupportLibraries_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae"
version = "1.0.1+0"
version = "1.0.5+1"

[[deps.Example]]
git-tree-sha1 = "46e44e869b4d90b96bd8ed1fdcf32244fddfb6cc"
Expand All @@ -28,11 +28,17 @@ deps = ["Example"]
path = "../HasExtensions.jl"
uuid = "4d3288b3-3afc-4bb6-85f3-489fffe514c8"
version = "0.1.0"
weakdeps = ["OffsetArrays"]
weakdeps = ["IndirectArrays", "OffsetArrays"]

[deps.HasExtensions.extensions]
IndirectArraysExt = "IndirectArrays"
OffsetArraysExt = "OffsetArrays"

[[deps.IndirectArrays]]
git-tree-sha1 = "012e604e1c7458645cb8b436f8fba789a51b257f"
uuid = "9b13fd28-a010-5f03-acff-a1bbcff69959"
version = "1.0.0"

[[deps.Libdl]]
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"

Expand All @@ -49,9 +55,9 @@ version = "1.12.8"
[[deps.OpenBLAS_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"]
uuid = "4536629a-c528-5b80-bd46-f80d51c5b363"
version = "0.3.21+0"
version = "0.3.23+2"

[[deps.libblastrampoline_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "8e850b90-86db-534c-a0d3-1478176c7d93"
version = "5.2.0+0"
version = "5.8.0+1"
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ version = "0.1.0"

[deps]
HasExtensions = "4d3288b3-3afc-4bb6-85f3-489fffe514c8"
IndirectArrays = "9b13fd28-a010-5f03-acff-a1bbcff69959"
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"

[compat]
HasExtensions = "0.1"
IndirectArrays = "1.0"
OffsetArrays = "1.12"

[extras]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@ module HasDepWithExtensions

using HasExtensions
using OffsetArrays: OffsetArray
# Loading OffsetArrays makes the extesion "OffsetArraysExt" to load
# Loading OffsetArrays makes the extesion "OffsetArraysExt" load

using IndirectArrays: IndirectArray
# Loading IndirectArrays makes the extesion "IndirectArraysExt" load

function do_something()
# @info "First do something with the basic array support in B"
# @info "First do something with the basic array support"
HasExtensions.foo(rand(Float64, 2)) == 1 || error("Unexpected value")

# @info "Now do something with extended OffsetArray support in B"
# @info "Now do something with extended OffsetArray support"
HasExtensions.foo(OffsetArray(rand(Float64, 2), 0:1)) == 2 || error("Unexpected value")

# @info "Now do something with extended IndirectArray support"
HasExtensions.foo(IndirectArray(rand(1:6, 32, 32), 1:6)) == 3 || error("Unexpected value")
end

end # module
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ using HasDepWithExtensions
using Test

@test HasDepWithExtensions.HasExtensions.offsetarrays_loaded
@test HasDepWithExtensions.HasExtensions.indirectarrays_loaded
HasDepWithExtensions.do_something()
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

julia_version = "1.10.0-DEV"
manifest_format = "2.0"
project_hash = "549efd0c32255f4b8717f50f49778e183bcc0e36"
project_hash = "8e0de0086d647967f02f7aba44b17d73156d2fee"

[[deps.Example]]
git-tree-sha1 = "46e44e869b4d90b96bd8ed1fdcf32244fddfb6cc"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,23 @@ version = "0.1.0"

[deps]
Example = "7876af07-990d-54b4-ab0e-23690620f79a"
IndirectArrays = "9b13fd28-a010-5f03-acff-a1bbcff69959"

[weakdeps]
IndirectArrays = "9b13fd28-a010-5f03-acff-a1bbcff69959"
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"

[extensions]
IndirectArraysExt = "IndirectArrays"
OffsetArraysExt = "OffsetArrays"

[compat]
Example = "0.5"
IndirectArrays = "1.0"
OffsetArrays = "1.12"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["OffsetArrays", "Test"]
test = ["IndirectArrays", "OffsetArrays", "Test"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module IndirectArraysExt

using HasExtensions, IndirectArrays
import HasExtensions: foo

function foo(::IndirectArray)
return 3
end

function __init__()
HasExtensions.indirectarrays_loaded = true
end

end
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ function foo(::AbstractArray)
return 1
end

indirectarrays_loaded = false
offsetarrays_loaded = false

end # module
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@ using OffsetArrays

@test HasExtensions.offsetarrays_loaded
@test HasExtensions.foo(OffsetArray(rand(Float64, 2), 0:1)) == 2

using IndirectArrays

@test HasExtensions.indirectarrays_loaded
@test HasExtensions.foo(IndirectArray(rand(1:6, 32, 32), 1:6)) == 3

0 comments on commit 051ab5b

Please sign in to comment.