# Package definition

**URL:** <https://discourse.julialang.org/t/package-definition/57563>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [March 19, 2021, 6:50pm UTC](https://discourse.julialang.org/t/package-definition/57563 "2021-03-19T18:50:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![roryh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/roryh/32/23094_2.png) [@roryh](https://discourse.julialang.org/u/roryh)\
**Post date:** [March 19, 2021, 6:50pm UTC](https://discourse.julialang.org/t/package-definition/57563/1 "2021-03-19T18:50:33Z")

</div>

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](https://pkgdocs.julialang.org/v1/creating-packages/# **5.** -Creating-Packages) 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](https://docs.julialang.org/en/v1/manual/code-loading/#Environments) 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.

```julia
MyPackage/
    Project.toml:
        name = "MyPackage"
        uuid = ...
        [deps]
        ...
        ...
    src/MyPackage.jl:
        module MyPackage
        ...
        end

```

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 🙂

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [March 20, 2021, 7:53am UTC](https://discourse.julialang.org/t/package-definition/57563/2 "2021-03-20T07:53:57Z")

</div>

> [@roryh](#):
>
> However a package can also be defined implicitly from it’s structure as stated in the [julia docs](https://docs.julialang.org/en/v1/manual/code-loading/#Environments) i.e. `X/src/X.jl` defines a package with no Project.toml.

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.

> [@roryh](#):
>
> I was unable to find anywhere stating that project name must match the package name.

It is described in the [project environments](https://docs.julialang.org/en/v1/manual/code-loading/#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

> **[GitHub - JuliaCI/PkgTemplates.jl: Create new Julia packages, the easy way](https://github.com/JuliaCI/PkgTemplates.jl)**
>
> Create new Julia packages, the easy way. Contribute to JuliaCI/PkgTemplates.jl development by creating an account on GitHub.

> **[GitHub - tpapp/PkgSkeleton.jl: Generate Julia package skeletons using a...](https://github.com/tpapp/PkgSkeleton.jl)**
>
> Generate Julia package skeletons using a simple template system - GitHub - tpapp/PkgSkeleton.jl: Generate Julia package skeletons using a simple template system
