Creating a Julia package

A detailed page on Julia packages is available here. Including the part on creating packages.

Julia packages consist of modules. Hence, before creating a package, make sure to understand how modules work in Julia.

Here we provide a step-by-step example, using PkgTemplates.jl, inspired by the video of Chris Rackauckas.

In case of any issues, remember that help is available.


Starting a package

  1. You need to create a folder to store a new package. For example, if you use Atom as an IDE, create a new folder called tiddlywinks.jl. Then, open the GitHub panel and select Initialize and publish on GitHub. Now, you can go to your GitHub page and see that 'tiddlywinks.jl' has appeared there, as well as locally.

  2. In your terminal application, use the change directory (cd) command to change the current working directory to the location of your package.

  3. In the Julia REPL, install PkgTemplate.jl as follows:

using Pkg

Creating package template

Now PkgTemplates.jl has been installed and we want to use it to create a template for a package.

Run the following commands in the Julia REPL to create the template:

using PkgTemplates

t = Template(;

The package called "tiddlywinks" can now be created using the template t by running the following line in Julia REPL:


As the folder has not been specified, the package has been created at ~/.julia/dev on Linux, and at username/julia/dev in Windows. If this is not the repository you want to be working from, move the files to the original repo which you have created. Now in tiddlywinks.jl you should have

Writing code

Everything is ready for us to write code. Folder /src already contains a file with the same name as the name of our package (tiddlywinks.jl). We may not want to write all of the code in this file directly. Instead, we can create varaious pieces in external files within the /src directory, and then assemble them in the main file with the include command. Let us go ahead and

function tiddly_greet()

Writing tests

Tests are necessary to make sure that the code is working correctly. There is never enought testing. The /test folder already has a starter. We edit it to call the newly implemented function:

using tiddlywinks
using Test

@testset "tiddlywinks.jl" begin
    @test tiddlywinks.tiddly_greet() == "tiddlywinks is working"
    @test tiddlywinks.tiddly_greet() != "hello world"

Running tests

To run tests on your package:

Continuous integration (CI)

Make sure to have pushed all of the changes to GitHub. Click on the first badge which has appeared in the GitHub repository of the package, and sign in with Travis CI.

More to come

Stay tuned for more: continuous integration, publishing a package, branches and pull requests, code review