Computational Analysis of Social Complexity
Fall 2025, Spencer Lyon
Prerequisites
- Laptop or personal computer with internet connection
- Julia intro lecture
- Julia Modules lecture
Outcomes
- Installing, uninstalling, and updating packages
- Managing a Project.toml file and understanding the related Manifest.toml
- Create new Julia packages to organize code snippets
References
Introduction¶
- Julia is a very powerful, modern language
- It comes packed with many essential components for creating high performing numerical programs
- Arrays
- Parallel processing
- Multi threading
- Calling C code
- ... and many more
- However, Julia also has a thriving 3rd party library ecosystem (ML, Plotting, Notebooks, Differential Equations, and more)
- Julia libraries are known as packages
- Today we will learn how to manage and develop packages
Package Management¶
- To start, let’s learn how to manage Julia packages
- There are two primary methods for managing packages:
- Importing and calling functions from the
Pkgstandard library package - Using the
pkgREPL mode from the main Julia REPL
- Importing and calling functions from the
- We will learn both here
- First, we’ll import the
Pkgpackage
import PkgInstalling¶
- To install a package use
Pkg.add("PACKAGE_NAME") - Below we install the popular
CSVpackage used for handling CSV files in Julia
Pkg.add("CSV") Resolving package versions...
Updating `~/.julia/environments/v1.11/Project.toml`
[336ed68f] + CSV v0.10.15
Updating `~/.julia/environments/v1.11/Manifest.toml`
[336ed68f] + CSV v0.10.15
[944b1d66] + CodecZlib v0.7.8
[34da2185] + Compat v4.18.0
[9a962f9c] + DataAPI v1.16.0
[e2d170a0] + DataValueInterfaces v1.0.0
[48062228] + FilePathsBase v0.9.24
[842dd82b] + InlineStrings v1.4.4
[82899510] + IteratorInterfaceExtensions v1.0.0
[bac558e1] + OrderedCollections v1.8.1
[2dfb63ee] + PooledArrays v1.4.3
[91c51154] + SentinelArrays v1.4.8
[3783bdb8] + TableTraits v1.0.1
[bd369af6] + Tables v1.12.1
[3bb67fe8] + TranscodingStreams v0.11.3
[ea10d353] + WeakRefStrings v1.4.2
[76eceee3] + WorkerUtilities v1.6.1
[9fa8497b] + Future v1.11.0
- To use the
pkgREPL mode, I first start the repl by runningjuliain my terminal - Then I press
]to enter Pkg mode- REPL prompt chanegs to
(@v1.11) pkg>(wherev1.11represents my Julia system version)
- REPL prompt chanegs to
- Once here I run
add CSVto get the following output:
(@v1.11) pkg> add CSV
Resolving package versions...
Updating `~/.julia/environments/v1.11/Project.toml`
[336ed68f] + CSV v0.10.15
Updating `~/.julia/environments/v1.11/Manifest.toml`
[336ed68f] + CSV v0.10.15
[944b1d66] + CodecZlib v0.7.8
[34da2185] + Compat v4.18.0
[9a962f9c] + DataAPI v1.16.0
[e2d170a0] + DataValueInterfaces v1.0.0
[48062228] + FilePathsBase v0.9.24
[842dd82b] + InlineStrings v1.4.4
[82899510] + IteratorInterfaceExtensions v1.0.0
[bac558e1] + OrderedCollections v1.8.1
[2dfb63ee] + PooledArrays v1.4.3
[91c51154] + SentinelArrays v1.4.8
[3783bdb8] + TableTraits v1.0.1
[bd369af6] + Tables v1.12.1
[3bb67fe8] + TranscodingStreams v0.11.3
[ea10d353] + WeakRefStrings v1.4.2
[76eceee3] + WorkerUtilities v1.6.1
[9fa8497b] + Future v1.11.0Checking Status¶
- To check the
statusof my packages, I can use thePkg.statusfunction orstatuscommand at the pkg REPL
Pkg.status()Status `~/.julia/environments/v1.11/Project.toml`
[336ed68f] CSV v0.10.15
⌃ [7073ff75] IJulia v1.29.2
Info Packages marked with ⌃ have new versions available and may be upgradable.
(@v1.11) pkg> status
Status `~/.julia/environments/v1.11/Project.toml`
[336ed68f] CSV v0.10.15
⌃ [7073ff75] IJulia v1.29.2
Info Packages marked with ⌃ have new versions available and may be upgradable.- The printout here will show one line per explicity installed package (not transitive dependencies)
- The format of each line is
_ [ID] NAME VERSIONwhereIDis the beginning of a universially unique identifier (UUID) that identifies the package in the Julia ecosystemNAMEis the name of the packageVERSIONis the installed version number_is a placeholder for possible version updates. These placeholders will be explained beneath the list of packages
Updating¶
- Notice how our printout shows we have version v1.29.2 of IJulia, but that there is an update available
- To update to the latest verison (reccomended for security and features) we use the
Pkg.udpatefunction orupREPL command - If we run
pkg> up, Julia will attempt to get the latest version of all installed packages (same forPkg.update()) - If instead we do
pkg> up IJulia, Julia will only update IJulia (same forPkg.update("IJulia"))
(@v1.11) pkg> up IJulia
Updating registry at `~/.julia/registries/General.toml`
Updating `~/.julia/environments/v1.11/Project.toml`
[7073ff75] ↑ IJulia v1.29.2 ⇒ v1.30.0
Updating `~/.julia/environments/v1.11/Manifest.toml`
[7073ff75] ↑ IJulia v1.29.2 ⇒ v1.30.0
[b85f4697] - SoftGlobalScope v1.1.0- Now running
statusdoes not show that IJulia has a newer available version
Pkg.status()Status `~/.julia/environments/v1.11/Project.toml`
[336ed68f] CSV v0.10.15
[7073ff75] IJulia v1.30.0
Uninstalling¶
- To uninstall a package we can use the
Pkg.rm("NAME")functino orpkg> rm NAMEREPL command:|
Pkg.rm("CSV") Updating `~/.julia/environments/v1.11/Project.toml`
[336ed68f] - CSV v0.10.15
Updating `~/.julia/environments/v1.11/Manifest.toml`
[336ed68f] - CSV v0.10.15
[944b1d66] - CodecZlib v0.7.8
[34da2185] - Compat v4.18.0
[9a962f9c] - DataAPI v1.16.0
[e2d170a0] - DataValueInterfaces v1.0.0
[48062228] - FilePathsBase v0.9.24
[842dd82b] - InlineStrings v1.4.4
[82899510] - IteratorInterfaceExtensions v1.0.0
[bac558e1] - OrderedCollections v1.8.1
[2dfb63ee] - PooledArrays v1.4.3
[91c51154] - SentinelArrays v1.4.8
[3783bdb8] - TableTraits v1.0.1
[bd369af6] - Tables v1.12.1
[3bb67fe8] - TranscodingStreams v0.11.3
[ea10d353] - WeakRefStrings v1.4.2
[76eceee3] - WorkerUtilities v1.6.1
[9fa8497b] - Future v1.11.0
- Status now shows we no longer have CSV
Pkg.status()Status `~/.julia/environments/v1.11/Project.toml`
[7073ff75] IJulia v1.30.0
Environments¶
- Notice above when managing packages, I always saw the following at the top of the file:
Resolving package versions...
Updating `~/.julia/environments/v1.11/Project.toml`- This was a hint to how Julia keeps its packages organized...
- Whenever we are working in Julia, there is always an environment active
- By default, the environment is specific to the user account (
~/is UNIX shorthand for current user’s home directory) and the Julia version number (v1.11) - This means that all packages we install will be available any time someone starts Julia v1.11 from my user account
Environment Management¶
- Having a single, global environment is very convenient for simple tasks and exploration
- However, for larger software or research projects, it is a best practice to have an environment specific for that project
- The Julia package manager has built in support for managing isolated sets of packages in named environments
Activate¶
- To create an environment, start Julia within the folder for the project (use
pwd()) to check your folder - Then run
Pkg.activate(".")orpkg> activate .to create a new project, or activate an existing project specific to the current folder - When you run this command, no files will have been changed, but checking status will show you are in a different environment
Pkg.activate(".") Activating new project at `~/Teaching/UCF/CAP-6318/book-myst/week02`
Pkg.status()Status `~/Teaching/UCF/CAP-6318/book-myst/week02/Project.toml` (empty project)
Manage Packages¶
- Now that we have a new environment activated, we can install packages specific to this project
Pkg.add(["VegaLite", "VegaDatasets"]) Resolving package versions...
Updating `~/Teaching/UCF/CAP-6318/book-myst/week02/Project.toml`
[0ae4a718] + VegaDatasets v2.1.1
[112f6efa] + VegaLite v3.3.0
Updating `~/Teaching/UCF/CAP-6318/book-myst/week02/Manifest.toml`
[e1450e63] + BufferedStreams v1.2.2
[944b1d66] + CodecZlib v0.7.8
[34da2185] + Compat v4.18.0
[187b0558] + ConstructionBase v1.6.0
[9a962f9c] + DataAPI v1.16.0
⌅ [864edb3b] + DataStructures v0.18.22
[e2d170a0] + DataValueInterfaces v1.0.0
[e7dc6d0d] + DataValues v0.4.13
[ffbed154] + DocStringExtensions v0.9.5
[497a8b3b] + DoubleFloats v1.4.3
[5789e2e9] + FileIO v1.17.0
⌅ [8fc22ac5] + FilePaths v0.8.3
[48062228] + FilePathsBase v0.9.24
[14197337] + GenericLinearAlgebra v0.3.18
[842dd82b] + InlineStrings v1.4.4
[92d709cd] + IrrationalConstants v0.2.4
[1c8ee90f] + IterableTables v1.0.0
[82899510] + IteratorInterfaceExtensions v1.0.0
[692b3bcd] + JLLWrappers v1.7.1
[682c06a0] + JSON v0.21.4
[0f8b85d8] + JSON3 v1.14.3
[7d188eb4] + JSONSchema v1.4.1
[2ab3a3ac] + LogExpFunctions v0.3.29
[1914dd2f] + MacroTools v0.5.16
[e1d29d7a] + Missings v1.2.0
[2bd173c7] + NodeJS v2.0.0
[4d1e1d77] + Nullables v1.0.0
[bac558e1] + OrderedCollections v1.8.1
[69de0a69] + Parsers v2.8.3
[f27b6e38] + Polynomials v4.1.0
⌅ [aea7be01] + PrecompileTools v1.2.1
[21216c6a] + Preferences v1.5.0
[be4d8f0f] + Quadmath v0.5.13
[3cdcf5f2] + RecipesBase v1.3.4
[189a3867] + Reexport v1.2.2
[ae029012] + Requires v1.3.1
[efcf1570] + Setfield v1.1.2
[276daf66] + SpecialFunctions v2.5.1
[1e83bf80] + StaticArraysCore v1.4.3
[856f2bd8] + StructTypes v1.11.0
[5e66a065] + TableShowUtils v0.2.6
[3783bdb8] + TableTraits v1.0.1
[382cd787] + TableTraitsUtils v1.0.2
[e0df1984] + TextParse v1.0.3
[3bb67fe8] + TranscodingStreams v0.11.3
[30578b45] + URIParser v0.4.1
[5c2747f8] + URIs v1.6.1
[239c3e63] + Vega v2.7.0
[0ae4a718] + VegaDatasets v2.1.1
[112f6efa] + VegaLite v3.3.0
[ea10d353] + WeakRefStrings v1.4.2
[efe28fd5] + OpenSpecFun_jll v0.5.6+0
[0dad84c5] + ArgTools v1.1.2
[56f22d72] + Artifacts v1.11.0
[2a0f44e3] + Base64 v1.11.0
[ade2ca70] + Dates v1.11.0
[f43a241f] + Downloads v1.6.0
[7b1f6079] + FileWatching v1.11.0
[9fa8497b] + Future v1.11.0
[b77e0a4c] + InteractiveUtils v1.11.0
[b27032c2] + LibCURL v0.6.4
[76f85450] + LibGit2 v1.11.0
[8f399da3] + Libdl v1.11.0
[37e2e46d] + LinearAlgebra v1.11.0
[56ddb016] + Logging v1.11.0
[d6f4376e] + Markdown v1.11.0
[a63ad114] + Mmap v1.11.0
[ca575930] + NetworkOptions v1.2.0
[44cfe95a] + Pkg v1.11.0
[de0858da] + Printf v1.11.0
[3fa0cd96] + REPL v1.11.0
[9a3f8284] + Random v1.11.0
[ea8e919c] + SHA v0.7.0
[9e88b42a] + Serialization v1.11.0
[6462fe0b] + Sockets v1.11.0
[2f01184e] + SparseArrays v1.11.0
[f489334b] + StyledStrings v1.11.0
[fa267f1f] + TOML v1.0.3
[a4e569a6] + Tar v1.10.0
[cf7118a7] + UUIDs v1.11.0
[4ec0a83e] + Unicode v1.11.0
[e66e0078] + CompilerSupportLibraries_jll v1.1.1+0
[deac9b47] + LibCURL_jll v8.6.0+0
[e37daf67] + LibGit2_jll v1.7.2+0
[29816b5a] + LibSSH2_jll v1.11.0+1
[c8ffd9c3] + MbedTLS_jll v2.28.6+0
[14a3606d] + MozillaCACerts_jll v2023.12.12
[4536629a] + OpenBLAS_jll v0.3.27+1
[05823500] + OpenLibm_jll v0.8.5+0
[bea87d4a] + SuiteSparse_jll v7.7.0+0
[83775a58] + Zlib_jll v1.2.13+1
[8e850b90] + libblastrampoline_jll v5.11.0+0
[8e850ede] + nghttp2_jll v1.59.0+0
[3f19e933] + p7zip_jll v17.4.0+2
Info Packages marked with ⌅ have new versions available but compatibility constraints restrict them from upgrading. To see why use `status --outdated -m`
Pkg.status()Status `~/Teaching/UCF/CAP-6318/book-myst/week02/Project.toml`
[0ae4a718] VegaDatasets v2.1.1
[112f6efa] VegaLite v3.3.0
- Note two things:
- We can now use the packages
- The
Pkg.addcommand had this line in the printout: Updating~/Teaching/UCF/CAP-6318/book-myst/week02/Project.toml
- We’ll demonstrate we can use the packages below, then we’ll dig into the
Project.toml
using VegaLite, VegaDatasets
dataset("cars") |>
@vlplot(
:point,
x=:Horsepower,
y=:Miles_per_Gallon,
color=:Origin,
width=400,
height=400
)Loading...
Package.toml¶
- Julia environments are managed and described using in a format called TOML (Tom’s obvious markup language) in a file Project.toml
- This file will be created and updated as needed by
Pkgas we runPkgcommands - Let’s see what our new Project.toml looks like:
println(String(read("Project.toml")))[deps]
VegaDatasets = "0ae4a718-28b7-58ec-9efb-cded64d6d5b4"
VegaLite = "112f6efa-9a02-5b7d-90c0-432ed331239a"
- This shows us we have a
[deps]section with entries for the three packages we installed - Each package line has the
NAME = UUIDsyntax - There can be other top level items (not in a section) and other sections
- We’ll discuss these as they come up
Manifest.toml¶
- Notice that the Project.toml file does not have any information about the version of our installed packages
- There is a companion file called Manifest.toml that does have this information
- Let’s take a look:
println(String(read("Manifest.toml")))# This file is machine-generated - editing it directly is not advised
julia_version = "1.11.6"
manifest_format = "2.0"
project_hash = "933e48d381787bff6d1dc3c57ff3487e8924b34d"
[[deps.ArgTools]]
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
version = "1.1.2"
[[deps.Artifacts]]
uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
version = "1.11.0"
[[deps.Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
version = "1.11.0"
[[deps.BufferedStreams]]
git-tree-sha1 = "6863c5b7fc997eadcabdbaf6c5f201dc30032643"
uuid = "e1450e63-4bb3-523b-b2a4-4ffa8c0fd77d"
version = "1.2.2"
[[deps.CodecZlib]]
deps = ["TranscodingStreams", "Zlib_jll"]
git-tree-sha1 = "962834c22b66e32aa10f7611c08c8ca4e20749a9"
uuid = "944b1d66-785c-5afd-91f1-9de20f533193"
version = "0.7.8"
[[deps.Compat]]
deps = ["TOML", "UUIDs"]
git-tree-sha1 = "0037835448781bb46feb39866934e243886d756a"
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
version = "4.18.0"
weakdeps = ["Dates", "LinearAlgebra"]
[deps.Compat.extensions]
CompatLinearAlgebraExt = "LinearAlgebra"
[[deps.CompilerSupportLibraries_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae"
version = "1.1.1+0"
[[deps.ConstructionBase]]
git-tree-sha1 = "b4b092499347b18a015186eae3042f72267106cb"
uuid = "187b0558-2788-49d3-abe0-74a17ed4e7c9"
version = "1.6.0"
[deps.ConstructionBase.extensions]
ConstructionBaseIntervalSetsExt = "IntervalSets"
ConstructionBaseLinearAlgebraExt = "LinearAlgebra"
ConstructionBaseStaticArraysExt = "StaticArrays"
[deps.ConstructionBase.weakdeps]
IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
[[deps.DataAPI]]
git-tree-sha1 = "abe83f3a2f1b857aac70ef8b269080af17764bbe"
uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
version = "1.16.0"
[[deps.DataStructures]]
deps = ["Compat", "InteractiveUtils", "OrderedCollections"]
git-tree-sha1 = "4e1fe97fdaed23e9dc21d4d664bea76b65fc50a0"
uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
version = "0.18.22"
[[deps.DataValueInterfaces]]
git-tree-sha1 = "bfc1187b79289637fa0ef6d4436ebdfe6905cbd6"
uuid = "e2d170a0-9d28-54be-80f0-106bbe20a464"
version = "1.0.0"
[[deps.DataValues]]
deps = ["DataValueInterfaces", "Dates"]
git-tree-sha1 = "d88a19299eba280a6d062e135a43f00323ae70bf"
uuid = "e7dc6d0d-1eca-5fa6-8ad6-5aecde8b7ea5"
version = "0.4.13"
[[deps.Dates]]
deps = ["Printf"]
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"
version = "1.11.0"
[[deps.DocStringExtensions]]
git-tree-sha1 = "7442a5dfe1ebb773c29cc2962a8980f47221d76c"
uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
version = "0.9.5"
[[deps.DoubleFloats]]
deps = ["GenericLinearAlgebra", "LinearAlgebra", "Polynomials", "Printf", "Quadmath", "Random", "Requires", "SpecialFunctions"]
git-tree-sha1 = "1ee9bc92a6b862a5ad556c52a3037249209bec1a"
uuid = "497a8b3b-efae-58df-a0af-a86822472b78"
version = "1.4.3"
[[deps.Downloads]]
deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"]
uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
version = "1.6.0"
[[deps.FileIO]]
deps = ["Pkg", "Requires", "UUIDs"]
git-tree-sha1 = "b66970a70db13f45b7e57fbda1736e1cf72174ea"
uuid = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
version = "1.17.0"
[deps.FileIO.extensions]
HTTPExt = "HTTP"
[deps.FileIO.weakdeps]
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
[[deps.FilePaths]]
deps = ["FilePathsBase", "MacroTools", "Reexport", "Requires"]
git-tree-sha1 = "919d9412dbf53a2e6fe74af62a73ceed0bce0629"
uuid = "8fc22ac5-c921-52a6-82fd-178b2807b824"
version = "0.8.3"
[[deps.FilePathsBase]]
deps = ["Compat", "Dates"]
git-tree-sha1 = "3bab2c5aa25e7840a4b065805c0cdfc01f3068d2"
uuid = "48062228-2e41-5def-b9a4-89aafe57970f"
version = "0.9.24"
[deps.FilePathsBase.extensions]
FilePathsBaseMmapExt = "Mmap"
FilePathsBaseTestExt = "Test"
[deps.FilePathsBase.weakdeps]
Mmap = "a63ad114-7e13-5084-954f-fe012c677804"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
[[deps.FileWatching]]
uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee"
version = "1.11.0"
[[deps.Future]]
deps = ["Random"]
uuid = "9fa8497b-333b-5362-9e8d-4d0656e87820"
version = "1.11.0"
[[deps.GenericLinearAlgebra]]
deps = ["LinearAlgebra", "Printf", "Random", "libblastrampoline_jll"]
git-tree-sha1 = "37cef077b50d28b2542c1adb4c5427871a759d12"
uuid = "14197337-ba66-59df-a3e3-ca00e7dcff7a"
version = "0.3.18"
[[deps.InlineStrings]]
git-tree-sha1 = "8594fac023c5ce1ef78260f24d1ad18b4327b420"
uuid = "842dd82b-1e85-43dc-bf29-5d0ee9dffc48"
version = "1.4.4"
[deps.InlineStrings.extensions]
ArrowTypesExt = "ArrowTypes"
ParsersExt = "Parsers"
[deps.InlineStrings.weakdeps]
ArrowTypes = "31f734f8-188a-4ce0-8406-c8a06bd891cd"
Parsers = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
[[deps.InteractiveUtils]]
deps = ["Markdown"]
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
version = "1.11.0"
[[deps.IrrationalConstants]]
git-tree-sha1 = "e2222959fbc6c19554dc15174c81bf7bf3aa691c"
uuid = "92d709cd-6900-40b7-9082-c6be49f344b6"
version = "0.2.4"
[[deps.IterableTables]]
deps = ["DataValues", "IteratorInterfaceExtensions", "Requires", "TableTraits", "TableTraitsUtils"]
git-tree-sha1 = "70300b876b2cebde43ebc0df42bc8c94a144e1b4"
uuid = "1c8ee90f-4401-5389-894e-7a04a3dc0f4d"
version = "1.0.0"
[[deps.IteratorInterfaceExtensions]]
git-tree-sha1 = "a3f24677c21f5bbe9d2a714f95dcd58337fb2856"
uuid = "82899510-4779-5014-852e-03e436cf321d"
version = "1.0.0"
[[deps.JLLWrappers]]
deps = ["Artifacts", "Preferences"]
git-tree-sha1 = "0533e564aae234aff59ab625543145446d8b6ec2"
uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210"
version = "1.7.1"
[[deps.JSON]]
deps = ["Dates", "Mmap", "Parsers", "Unicode"]
git-tree-sha1 = "31e996f0a15c7b280ba9f76636b3ff9e2ae58c9a"
uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
version = "0.21.4"
[[deps.JSON3]]
deps = ["Dates", "Mmap", "Parsers", "PrecompileTools", "StructTypes", "UUIDs"]
git-tree-sha1 = "411eccfe8aba0814ffa0fdf4860913ed09c34975"
uuid = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
version = "1.14.3"
[deps.JSON3.extensions]
JSON3ArrowExt = ["ArrowTypes"]
[deps.JSON3.weakdeps]
ArrowTypes = "31f734f8-188a-4ce0-8406-c8a06bd891cd"
[[deps.JSONSchema]]
deps = ["Downloads", "JSON", "JSON3", "URIs"]
git-tree-sha1 = "243f1cdb476835d7c249deb9f29ad6b7827da7d3"
uuid = "7d188eb4-7ad8-530c-ae41-71a32a6d4692"
version = "1.4.1"
[[deps.LibCURL]]
deps = ["LibCURL_jll", "MozillaCACerts_jll"]
uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21"
version = "0.6.4"
[[deps.LibCURL_jll]]
deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"]
uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0"
version = "8.6.0+0"
[[deps.LibGit2]]
deps = ["Base64", "LibGit2_jll", "NetworkOptions", "Printf", "SHA"]
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"
version = "1.11.0"
[[deps.LibGit2_jll]]
deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll"]
uuid = "e37daf67-58a4-590a-8e99-b0245dd2ffc5"
version = "1.7.2+0"
[[deps.LibSSH2_jll]]
deps = ["Artifacts", "Libdl", "MbedTLS_jll"]
uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8"
version = "1.11.0+1"
[[deps.Libdl]]
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
version = "1.11.0"
[[deps.LinearAlgebra]]
deps = ["Libdl", "OpenBLAS_jll", "libblastrampoline_jll"]
uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
version = "1.11.0"
[[deps.LogExpFunctions]]
deps = ["DocStringExtensions", "IrrationalConstants", "LinearAlgebra"]
git-tree-sha1 = "13ca9e2586b89836fd20cccf56e57e2b9ae7f38f"
uuid = "2ab3a3ac-af41-5b50-aa03-7779005ae688"
version = "0.3.29"
[deps.LogExpFunctions.extensions]
LogExpFunctionsChainRulesCoreExt = "ChainRulesCore"
LogExpFunctionsChangesOfVariablesExt = "ChangesOfVariables"
LogExpFunctionsInverseFunctionsExt = "InverseFunctions"
[deps.LogExpFunctions.weakdeps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
ChangesOfVariables = "9e997f8a-9a97-42d5-a9f1-ce6bfc15e2c0"
InverseFunctions = "3587e190-3f89-42d0-90ee-14403ec27112"
[[deps.Logging]]
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
version = "1.11.0"
[[deps.MacroTools]]
git-tree-sha1 = "1e0228a030642014fe5cfe68c2c0a818f9e3f522"
uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
version = "0.5.16"
[[deps.Markdown]]
deps = ["Base64"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
version = "1.11.0"
[[deps.MbedTLS_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"
version = "2.28.6+0"
[[deps.Missings]]
deps = ["DataAPI"]
git-tree-sha1 = "ec4f7fbeab05d7747bdf98eb74d130a2a2ed298d"
uuid = "e1d29d7a-bbdc-5cf2-9ac0-f12de2c33e28"
version = "1.2.0"
[[deps.Mmap]]
uuid = "a63ad114-7e13-5084-954f-fe012c677804"
version = "1.11.0"
[[deps.MozillaCACerts_jll]]
uuid = "14a3606d-f60d-562e-9121-12d972cd8159"
version = "2023.12.12"
[[deps.NetworkOptions]]
uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908"
version = "1.2.0"
[[deps.NodeJS]]
deps = ["Pkg"]
git-tree-sha1 = "bf1f49fd62754064bc42490a8ddc2aa3694a8e7a"
uuid = "2bd173c7-0d6d-553b-b6af-13a54713934c"
version = "2.0.0"
[[deps.Nullables]]
git-tree-sha1 = "8f87854cc8f3685a60689d8edecaa29d2251979b"
uuid = "4d1e1d77-625e-5b40-9113-a560ec7a8ecd"
version = "1.0.0"
[[deps.OpenBLAS_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"]
uuid = "4536629a-c528-5b80-bd46-f80d51c5b363"
version = "0.3.27+1"
[[deps.OpenLibm_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "05823500-19ac-5b8b-9628-191a04bc5112"
version = "0.8.5+0"
[[deps.OpenSpecFun_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl"]
git-tree-sha1 = "1346c9208249809840c91b26703912dff463d335"
uuid = "efe28fd5-8261-553b-a9e1-b2916fc3738e"
version = "0.5.6+0"
[[deps.OrderedCollections]]
git-tree-sha1 = "05868e21324cede2207c6f0f466b4bfef6d5e7ee"
uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
version = "1.8.1"
[[deps.Parsers]]
deps = ["Dates", "PrecompileTools", "UUIDs"]
git-tree-sha1 = "7d2f8f21da5db6a806faf7b9b292296da42b2810"
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
version = "2.8.3"
[[deps.Pkg]]
deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "Random", "SHA", "TOML", "Tar", "UUIDs", "p7zip_jll"]
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
version = "1.11.0"
weakdeps = ["REPL"]
[deps.Pkg.extensions]
REPLExt = "REPL"
[[deps.Polynomials]]
deps = ["LinearAlgebra", "OrderedCollections", "RecipesBase", "Requires", "Setfield", "SparseArrays"]
git-tree-sha1 = "972089912ba299fba87671b025cd0da74f5f54f7"
uuid = "f27b6e38-b328-58d1-80ce-0feddd5e7a45"
version = "4.1.0"
[deps.Polynomials.extensions]
PolynomialsChainRulesCoreExt = "ChainRulesCore"
PolynomialsFFTWExt = "FFTW"
PolynomialsMakieExt = "Makie"
PolynomialsMutableArithmeticsExt = "MutableArithmetics"
[deps.Polynomials.weakdeps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
MutableArithmetics = "d8a4904e-b15c-11e9-3269-09a3773c0cb0"
[[deps.PrecompileTools]]
deps = ["Preferences"]
git-tree-sha1 = "5aa36f7049a63a1528fe8f7c3f2113413ffd4e1f"
uuid = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
version = "1.2.1"
[[deps.Preferences]]
deps = ["TOML"]
git-tree-sha1 = "0f27480397253da18fe2c12a4ba4eb9eb208bf3d"
uuid = "21216c6a-2e73-6563-6e65-726566657250"
version = "1.5.0"
[[deps.Printf]]
deps = ["Unicode"]
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"
version = "1.11.0"
[[deps.Quadmath]]
deps = ["Compat", "Printf", "Random", "Requires"]
git-tree-sha1 = "6bc924717c495f24de85867aa94da4de0e6cd1a1"
uuid = "be4d8f0f-7fa4-5f49-b795-2f01399ab2dd"
version = "0.5.13"
[[deps.REPL]]
deps = ["InteractiveUtils", "Markdown", "Sockets", "StyledStrings", "Unicode"]
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
version = "1.11.0"
[[deps.Random]]
deps = ["SHA"]
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
version = "1.11.0"
[[deps.RecipesBase]]
deps = ["PrecompileTools"]
git-tree-sha1 = "5c3d09cc4f31f5fc6af001c250bf1278733100ff"
uuid = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
version = "1.3.4"
[[deps.Reexport]]
git-tree-sha1 = "45e428421666073eab6f2da5c9d310d99bb12f9b"
uuid = "189a3867-3050-52da-a836-e630ba90ab69"
version = "1.2.2"
[[deps.Requires]]
deps = ["UUIDs"]
git-tree-sha1 = "62389eeff14780bfe55195b7204c0d8738436d64"
uuid = "ae029012-a4dd-5104-9daa-d747884805df"
version = "1.3.1"
[[deps.SHA]]
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
version = "0.7.0"
[[deps.Serialization]]
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
version = "1.11.0"
[[deps.Setfield]]
deps = ["ConstructionBase", "Future", "MacroTools", "StaticArraysCore"]
git-tree-sha1 = "c5391c6ace3bc430ca630251d02ea9687169ca68"
uuid = "efcf1570-3423-57d1-acb7-fd33fddbac46"
version = "1.1.2"
[[deps.Sockets]]
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
version = "1.11.0"
[[deps.SparseArrays]]
deps = ["Libdl", "LinearAlgebra", "Random", "Serialization", "SuiteSparse_jll"]
uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
version = "1.11.0"
[[deps.SpecialFunctions]]
deps = ["IrrationalConstants", "LogExpFunctions", "OpenLibm_jll", "OpenSpecFun_jll"]
git-tree-sha1 = "41852b8679f78c8d8961eeadc8f62cef861a52e3"
uuid = "276daf66-3868-5448-9aa4-cd146d93841b"
version = "2.5.1"
[deps.SpecialFunctions.extensions]
SpecialFunctionsChainRulesCoreExt = "ChainRulesCore"
[deps.SpecialFunctions.weakdeps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
[[deps.StaticArraysCore]]
git-tree-sha1 = "192954ef1208c7019899fbf8049e717f92959682"
uuid = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
version = "1.4.3"
[[deps.StructTypes]]
deps = ["Dates", "UUIDs"]
git-tree-sha1 = "159331b30e94d7b11379037feeb9b690950cace8"
uuid = "856f2bd8-1eba-4b0a-8007-ebc267875bd4"
version = "1.11.0"
[[deps.StyledStrings]]
uuid = "f489334b-da3d-4c2e-b8f0-e476e12c162b"
version = "1.11.0"
[[deps.SuiteSparse_jll]]
deps = ["Artifacts", "Libdl", "libblastrampoline_jll"]
uuid = "bea87d4a-7f5b-5778-9afe-8cc45184846c"
version = "7.7.0+0"
[[deps.TOML]]
deps = ["Dates"]
uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
version = "1.0.3"
[[deps.TableShowUtils]]
deps = ["DataValues", "Dates", "JSON", "Markdown", "Unicode"]
git-tree-sha1 = "2a41a3dedda21ed1184a47caab56ed9304e9a038"
uuid = "5e66a065-1f0a-5976-b372-e0b8c017ca10"
version = "0.2.6"
[[deps.TableTraits]]
deps = ["IteratorInterfaceExtensions"]
git-tree-sha1 = "c06b2f539df1c6efa794486abfb6ed2022561a39"
uuid = "3783bdb8-4a98-5b6b-af9a-565f29a5fe9c"
version = "1.0.1"
[[deps.TableTraitsUtils]]
deps = ["DataValues", "IteratorInterfaceExtensions", "Missings", "TableTraits"]
git-tree-sha1 = "78fecfe140d7abb480b53a44f3f85b6aa373c293"
uuid = "382cd787-c1b6-5bf2-a167-d5b971a19bda"
version = "1.0.2"
[[deps.Tar]]
deps = ["ArgTools", "SHA"]
uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"
version = "1.10.0"
[[deps.TextParse]]
deps = ["CodecZlib", "DataStructures", "Dates", "DoubleFloats", "Mmap", "Nullables", "WeakRefStrings"]
git-tree-sha1 = "43eddc3c0d788ebfc8a72bde108825ac65e66b11"
uuid = "e0df1984-e451-5cb5-8b61-797a481e67e3"
version = "1.0.3"
[[deps.TranscodingStreams]]
git-tree-sha1 = "0c45878dcfdcfa8480052b6ab162cdd138781742"
uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa"
version = "0.11.3"
[[deps.URIParser]]
deps = ["Unicode"]
git-tree-sha1 = "53a9f49546b8d2dd2e688d216421d050c9a31d0d"
uuid = "30578b45-9adc-5946-b283-645ec420af67"
version = "0.4.1"
[[deps.URIs]]
git-tree-sha1 = "bef26fb046d031353ef97a82e3fdb6afe7f21b1a"
uuid = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4"
version = "1.6.1"
[[deps.UUIDs]]
deps = ["Random", "SHA"]
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
version = "1.11.0"
[[deps.Unicode]]
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
version = "1.11.0"
[[deps.Vega]]
deps = ["BufferedStreams", "DataStructures", "DataValues", "Dates", "FileIO", "FilePaths", "IteratorInterfaceExtensions", "JSON", "JSONSchema", "MacroTools", "NodeJS", "Pkg", "REPL", "Random", "Setfield", "TableTraits", "TableTraitsUtils", "URIParser"]
git-tree-sha1 = "0efd71a3df864e86d24236c99aaae3970e6f0ed0"
uuid = "239c3e63-733f-47ad-beb7-a12fde22c578"
version = "2.7.0"
[[deps.VegaDatasets]]
deps = ["DataStructures", "DataValues", "FilePaths", "IterableTables", "IteratorInterfaceExtensions", "JSON", "TableShowUtils", "TableTraits", "TableTraitsUtils", "TextParse"]
git-tree-sha1 = "c997c7217f37205c5795de8c797f8f8531890f1d"
uuid = "0ae4a718-28b7-58ec-9efb-cded64d6d5b4"
version = "2.1.1"
[[deps.VegaLite]]
deps = ["Base64", "BufferedStreams", "DataStructures", "DataValues", "Dates", "FileIO", "FilePaths", "IteratorInterfaceExtensions", "JSON", "MacroTools", "NodeJS", "Pkg", "REPL", "Random", "TableTraits", "TableTraitsUtils", "URIParser", "Vega"]
git-tree-sha1 = "79115432a0a40955f071bccc6e5574ae5567a7b0"
uuid = "112f6efa-9a02-5b7d-90c0-432ed331239a"
version = "3.3.0"
[[deps.WeakRefStrings]]
deps = ["DataAPI", "InlineStrings", "Parsers"]
git-tree-sha1 = "b1be2855ed9ed8eac54e5caff2afcdb442d52c23"
uuid = "ea10d353-3f73-51f8-a26c-33c1cb351aa5"
version = "1.4.2"
[[deps.Zlib_jll]]
deps = ["Libdl"]
uuid = "83775a58-1f1d-513f-b197-d71354ab007a"
version = "1.2.13+1"
[[deps.libblastrampoline_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "8e850b90-86db-534c-a0d3-1478176c7d93"
version = "5.11.0+0"
[[deps.nghttp2_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d"
version = "1.59.0+0"
[[deps.p7zip_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0"
version = "17.4.0+2"
- The
Manifest.tomlfile is a very comprehensive overview of ALL details about a Julia environment - This file is rarely (if ever) touched by humans
- It can be used to reproduce an exact replica of the Julia version, packages, and package versions on any machine
Set up environment on new machine¶
- If you are given a Project.toml/Manifest.toml combo, you can easily create a duplicate of teh author’s Julia environment
- To do this follow these two steps:
- Call
Pkg.activate(".")(orpkg> activate) from the directory containing the .toml files - Call
Pkg.instantiate()(orpkg> instantiate)
- Call
- This will first activate the Project’s environment in your current Julia session and then install all dependencies
using Pkg
Pkg.activate(".")
Pkg.instantiate() Activating project at `~/Teaching/UCF/CAP-6318/book-myst/week02`
Package Development¶
- The vast majority of Julia itself -- including the packages in its standard library -- are written in Julia
- This means that to be a package author you really only need to know Julia
- Since you know Julia, you can author packages!
- The
Pkgmodule has ageneratefunction to help us develop packages, however Julia authors reccomend using the first partyPkgTemplates.jlpackage to start a new package - So, we’ll start by installing
PkgTemplates
using Pkg
Pkg.add("PkgTemplates")
using PkgTemplates Resolving package versions...
Installed PkgTemplates ─ v0.7.56
Updating `~/Teaching/UCF/CAP-6318/book-myst/week02/Project.toml`
[14b8a8f1] + PkgTemplates v0.7.56
Updating `~/Teaching/UCF/CAP-6318/book-myst/week02/Manifest.toml`
[e2ba6199] + ExprTools v0.1.10
[78c3b35d] + Mocking v0.8.1
[ffc61752] + Mustache v1.0.21
[d96e819e] + Parameters v0.12.3
[14b8a8f1] + PkgTemplates v0.7.56
[bd369af6] + Tables v1.12.1
[3a884ed6] + UnPack v1.0.2
Precompiling project...
1669.1 ms ✓ PkgTemplates
1 dependency successfully precompiled in 2 seconds. 96 already precompiled.
CAP6318¶
- As we progress throughout the semseter we will build up a toolbox of useful types and functions
- Let’s organize these into a helpful package called
CAP6318 - We can also use this package as a way to specify dependencies specifically required for the course
- To create our package we will need to follow the PkgTemplates.jl documentation to (1) establish the template for our project and (2) run the template on our project name
t = Template(;
user="sglyon", # TODO: you change this!
plugins=[PkgTemplates.Develop(), ]
)
package_dir = t("CAP6318")┌ Info: Running prehooks
└ @ PkgTemplates /Users/sglyon/.julia/packages/PkgTemplates/5mBnk/src/template.jl:137
┌ Info: Running hooks
└ @ PkgTemplates /Users/sglyon/.julia/packages/PkgTemplates/5mBnk/src/template.jl:137
Activating project at `~/.julia/dev/CAP6318`
Updating registry at `~/.julia/registries/General.toml`
No Changes to `~/.julia/dev/CAP6318/Project.toml`
No Changes to `~/.julia/dev/CAP6318/Manifest.toml`
Precompiling project...
199.5 ms ✓ CAP6318
1 dependency successfully precompiled in 0 seconds
Activating project at `~/Teaching/UCF/CAP-6318/book-myst/week02`
┌ Info: Running posthooks
└ @ PkgTemplates /Users/sglyon/.julia/packages/PkgTemplates/5mBnk/src/template.jl:137
Resolving package versions...
Updating `~/Teaching/UCF/CAP-6318/book-myst/week02/Project.toml`
[8b4527b1] + CAP6318 v1.0.0-DEV `~/.julia/dev/CAP6318`
Updating `~/Teaching/UCF/CAP-6318/book-myst/week02/Manifest.toml`
[8b4527b1] + CAP6318 v1.0.0-DEV `~/.julia/dev/CAP6318`
┌ Info: New package is at /Users/sglyon/.julia/dev/CAP6318
└ @ PkgTemplates /Users/sglyon/.julia/packages/PkgTemplates/5mBnk/src/template.jl:147
"/Users/sglyon/.julia/dev/CAP6318"- Notice that the code generated a new project in
~/.julia/dev/CAP6318 - Let’s take a look at was created for us
- Let’s see what was created for us
cmd =`tree $package_dir`
println("About to run: $cmd")
run(cmd);About to run: `tree /Users/sglyon/.julia/dev/CAP6318`
/Users/sglyon/.julia/dev/CAP6318
├── LICENSE
├── Manifest.toml
├── Project.toml
├── README.md
├── src
│ └── CAP6318.jl
└── test
└── runtests.jl
3 directories, 6 files
- Here we see a LICENSE, Manifest.toml/Project.toml pair, and a README.md (for usage instructions) in the top folder
- Then inside
src/we have a module fileCAP6318.jl - Inside
test/we have aruntests.jlfile - Let’s peek inside the files
print_pkg_file(parts::String...) = println(String(read(joinpath(package_dir, parts...))))
print_pkg_file("Project.toml")name = "CAP6318"
uuid = "8b4527b1-c17c-4ce8-a82d-b872f04552bb"
authors = ["Spencer Lyon <spencerlyon2@gmail.com> and contributors"]
version = "1.0.0-DEV"
[compat]
julia = "1.6.7"
[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
[targets]
test = ["Test"]
print_pkg_file("src", "CAP6318.jl")module CAP6318
# Write your package code here.
end
print_pkg_file("test", "runtests.jl")using CAP6318
using Test
@testset "CAP6318.jl" begin
# Write your tests here.
end
- Ok, we have a nicely structured starting point
- We will add to this throughout the course
Exercise¶
Perform the following tasks
- Activate the project by doing
activate CAP6318. Because we specifiedDevelop()in our template and this is the package name we do not need to be in the same directory or pass the directory path - Install
CSV, DataFrames, VegaLite, Graphsin the CAP6318 project. We’ll use them later - Ensure that you installed these correctly by using the
print_pkg_filefunction above and looking for the[deps]section - Create a new function
greet() = println("Hello from CAP6318")in yoursrc/CAP6318.jlmodule file. Note you will have to open this file in your text editor - Call
using CAP6318then rungreet()to see your message