Skip to content

Commit a750190

Browse files
committed
Finished pkg.md
1 parent 4d57ada commit a750190

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

docs/src/lecture_06/pkg.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
# Package management
22

3-
Julia provides a simple and intuitive built-in package manager, that handles operations such as installing, updating, and removing packages. The package manager provides an interactive Pkg REPL, which simplifies the package management process. The Pkg REPL can be entered from the Julia REPL simply by pressing `]`. To get back to the Julia REPL, press backspace or `^C`. After entering the Pkg REPL, the screen similar to the following one should appear
3+
Julia provides a simple and intuitive built-in package manager that handles operations such as installing, updating, and removing packages. The package manager offers an interactive Pkg REPL, which simplifies the package management process. The Pkg REPL can be entered from the Julia REPL simply by pressing `]`. To get back to the Julia REPL, press backspace or `^C`. After entering the Pkg REPL, the screen similar to the following one should appear.
44

55
```julia
66
(@v1.5) pkg>
77
```
88

9-
Registered packages can be installed using the `add` keyword in the following way
9+
Registered packages can be installed using the `add` keyword in the following way.
1010

1111
```julia
1212
(@v1.5) pkg> add JSON BSON
1313
```
1414

15-
Note that it is possible to install multiple packages at once simply by entering their names separated by a space. It is also possible to install the unregistered package using the `add` keyword. However, in this case, we have to specify an URL of a git repository
15+
Note that it is possible to install multiple packages simply by entering their names separated by a space. It is also possible to install the unregistered package using the `add` keyword. However, in this case, we have to specify an URL of a git repository.
1616

1717
```julia
1818
(@v1.5) pkg> add https://github.com/JuliaLang/Example.jl
1919
```
2020

21-
or absolute/relative path to the local git repository
21+
It is also possible to use the absolute/relative path to the local git repository.
2222

2323
```julia
2424
(@v1.5) pkg> add /absolute/or/relative/path/MyPackage
@@ -39,7 +39,7 @@ Status `~/.julia/environments/v1.5/Project.toml`
3939
<header class = "info-header">Adding specific version</header><p>
4040
```
4141

42-
In most cases, we want to install the latest stable version of the package. However, it may occur that we want to use the older version of the package or the version from a different git branch that is not yet released. A specific version of the package can be installed by appending a version after a `@` symbol.
42+
In most cases, we want to install the latest stable version of the package. However, we may want to use the older version of the package or the version from a different git branch that is not yet released. A specific version of the package can be installed by appending a version after a `@` symbol.
4343

4444
```julia
4545
(@v1.5) pkg> add BSON@0.2.1
@@ -69,7 +69,7 @@ Status `~/.julia/environments/v1.5/Project.toml`
6969
</p></div>
7070
```
7171

72-
If we want to update some package (for example, because the new version was released), we can do it using the `update` keyword followed by the package name
72+
If we want to update some packages (for example, because the new version was released), we can do it using the `update` keyword followed by the package name.
7373

7474
```julia
7575
(@v1.5) pkg> update Example
@@ -87,7 +87,7 @@ Status `~/.julia/environments/v1.5/Project.toml`
8787
[682c06a0] JSON v0.21.1
8888
```
8989

90-
Note the pin symbol `` showing that the package is pinned. Removing the pin is done using the `free` command
90+
Note the pin symbol `` showing that the package is pinned. Removing the pin is done using the `free` command.
9191

9292
```julia
9393
(@v1.5) pkg> free BSON
@@ -99,7 +99,7 @@ Status `~/.julia/environments/v1.5/Project.toml`
9999
[682c06a0] JSON v0.21.1
100100
```
101101

102-
Any installed package can be removed using the `rm` keyword similarly as the installation works
102+
Any installed package can be removed using the `rm` keyword similarly as the installation works.
103103

104104
```julia
105105
(@v1.5) pkg> rm Example
@@ -110,7 +110,7 @@ Any installed package can be removed using the `rm` keyword similarly as the ins
110110
<header class = "info-header">Non-interactive package manager</header><p>
111111
```
112112

