Julia Packages Guide — Creating, Publishing, and Managing Julia Packages
In this tutorial, you will learn about Julia Packages Guide. We cover key concepts, practical examples, and best practices to help you master this topic.
Julia packages are Git repositories with Project.toml descriptor, src/ directory for source, test/ for tests, and UUID identification -- managed through Pkg.jl for adding, updating, and developing dependencies with the Julia General Registry.
Creating a Package
# Generate package skeleton
] generate MyPackage
# Structure:
# MyPackage/
# src/MyPackage.jl
# Project.toml
# test/runtests.jl
Project.toml
name = "MyPackage"
uuid = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
authors = ["DodaTech <tutorials@dodatech.com>"]
version = "0.1.0"
[deps]
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
[compat]
julia = "1.9"
DataFrames = "1.5"
Package Development
# Activate package environment
] activate .
# Add dependencies
] add DataFrames CSV
# Develop a local package
] dev ./path/to/local/package
# Update dependencies
] update
# Pin a version
] pin PackageName=1.2.3
# Free (unpin)
] free PackageName
Publishing
# Tag a version
] tag MyPackage v0.1.0
# Register with registry
] register
# Or manually via GitHub:
# 1. Create GitHub repo
# 2. Push code
# 3. Tag version
# 4. Submit to JuliaRegistries
Common Mistakes
1. Missing UUID
Every package needs a UUID in Project.toml. Generate with using UUIDs; uuid4().
2. Not locking dependencies
Commit Manifest.toml for reproducible environments. Use ] resolve to update it.
3. Package name conflicts
Check the Julia General Registry for existing names before publishing. Use unique, descriptive names.
Practice Questions
1. How do you create a new package?
] generate PackageName creates the directory structure. Then add source files.
2. What is the UUID in Project.toml? A unique identifier for the package. Required by the package manager for dependency resolution.
3. How do you add a dependency?
] add PackageName or manually add to Project.toml [deps].
FAQ
{{< faq question="What is the difference between add and dev?" >}} Add installs from registry. Dev creates a git clone or directory link for local development. {{< /faq >}}
{{< faq question="What is Manifest.toml?" >}} Locks the exact versions of all dependencies. Commit it for reproducible environments. Ignore for libraries. {{< /faq >}}
{{< faq question="How do I specify compatibility bounds?" >}}
In Project.toml under [compat]: PackageName = "1.0, 1.1" supports 1.0.x and 1.1.x.
{{< /faq >}}
What's Next
Now continue with more Julia topics.
| Topic | Description | Link |
|---|---|---|
| Web Development | Web frameworks | {{< ref "21-web" >}} |
| NLP | Natural language processing | {{< ref "22-nlp" >}} |
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro