Skip to content

Packages

Creating packages

  1. Create the package locally. If using PkgTemplates.jl, this automatically initializes the github repo and sets it as the origin (git remote add origin <url>).
  2. Write some code.
  3. Push to github.

PkgTemplates.jl

The typical flow would be:

using PkgTemplates
gitIgnore = ["*.jl.cov", "*.jl.*.cov", "*.jl.mem", "/deps/deps.jl", "/docs/build"];
t = Template(;
    dir = joinpath(homedir(), "Documents", "julia"),
    plugins = [
        Documenter{GitHubActions},
        Git(; jl = false, ignore = gitIgnore),
        !CompatHelper,
        !AppVeyor,
        !TravisCI,
        !TagBot
        ]);

t("MyPkg");

Note that dir points to the parent directory of the new packages to be created.

Even if one does not want to deploy documentation, the Documenter plugin is needed to create the barebones file structure.

PkgSkeleton.jl (1.5)

The easiest way for creating a package is PkgSkeleton.jl. You need to set your github info (user.name etc) using

git config --global user.name YourName

This must be done inside a git directory. Then generate generates the directory structure and the required files (Project.toml etc). Example:

PkgSkeleton.generate("dir1/MyPackage")

Details:

  • I first create the repo on github and clone it to the local dir.
  • Then I use, from the parent dir: PkgSkeleton.generate("MyPackage", skip_existing_dir = false)
  • This way everything is linked to github from the start.

Github and packages

The basic steps (after creating the package locally):

  1. Create the package on github.
  2. git branch -M main
  3. git push -u origin main

Or import the package repo into Github Desktop.

Pkg Errors

Occasionally, Pkg complains that a package is not registered. ]registry up tends to solve that issue.