Skip to content

Commit e19710b

Browse files
committed
gluedeps -> weakdeps
1 parent d0c879e commit e19710b

File tree

4 files changed

+33
-34
lines changed

4 files changed

+33
-34
lines changed

base/loading.jl

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -758,14 +758,14 @@ function explicit_manifest_deps_get(project_file::String, where::PkgId, name::St
758758
glue_entry = gluepkgs[where.name]
759759
if glue_entry isa String && name == glue_entry ||
760760
glue_entry isa Vector{String} && name in glue_entry
761-
gluedeps = get(entry, "gluedeps", nothing)::Union{Vector{String}, Dict{String, Any}, Nothing}
762-
if gluedeps !== nothing
763-
if gluedeps isa Vector{String}
764-
found_name = name in gluedeps
761+
weakdeps = get(entry, "weakdeps", nothing)::Union{Vector{String}, Dict{String, Any}, Nothing}
762+
if weakdeps !== nothing
763+
if weakdeps isa Vector{String}
764+
found_name = name in weakdeps
765765
break
766-
elseif gluedeps isa Dict{String, Any}
767-
gluedeps = gluedeps::Dict{String, Any}
768-
for (dep, uuid) in gluedeps
766+
elseif weakdeps isa Dict{String, Any}
767+
weakdeps = weakdeps::Dict{String, Any}
768+
for (dep, uuid) in weakdeps
769769
uuid::String
770770
if dep === name
771771
return PkgId(UUID(uuid), name)
@@ -816,8 +816,8 @@ function explicit_manifest_uuid_path(project_file::String, pkg::PkgId)::Union{No
816816
for (name, entries::Vector{Any}) in d
817817
for entry in entries
818818
uuid = get(entry, "uuid", nothing)::Union{Nothing, String}
819-
gluedeps = get(entry, "gluepkgs", nothing)::Union{Nothing, Dict{String, Any}}
820-
if gluedeps !== nothing && pkg.name in keys(gluedeps) && uuid !== nothing && uuid5(UUID(uuid), pkg.name) == pkg.uuid
819+
weakdeps = get(entry, "gluepkgs", nothing)::Union{Nothing, Dict{String, Any}}
820+
if weakdeps !== nothing && haskey(weakdeps, pkg.name) && uuid !== nothing && uuid5(UUID(uuid), pkg.name) == pkg.uuid
821821
p = normpath(dirname(locate_package(PkgId(UUID(uuid), name))), "..")
822822
gluefile = joinpath(p, "glue", pkg.name * ".jl")
823823
isfile(gluefile) && return gluefile
@@ -1061,11 +1061,11 @@ end
10611061

10621062
function insert_glue_triggers_project(project_file::String, parent::PkgId)
10631063
d = parsed_toml(project_file)
1064-
gluedeps = get(d, "gluedeps", nothing)::Union{Nothing, Dict{String, Any}}
1064+
weakdeps = get(d, "weakdeps", nothing)::Union{Nothing, Dict{String, Any}}
10651065
gluepkgs = get(d, "gluepkgs", nothing)::Union{Nothing, Dict{String, Any}}
10661066
gluepkgs === nothing && return
1067-
gluedeps === nothing && return
1068-
_insert_glue_triggers(parent, gluepkgs, gluedeps)
1067+
weakdeps === nothing && return
1068+
_insert_glue_triggers(parent, gluepkgs, weakdeps)
10691069
end
10701070

10711071
function insert_glue_triggers_manifest(project_file::String, parent::PkgId)
@@ -1079,41 +1079,41 @@ function insert_glue_triggers_manifest(project_file::String, parent::PkgId)
10791079
uuid = get(entry, "uuid", nothing)::Union{String, Nothing}
10801080
uuid === nothing && continue
10811081
if UUID(uuid) === parent.uuid
1082-
gluedeps = get(entry, "gluedeps", nothing)::Union{Nothing, Vector{String}, Dict{String,Any}}
1082+
weakdeps = get(entry, "weakdeps", nothing)::Union{Nothing, Vector{String}, Dict{String,Any}}
10831083
gluepkgs = get(entry, "gluepkgs", nothing)::Union{Nothing, Dict{String, Any}}
10841084
gluepkgs === nothing && return
1085-
gluedeps === nothing && return
1086-
if gluedeps isa Dict{String, Any}
1087-
return _insert_glue_triggers(parent, gluepkgs, gluedeps)
1085+
weakdeps === nothing && return
1086+
if weakdeps isa Dict{String, Any}
1087+
return _insert_glue_triggers(parent, gluepkgs, weakdeps)
10881088
end
10891089

1090-
d_gluedeps = Dict{String, String}()
1090+
d_weakdeps = Dict{String, String}()
10911091
for (dep_name, entries) in d
1092-
dep_name in gluedeps || continue
1092+
dep_name in weakdeps || continue
10931093
entries::Vector{Any}
10941094
if length(entries) != 1
10951095
error("expected a single entry for $(repr(name)) in $(repr(project_file))")
10961096
end
10971097
entry = first(entries)::Dict{String, Any}
10981098
uuid = get(entry, "uuid", nothing)::Union{String, Nothing}
1099-
d_gluedeps[dep_name] = uuid
1099+
d_weakdeps[dep_name] = uuid
11001100
end
1101-
@assert length(d_gluedeps) == length(gluedeps)
1102-
return _insert_glue_triggers(parent, gluepkgs, d_gluedeps)
1101+
@assert length(d_weakdeps) == length(weakdeps)
1102+
return _insert_glue_triggers(parent, gluepkgs, d_weakdeps)
11031103
end
11041104
end
11051105
end
11061106
return
11071107
end
11081108

1109-
function _insert_glue_triggers(parent::PkgId, gluepkgs::Dict{String, <:Any}, gluedeps::Dict{String, <:Any})
1109+
function _insert_glue_triggers(parent::PkgId, gluepkgs::Dict{String, <:Any}, weakdeps::Dict{String, <:Any})
11101110
for (glue_entry::String, triggers::Union{String, Vector{String}}) in gluepkgs
11111111
triggers isa String && (triggers = [triggers])
11121112
triggers_id = PkgId[]
11131113
id = PkgId(uuid5(parent.uuid, glue_entry), glue_entry)
11141114
for trigger in triggers
11151115
# TODO: Better error message if this lookup fails?
1116-
uuid_trigger = UUID(gluedeps[trigger]::String)
1116+
uuid_trigger = UUID(weakdeps[trigger]::String)
11171117
push!(triggers_id, PkgId(uuid_trigger, trigger))
11181118
end
11191119
gid = GlueId(id, parent, triggers_id, false, false)

doc/src/manual/code-loading.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -350,25 +350,24 @@ The subscripted `rootsᵢ`, `graphᵢ` and `pathsᵢ` variables correspond to th
350350
Since the primary environment is typically the environment of a project you're working on, while environments later in the stack contain additional tools, this is the right trade-off: it's better to break your development tools but keep the project working. When such incompatibilities occur, you'll typically want to upgrade your dev tools to versions that are compatible with the main project.
351351
### "Glue" packages and dependencies
352352

353-
A "glue package" is a module that is automatically loaded when a specified set of other packages (called "glue dependencies") are loaded in the current Julia session.
354-
These are defined by adding the following two sections to a package's `Project.toml` file:
353+
A "glue package" is a module that is automatically loaded when a specified set of other packages (its "glue dependencies") are loaded in the current Julia session. The glue dependencies of a glue package is a subset of those packages listed under the `[weakdeps]` section of a Project file. Glue packages are defined under the `[gluepkgs]` section in the project file:
355354

356355
```toml
357356
name = "MyPackage"
358357

359-
[gluedeps]
358+
[weakdeps]
360359
GlueDep = "c9a23..." # uuid
361360
OtherGlueDep = "862e..." # uuid
362361

363362
[gluepkgs]
364-
GlueFoo = "GlueDep"
365363
GlueBar = ["GlueDep", "OtherGlueDep"]
364+
GlueFoo = "GlueDep"
366365
...
367366
```
368367

369368
The keys under `gluepkgs` are the name of the glue packages.
370-
They are loaded when all the packages on the right hand side (the glue dependencies) of the glue package are loaded.
371-
If a glue package only has one glue dependency the lit of glue dependencies can be written as just a string for breviety.
369+
They are loaded when all the packages on the right hand side (the glue dependencies) of that glue package are loaded.
370+
If a glue package only has one glue dependency the list of glue dependencies can be written as just a string for brevity.
372371
The location for the entry point of the glue package is either in `glue/GlueFoo.jl` or `glue/GlueFoo/GlueFoo.jl` for
373372
glue package `GlueFoo`.
374373
The content of a glue package is often structured as:
@@ -385,10 +384,10 @@ MyPackage.func(x::GlueDep.SomeStruct) = ...
385384
end
386385
```
387386

388-
When a package with glue packages is added to an environment, the `gluedeps` and `gluepkgs` sections
387+
When a package with glue packages is added to an environment, the `weakdeps` and `gluepkgs` sections
389388
are stored in the manifest file in the section for that package. The dependency lookup rules for
390-
a package are the same as for its "parent" except that the listed glue dependencies are also
391-
part of its dependencies.
389+
a package are the same as for its "parent" except that the listed glue dependencies are also considered as
390+
dependencies.
392391
### Package/Environment Preferences
393392

394393
Preferences are dictionaries of metadata that influence package behavior within an environment.

test/project/GluePkgs/HasDepWithGluePkgs.jl/Manifest.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ uuid = "55982ee5-2ad5-4c40-8cfe-5e9e1b01500d"
1515
version = "0.1.0"
1616

1717
[[deps.HasGluePkgs]]
18-
gluedeps = ["GlueDep", "GlueDep2"]
18+
weakdeps = ["GlueDep", "GlueDep2"]
1919
path = "../HasGluePkgs.jl"
2020
uuid = "4d3288b3-3afc-4bb6-85f3-489fffe514c8"
2121
version = "0.1.0"

test/project/GluePkgs/HasGluePkgs.jl/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name = "HasGluePkgs"
22
uuid = "4d3288b3-3afc-4bb6-85f3-489fffe514c8"
33
version = "0.1.0"
44

5-
[gluedeps]
5+
[weakdeps]
66
GlueDep = "fa069be4-f60b-4d4c-8b95-f8008775090c"
77
GlueDep2 = "55982ee5-2ad5-4c40-8cfe-5e9e1b01500d"
88

0 commit comments

Comments
 (0)