# Can someone help me figure out how to arrange a package with the structure as in ITensors.jl?

**URL:** <https://discourse.julialang.org/t/can-someone-help-me-figure-out-how-to-arrange-a-package-with-the-structure-as-in-itensors-jl/89476>\
**Category:** Package Management\
**Created:** [October 29, 2022, 5:48am UTC](https://discourse.julialang.org/t/can-someone-help-me-figure-out-how-to-arrange-a-package-with-the-structure-as-in-itensors-jl/89476 "2022-10-29T05:48:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![liuyxpp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/liuyxpp/32/9870_2.png) [@liuyxpp](https://discourse.julialang.org/u/liuyxpp)\
**Post date:** [October 29, 2022, 5:48am UTC](https://discourse.julialang.org/t/can-someone-help-me-figure-out-how-to-arrange-a-package-with-the-structure-as-in-itensors-jl/89476/1 "2022-10-29T05:48:05Z")

</div>

I want to split plotting functionality (which depends on Plots or Makie) from my main package to reduce loading time. I notice that [ITensors.jl](https://github.com/ITensor/ITensors.jl) does the exact thing I want to do. But I have difficulty on how it works. For example,

- as the subpacakges are in the same github repo, how can I register each of them?
- Why there is an `ITensorVisualizationCore` module within the main package ITensor?

Thanks!

---

<div class="post-metadata">

**Author:** ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Post date:** [October 29, 2022, 5:55am UTC](https://discourse.julialang.org/t/can-someone-help-me-figure-out-how-to-arrange-a-package-with-the-structure-as-in-itensors-jl/89476/2 "2022-10-29T05:55:38Z")

</div>

> [@liuyxpp](#):
>
> as the subpacakges are in the same github repo, how can I register each of them?

> **[GitHub - JuliaRegistries/Registrator.jl: Julia package registration bot](https://github.com/JuliaRegistries/Registrator.jl#registering-a-package-in-a-subdirectory)**
>
> Julia package registration bot. Contribute to JuliaRegistries/Registrator.jl development by creating an account on GitHub.

TLDR: `@JuliaRegistrator register subdir=path/to/my/package`

Btw, instead of using subpackages or Requires.jl there might be better support for optional/weak dependencies in the (soon?) future, see e.g. [Support in code loading and precompilation for weak dependencies by KristofferC · Pull Request #47040 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/pull/47040)

---

<div class="post-metadata">

**Author:** ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Post date:** [October 29, 2022, 6:01am UTC](https://discourse.julialang.org/t/can-someone-help-me-figure-out-how-to-arrange-a-package-with-the-structure-as-in-itensors-jl/89476/3 "2022-10-29T06:01:19Z")

</div>

As for ITensorsVisualizationBase, I would think that it just hold common code that is shared among the different plotting backend packages.

---

<div class="post-metadata">

**Author:** ![liuyxpp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/liuyxpp/32/9870_2.png) [@liuyxpp](https://discourse.julialang.org/u/liuyxpp)\
**Post date:** [October 29, 2022, 6:15am UTC](https://discourse.julialang.org/t/can-someone-help-me-figure-out-how-to-arrange-a-package-with-the-structure-as-in-itensors-jl/89476/4 "2022-10-29T06:15:42Z")

</div>

I am not confused with ITensorsVisualizationBase, but ITensorVisualizationCore, which resides in `ITensors/src/ITensorVisualizationCore`. Note that ITensorsVisualizationBase is a subpackage instead of a sub module inside ITensors (it locates at `ITensors/ITensorsVisualizationBase`)

---

<div class="post-metadata">

**Author:** ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Post date:** [October 29, 2022, 7:02am UTC](https://discourse.julialang.org/t/can-someone-help-me-figure-out-how-to-arrange-a-package-with-the-structure-as-in-itensors-jl/89476/5 "2022-10-29T07:02:04Z")

</div>

My bad. Don’t what this module is for exactly. Someone else should be able to comment on that.

---

<div class="post-metadata">

**Author:** ![mtfishman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mtfishman/32/30755_2.png) [@mtfishman](https://discourse.julialang.org/u/mtfishman)\
**Post date:** [April 3, 2023, 11:20pm UTC](https://discourse.julialang.org/t/can-someone-help-me-figure-out-how-to-arrange-a-package-with-the-structure-as-in-itensors-jl/89476/6 "2023-04-03T23:20:45Z")

</div>

The reason for the `ITensorVisualizationCore` submodule within the `ITensors` module is to define the interface function `visualize` and macro `@visualize`, which I want to be able to use inside `ITensors` to help debug code by visualizing tensor contractions. However, I didn’t want all of `ITensorsVisualizationBase` (the common infrastructure of the various visualization backends like `UnicodePlots` and `Makie`) defined inside `ITensors`, so I defined `ITensorVisualizationCore` just to define the minimal interface that then gets extended by `ITensorsVisualizationBase` and the backend packages.

Perhaps there is a better way to achieve this. Ultimately it might make sense to have a separate `VisualizationCore` interface package that just defines `visualize` and `@visualize` which can then be loaded inside `ITensors` (analogous to packages like [GitHub - JuliaArrays/StaticArraysCore.jl: Interface package for StaticArrays.jl](https://github.com/JuliaArrays/StaticArraysCore.jl)) which then get overloaded by `ITensorsVisualizationBase` and extended by the various visualization backend packages.

Also I should probably re-implement some of this using the new Pkg extensions system coming to Julia 1.9 ([5. Creating Packages · Pkg.jl](https://pkgdocs.julialang.org/dev/creating-packages/#Conditional-loading-of-code-in-packages-(Extensions))).

---

<div class="post-metadata">

**Author:** ![liuyxpp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/liuyxpp/32/9870_2.png) [@liuyxpp](https://discourse.julialang.org/u/liuyxpp)\
**Post date:** [April 4, 2023, 11:45am UTC](https://discourse.julialang.org/t/can-someone-help-me-figure-out-how-to-arrange-a-package-with-the-structure-as-in-itensors-jl/89476/7 "2023-04-04T11:45:18Z")

</div>

Great! Thanks for such a detailed explanation.
