Skip to content

Instantly share code, notes, and snippets.

@crbinz
Last active August 11, 2018 01:00
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 crbinz/08c17626a6848945b834aa5b31fadde2 to your computer and use it in GitHub Desktop.
Save crbinz/08c17626a6848945b834aa5b31fadde2 to your computer and use it in GitHub Desktop.
Pkg workflow - Application development

An application is "a project which provides standalone functionality not intended to be reused by other Julia projects", per the docs

shell> pwd
/Users/cbinz/Code

(v0.7) pkg> generate MyApp
Generating project MyApp:
    MyApp/Project.toml
    MyApp/src/MyApp.jl

shell> cd MyApp
/Users/cbinz/Code/MyApp

(v0.7) pkg> activate . # changes current project to MyApp

(MyApp) pkg> add Example # add some dependency to MyApp; puts Example in [deps] in Project.toml, and puts Example and its dependencies into Manifest.toml 
  Updating registry at `~/.julia/registries/General`
  Updating git-repo `https://github.com/JuliaRegistries/General.git`
 Resolving package versions...
 Installed Example ─ v0.5.1
  Updating `Project.toml`
  [7876af07] + Example v0.5.1
  Updating `Manifest.toml`
  [7876af07] + Example v0.5.1
  [2a0f44e3] + Base64
  [8ba89e20] + Distributed
  [b77e0a4c] + InteractiveUtils
  [8f399da3] + Libdl
  [37e2e46d] + LinearAlgebra
  [56ddb016] + Logging
  [d6f4376e] + Markdown
  [9a3f8284] + Random
  [9e88b42a] + Serialization
  [6462fe0b] + Sockets
  [8dfed614] + Test

shell> cat Manifest.toml
[[Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

[[Distributed]]
deps = ["LinearAlgebra", "Random", "Serialization", "Sockets"]
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"

[[Example]]
deps = ["Test"]
git-tree-sha1 = "8eb7b4d4ca487caade9ba3e85932e28ce6d6e1f8"
uuid = "7876af07-990d-54b4-ab0e-23690620f79a"
version = "0.5.1"

[[InteractiveUtils]]
deps = ["LinearAlgebra", "Markdown"]
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"

[[Libdl]]
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"

[[LinearAlgebra]]
deps = ["Libdl"]
uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

[[Logging]]
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"

[[Markdown]]
deps = ["Base64"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"

[[Random]]
deps = ["Serialization"]
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[[Serialization]]
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"

[[Sockets]]
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"

[[Test]]
deps = ["Distributed", "InteractiveUtils", "Logging", "Random"]
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

shell> cat Project.toml
name = "MyApp"
uuid = "1c1d2e36-9cfe-11e8-1b52-ab36aa859629"
authors = ["Chris Binz <chris.binz@gmail.com>"]
version = "0.1.0"

[deps]
Example = "7876af07-990d-54b4-ab0e-23690620f79a"

Then the entire application can be recreated from the Manifest.toml and Project.toml

shell> rm -rf ~/.julia/packages/Example # get rid of Example

(MyApp) pkg> resolve # MyApp is still the current project
 Resolving package versions...
 Installed Example ─ v0.5.1
  Updating `Project.toml`
 [no changes]
  Updating `Manifest.toml`
 [no changes]

shell> ls ~/.julia/packages/
BinDeps  Compat  Conda	Crayons  Example  JSON	MacroTools  OhMyREPL  OrderedCollections  PyCall  Revise  SGP4	Tokenize  URIParser  VersionParsing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment