Package definition

I’ve recently moved from c++ and python to julia as the perfect one stop shop for all my simulation needs. One thing I struggled with for quite a bit and seems others do as well is the concept of packages and projects.

There seems to be a bit of contradictory information in the Pkg documentation which states a package must have a Project.toml file which defines a name, uuid and deps. However a package can also be defined implicitly from it’s structure as stated in the julia docs i.e. X/src/X.jl defines a package with no Project.toml. So I suppose my question is should these docs be edited to be a bit more consistent with each other or I could easily be missing something. I’m happy to help out with docs but it’s probably better left to someone not asking beginner questions.

Another related question I have, is it necessary that the name field in a in Project.toml match the package name i.e.

        name = "MyPackage"
        uuid = ...
        module MyPackage

because this tripped me up for a while and I am unable to import MyPackage when I activate the environment with name = OtherName. I was unable to find anywhere stating that project name must match the package name. Thanks for your help :slight_smile:

1 Like

I think you misunderstood:

A package directory is a directory containing the source trees of a set of packages as subdirectories, and forms an implicit environment .

This is a convenience feature for environments. I would just use a project though in practice.

It is described in the project environments section of the docs you linked.

That said, most Julia users just use a package generator template which takes care of all the details, eg

1 Like