# Question on Dependency-Related Best Practice for Packages

**URL:** <https://discourse.julialang.org/t/question-on-dependency-related-best-practice-for-packages/98146>\
**Category:** General Usage\
**Tags:** package, dependencies, package-dev\
**Created:** [May 1, 2023, 1:46am UTC](https://discourse.julialang.org/t/question-on-dependency-related-best-practice-for-packages/98146 "2023-05-01T01:46:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![TI36XPro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ti36xpro/32/33658_2.png) [@TI36XPro](https://discourse.julialang.org/u/TI36XPro)\
**Post date:** [May 1, 2023, 1:46am UTC](https://discourse.julialang.org/t/question-on-dependency-related-best-practice-for-packages/98146/1 "2023-05-01T01:46:58Z")

</div>

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.

1. Add `PackageC` as a dependency of `PackageA`
2. Within `PackageA`, include `using PackageB.PackageC`

I’m not sure which I should do.

---

<div class="post-metadata">

**Author:** ![fatteneder](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fatteneder/32/33991_2.png) [@fatteneder](https://discourse.julialang.org/u/fatteneder)\
**Post date:** [May 1, 2023, 2:32am UTC](https://discourse.julialang.org/t/question-on-dependency-related-best-practice-for-packages/98146/2 "2023-05-01T02:32:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![oxinabox](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oxinabox/32/206603_2.png) [@oxinabox](https://discourse.julialang.org/u/oxinabox)\
**Post date:** [May 1, 2023, 5:17am UTC](https://discourse.julialang.org/t/question-on-dependency-related-best-practice-for-packages/98146/3 "2023-05-01T05:17:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [May 1, 2023, 5:24am UTC](https://discourse.julialang.org/t/question-on-dependency-related-best-practice-for-packages/98146/4 "2023-05-01T05:24:02Z")

</div>

> [@TI36XPro](#):
>
> is that the right terminology?

It’s usually called a “direct dependency”. The terminology goes like this:

```julia
┌──────────────┐ ┌────────────┐ ┌───────────────┐
│ │ │ │ │ │
│ Package ├──────►│ Direct ├──────►│ Indirect │
│ │ │ │ │ │
└──────────────┘ └────────────┘ └───────────────┘
                        \ /
                         \─────────Dependencies───────────/

```

---

<div class="post-metadata">

**Author:** ![TI36XPro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ti36xpro/32/33658_2.png) [@TI36XPro](https://discourse.julialang.org/u/TI36XPro)\
**Post date:** [May 1, 2023, 11:51am UTC](https://discourse.julialang.org/t/question-on-dependency-related-best-practice-for-packages/98146/5 "2023-05-01T11:51:09Z")

</div>

I’m developing my own package so I feel like I should know what semvar means…

---

<div class="post-metadata">

**Author:** ![screw\_dog](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/screw_dog/32/48119_2.png) [@screw\_dog](https://discourse.julialang.org/u/screw_dog)\
**Post date:** [May 1, 2023, 12:09pm UTC](https://discourse.julialang.org/t/question-on-dependency-related-best-practice-for-packages/98146/6 "2023-05-01T12:09:38Z")

</div>

“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](https://pkgdocs.julialang.org/v1/compatibility/#Version-specifier-format) for more info.
