Skip to content

Instantly share code, notes, and snippets.

@sg-s
Last active June 14, 2021 13:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sg-s/a4f44570ed62a0621d771bab62e35bef to your computer and use it in GitHub Desktop.
Save sg-s/a4f44570ed62a0621d771bab62e35bef to your computer and use it in GitHub Desktop.
Developing packages in Julia

What you want to do:

  • Write a package in Julia and develop it with the ultimate goal of releasing it for others to use

How to do it

  1. Open Julia
  2. Install PkgTemplates using using Pkg; Pkg.add("PkgTemplates")
  3. using PkgTemplates
  4. Create a template using your git user name: t = Template(user="sg-s")
  5. Generate a new package with whatever name you want: t("kongo")
  6. Julia will create a folder for you in ~/.julia/dev/kongo. This is where your package is. Inside of that will be a src folder (for your source files) and a test folder (for your tests)
  7. Note that this forces you to have your code in ~/.julia/dev. If you wanted to have your code elsewhere, use the dir argument
  8. Tell Julia that you will be developing this package using ] dev kongo.
  9. Activate the environment corresponding to that package using ] activate kongo

Further notes on VS Code

If you're using VS Code, and you mess around with the code in the src folder, and run it in the REPL, it will magically activate the right environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment