You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This allows packages to define "glue packages" which
are modules that are automatically loaded when
a set of other packages are loaded into the Julia
session.
Copy file name to clipboardExpand all lines: doc/src/manual/code-loading.md
+39
Original file line number
Diff line number
Diff line change
@@ -348,7 +348,46 @@ The subscripted `rootsᵢ`, `graphᵢ` and `pathsᵢ` variables correspond to th
348
348
2. Packages in non-primary environments can end up using incompatible versions of their dependencies even if their own environments are entirely compatible. This can happen when one of their dependencies is shadowed by a version in an earlier environment in the stack (either by graph or path, or both).
349
349
350
350
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.
351
+
### "Glue" packages and dependencies
351
352
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:
355
+
356
+
```toml
357
+
name = "MyPackage"
358
+
359
+
[gluedeps]
360
+
GlueDep = "c9a23..."# uuid
361
+
OtherGlueDep = "862e..."# uuid
362
+
363
+
[gluepkgs]
364
+
GlueFoo = "GlueDep"
365
+
GlueBar = ["GlueDep", "OtherGlueDep"]
366
+
...
367
+
```
368
+
369
+
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.
372
+
The location for the entry point of the glue package is either in `glue/GlueFoo.jl` or `glue/GlueFoo/GlueFoo.jl` for
373
+
glue package `GlueFoo`.
374
+
The glue package can be viewed as a somewhat normal package that has the glue dependencies and the main package as dependencies.
375
+
The content of a glue package is often structured as:
376
+
377
+
```
378
+
module GlueFoo
379
+
380
+
# Load main package and glue dependencies
381
+
using MyPackage, GlueDep
382
+
383
+
# Extend functionality in main package with types from the glue dependencies
384
+
MyPackage.func(x::GlueDep.SomeStruct) = ...
385
+
386
+
end
387
+
```
388
+
389
+
When a package with glue packages is added to an environment, the `gluedeps` and `gluepkgs` sections
390
+
are stored in the manifest file in the section for that package.
352
391
### Package/Environment Preferences
353
392
354
393
Preferences are dictionaries of metadata that influence package behavior within an environment.
0 commit comments