Revise, Pkg, PkgTemplates, PkgSkeleton and smooth Julia package development

Hi all. After having used Python extensively for the last 4-5 years, I am now switching to Julia both out of interest and for performance reasons. I am now actively learning to master the REPL-focused Julia development cycle. Development is made much faster and enjoyable using Revise.jl, however I find that my current workflow does not integrate well with Revise.jl and that I need to work on package development instead.

The project
I have a project, as a Git repository, with the following tree structure

ProjectName/
β”œβ”€β”€ README.md
β”œβ”€β”€ src
β”‚   β”œβ”€β”€ MainModule.jl
β”‚   β”œβ”€β”€ Submodule.jl
β”œβ”€β”€ docs
β”‚   β”œβ”€β”€ make.jl
β”‚   └── src
β”‚       └── index.md
β”œβ”€β”€ examples
β”‚   β”œβ”€β”€ README.md
β”‚   β”œβ”€β”€ example.jl
└── tests
    └── test.jl

File contents of Submodule.jl are, for example:

module Submodule
export AnotherFunction

function AnotherFunction()
    println("This is another function")
end
end # End module

File contents of MainModule.jl are, for example:

module MainModule

include("Submodule.jl")
using .Submodule

export SomeFunction

function SomeFunction()
    println("This is a function")
    Submodule.AnotherFunction()
end
end # End module

The problem
The problem is that changes in Submodule.jl are not tracked when using Revise.jl

julia> using Revise
julia> includet("MainModule.jl"); using .MainModule

Reading different topics (both here and on, e.g., StackExchange) recommend that instead of using the includet() command I switch to making MainModule a package instead. While most examples using PkgTemplates.jl, PkgSkeleton, or even the standard [Pkg.jl] all work fine, I cannot seem to figure out how to add Submodule to the package. Most examples out there also do not include the inclusion of separate Julia files (like Submodule.jl in this case).

I highly prefer to not make Submodule a separate package such that it can be imported, but I do need Revise.jl to track changes in Submodule.jl.

Question
How do I make a bare-bones package that allows Revise.jl to track all included files as well?

  • If possible, I prefer the β€œPackage” to be as bare bones as possible. I do not want automated Git workflow (I do this myself), I do not (yet) want to publish the package to the Julia repository, etc. I only want Revise.jl to track all included files.
  • Is there a change in mindset that I have to undergo? Should I always aim to develop packages that have to be pushed to the main Julia repository such that others can use it as well? Should I let the Julia package manager handle my Git workflow? Or is there something else I am not seeing at the moment?
  • What specific commands do I need to run (in the Julia REPL) to use and develop my MainModule?

Thank you for all the help you can offer.

3 Likes

Sorry, deleted it because you need to create an actual id to things work correctly. The easiest way is really just to use PkgTemplates. A very quick step-by-step is here: Create new package Β· JuliaNotes.jl

If you do not want any of the github actions, just delete the .github directory. But I don’t see any reason to do so, really, it can’t do any harm.

This might be somewhat helpful to answer that particular question: https://github.com/GunnarFarneback/LocalRegistry.jl/blob/tutorial/docs/tutorials/create_minimal_package.md

  • Is there a change in mindset that I have to undergo? Should I always aim to develop packages that have to be pushed to the main Julia repository such that others can use it as well?

That’s not necessary at all. If you start to develop many interdependent private packages you might want to consider making your own registry, but that’s absolutely not an immediate concern.

Should I let the Julia package manager handle my Git workflow? Or is there something else I am not seeing at the moment?

The package manager can’t help you that much with Git workflows.

  • What specific commands do I need to run (in the Julia REPL) to use and develop my MainModule?

In most cases I do like this:

  1. cd path/to/my/package
  2. julia --project
  3. julia> using Revise, MyPackage

This critically requires that you have a Project.toml file and the basic file structure described in the earlier link.

2 Likes

Thanks for the minimal example, that made it work. I believe I initially forgot the dot . before using the submodule (i.e. using .Submodule), which made Pkg unaware of the submodules existence.

The package manager can’t help you that much with Git workflows.

It appears I was wrong in assuming that PkgTemplates handled all the Git-related tasks as well, as they have quite some extensive documentation and configuration on the Git side. Can you actually run Git commands using PkgTemplates? Or is it just for versioning when eventually publishing the package?

julia --project

What is the --project doing in this context?

I don’t use PkgTemplates, so don’t have much insight, but my understanding is that it just gives you a package structure according to some template. That template might include files which configure how GitHub should behave in case you host it there, but that’s a GitHub thing.

Approximately the same as Pkg.activate.

1 Like

Quoting the docs:

--project[={<dir>|@.}] Set <dir> as the home project/environment. The default @. option will search through parent directories until a Project.toml or JuliaProject.toml file is found.

https://docs.julialang.org/en/v1/manual/command-line-options/#Command-line-switches-for-Julia

3 Likes

Hey @johannesnauta !

Warm welcome to the Julia Community and happy to hear about the packages you are developing! :wave:

One additional thing to keep in mind is that if you want to develop tests, I drafted some guidance on how to create a testing workflow: Unit Testing Β· The Julia Language

Hope it helps and see you around!

~ tcp :deciduous_tree:

1 Like