113-
The package manager can also be used in a non-interactive way. For example, packages can be installed in the following way
113+
The package manager can also be used in a non-interactive way. For example, packages can be installed in the following way.
114114

115115
```julia
116116
using Pkg
@@ -131,7 +131,7 @@ Updating and removing a package can be done in a similar way.
131131

132132
So far, we have dealt with the basic management of packages: adding, updating, or removing packages. However, Julia's package manager offers significant advantages over traditional package managers by organizing dependencies into environments. Environments should be familiar to people who use Python. The difference between Python and Julia is that it is effortless to create and manage environments in Julia. Of course, some utilities simplify the work with environments in Python, such as the Conda package manager. However, in Julia, it is still more convenient, and the whole process of creating and managing environments can be done within Julia itself.
133133

134-
You may have noticed the (`v1.5`) in the REPL prompt. It indicates that the active environment is `v1.5`. The active environment is the environment that will be modified by `Pkg` commands such as `add`, `rm` or `update`.A new environment can be set up using the `activate` keyword followed by the absolute or relative path
134+
You may have noticed the (`v1.5`) in the REPL prompt. It indicates that the active environment is `v1.5`. The active environment is the environment that will be modified by `Pkg` commands such as `add`, `rm`, or `update`. A new environment can be set up using the `activate` keyword followed by the absolute or relative path.
135135

136136
```julia
137137
julia> mkdir("./tutorial") # create an empty folder tutorial
@@ -143,21 +143,21 @@ julia> mkdir("./tutorial") # create an empty folder tutorial
143143
(tutorial) pkg>
144144
```
145145

146-
In the example above, we create an empty directory `tutorial` and activate a new environment inside this directory. Note that the prompt in the package REPL changed from `@v1.5` to `tutorial`. It indicates that `tutorial` is the active environment, i.e., this environment will be modified by Pkg commands. Now we can check the status of the environment using the `status` keyword
146+
In the example above, we create an empty directory `tutorial` and activate a new environment inside this directory. Note that the prompt in the package REPL changed from `@v1.5` to `tutorial`. It indicates that `tutorial` is the active environment, i.e., this environment will be modified by Pkg commands. Now we can check the status of the environment using the `status` keyword.
147147

148148
```julia
149149
(tutorial) pkg> status
150150
Status `/tutorial/Project.toml` (empty project)
151151
```
152152

153-
Note that the path printed by the `status` command (`/tutorial/Project.toml`) is the location of the `Project.toml` corresponding to the active environment. A `Project.toml` is a file where the package manager stores metadata for the environment. Because we have not yet added any packages to the environment, the `Project.toml` is not created yet
153+
Note that the path printed by the `status` command (`/tutorial/Project.toml`) is the location of the `Project.toml` corresponding to the active environment. A `Project.toml` is a file where the package manager stores metadata for the environment. Because we have not yet added any packages to the environment, the `Project.toml` is not created yet.
154154

155155
```julia
156156
julia> readdir("./tutorial") # returns and empty array since tutorial is an empty folder
157157
String[]
158158
```
159159

160-
We can install packages to the `tutorial` environment in the same way as we did it in the section above
160+
We can install packages to the `tutorial` environment in the same way as we did it in the section above.
161161

162162
```julia
163163
(tutorial) pkg> add JSON BSON
@@ -177,6 +177,7 @@ julia> readdir("./tutorial")
177177
"Project.toml"
178178
```
179179

180+
We can install packages to the `tutorial` environment in the same way as we did in the section above.
180181
The `Project.toml` describes the project on a high level. For example, the package/project dependencies and compatibility constraints are listed in the `Project.toml` file. The `Manifest.toml` file is an absolute record of the state of the packages used in the environment. It includes exact information about (direct and indirect) dependencies of the project. Given a `Project.toml` + `Manifest.toml` pair, it is possible to [instantiate](https://julialang.github.io/Pkg.jl/v1/api/#Pkg.instantiate) the exact same package environment, which is very useful for reproducibility.
181182

182183
```julia

0 commit comments

Comments
 (0)