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
Add support for "package extensions" to code loading (#47695)
* Add support for "glue packages" to code loading
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.
(cherry picked from commit 495a004)
Copy file name to clipboardExpand all lines: doc/src/manual/code-loading.md
+39Lines changed: 39 additions & 0 deletions
Display the source diff
Display the rich diff
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
+
### "Extension"s
351
352
353
+
An "extension" is a module that is automatically loaded when a specified set of other packages (its "extension dependencies") are loaded in the current Julia session. The extension dependencies of an extension are a subset of those packages listed under the `[weakdeps]` section of a Project file. Extensions are defined under the `[extensions]` section in the project file:
354
+
355
+
```toml
356
+
name = "MyPackage"
357
+
358
+
[weakdeps]
359
+
ExtDep = "c9a23..."# uuid
360
+
OtherExtDep = "862e..."# uuid
361
+
362
+
[extensions]
363
+
BarExt = ["ExtDep", "OtherExtDep"]
364
+
FooExt = "ExtDep"
365
+
...
366
+
```
367
+
368
+
The keys under `extensions` are the name of the extensions.
369
+
They are loaded when all the packages on the right hand side (the extension dependencies) of that extension are loaded.
370
+
If an extension only has one extension dependency the list of extension dependencies can be written as just a string for brevity.
371
+
The location for the entry point of the extension is either in `ext/FooExt.jl` or `ext/FooExt/FooExt.jl` for
372
+
extension `FooExt`.
373
+
The content of an extension is often structured as:
374
+
375
+
```
376
+
module FooExt
377
+
378
+
# Load main package and extension dependencies
379
+
using MyPackage, ExtDep
380
+
381
+
# Extend functionality in main package with types from the extension dependencies
382
+
MyPackage.func(x::ExtDep.SomeStruct) = ...
383
+
384
+
end
385
+
```
386
+
387
+
When a package with extensions is added to an environment, the `weakdeps` and `extensions` sections
388
+
are stored in the manifest file in the section for that package. The dependency lookup rules for
389
+
a package are the same as for its "parent" except that the listed extension dependencies are also considered as
390
+
dependencies.
352
391
### Package/Environment Preferences
353
392
354
393
Preferences are dictionaries of metadata that influence package behavior within an environment.
0 commit comments