Pkg3 project workflow questions

I am using the new Pkg setup for projects, ie bundles of code which are not necessarily packaged, but serve the a specific purpose (eg accompany a paper). I have some clarifying questions about the workflow.

I set up the directory structure like

ThisProject/
   Project.toml
   Manifest.toml
   src/
       ThisProject.jl # which has "module ThisProject ... end"

Questions:

  1. Is it OK if I don’t dev this project in the global environment, just use

    shell> cd to/ThisProject/
    pkg> activate . 
    

    when I am working on it? It seems to work fine so far.

  2. Having things in a module is convenient because of Revise.jl. Can I have multiple modules though, or do they have to be submodules of the same module? How should I set up the files?

  3. Unless I

    pkg> up
    

    from this active project, can I rely on the package versions being unchanged, because they are in Manifest.toml (which is in version control, so I can always reproduce my environment)?

Yes, that is the intended workflow.

You can have subpackages inside the project that you dev, but Revise can also track files that are just included with Revise.track.

Dependencies of dependencies could update on add unless you pin them (due to https://github.com/JuliaLang/Pkg.jl/issues/211). But with the Manifest you can recreate the exact versions, yes.

3 Likes

Just to clarify the subpackages,

  1. is there a 1-to-1 correspondence between modules and packages as far as loading is concerned? Eg I cannot have
    src/
        SomeModule.jl
        SomeOtherModule.jl
    
    and then
    using SomeModule
    using SomeOtherModule
    
    ?
  2. for the dev, I would need to set up a hierachy like
    src/
        MainProjectModule.jl
    misc/
        OtherModule/
            src/
                OtherModule.jl
    
    and then dev ./misc/OtherModule, or is it simpler than this?

You would have to do as 2 if you want them to be separate packages and be individually loadable.

If you want to provide two modules from the same package, you can make them both submodules of the main package module.

2 Likes