Hello,
I donβt know which of the following is the better option or what should be done. I am hoping someone can help me decide.
I am developing PackageA
. I have PackageB
currently as a dependency of PackageA
. Separately, there is PackageC
which I do not have as an explicit dependency (is that the right terminology?) of PackageA
but it is a dependency of PackageB
.
Now I want to define a new function that uses methods from PackageC
. I see I have two options.
- Add
PackageC
as a dependency of PackageA
- Within
PackageA
, include using PackageB.PackageC
Iβm not sure which I should do.
Most of the time you want to use option 1, especially if you are not the author of B, because then B could drop its C dependency every moment without notice.
I could imagine using option 2 only if B is some sort of wrapper package (or a jll
package) around C (eg GLMakie.jl
always depends on Makie.jl
), because then C is guaranteed to be always available. But I guess option 1 would also be ok then.
2 Likes
Itβs definitely option 1.
Because then you get to impose your own semver constraints on PackageC.
Which you want to do incase its API changes, and PackageB upgrades to use the new version but you canβt.
That way semver will protect PackageA (and itβs users) from breaking.
The fact that option 2 works is kinda a coincidence and not a feature.
1 Like
Itβs usually called a βdirect dependencyβ. The terminology goes like this:
ββββββββββββββββ ββββββββββββββ βββββββββββββββββ
β β β β β β
β Package ββββββββΊβ Direct ββββββββΊβ Indirect β
β β β β β β
ββββββββββββββββ ββββββββββββββ βββββββββββββββββ
\ /
\βββββββββDependenciesβββββββββββ/
1 Like
Iβm developing my own package so I feel like I should know what semvar meansβ¦
βsemverβ = βsemantic versioningβ refers to having your version numbers mean something in particular (ie the difference between 1.0.0 and 1.0.1 or 1.1.0). See package docs for more info.