Skip to content

Commit 18c0d3b

Browse files
committed
deploy: b515eac
0 parents  commit 18c0d3b

File tree

978 files changed

+125965
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

978 files changed

+125965
-0
lines changed

.nojekyll

Whitespace-only changes.

_images/git-invoke-editor.png

305 KB
Loading

_images/vscode.png

50.7 KB
Loading

_sources/conda.md.txt

Lines changed: 261 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,261 @@
1+
# Conda environment
2+
3+
[this page is adapted from <https://aaltoscicomp.github.io/python-for-scicomp/installation/>]
4+
5+
You only need this if you wish to go through examples and exercises during the
6+
second workshop week on your own computer.
7+
8+
9+
## Choosing an installation method
10+
11+
For this course we will install an **isolated environment**
12+
with following dependencies:
13+
:::::{tabs}
14+
::::{tab} environment.yml
15+
:::{literalinclude} software/environment.yml
16+
:language: yaml
17+
:::
18+
::::
19+
20+
::::{tab} requirements.txt
21+
:::{literalinclude} software/requirements.txt
22+
:::
23+
::::
24+
:::::
25+
26+
:::{admonition} If you have a tool/method that works for you, keep using it
27+
If you are used to installing Conda packages and know what to do with the
28+
above files, please follow your own preferred installation
29+
method.
30+
31+
**If you are new to Conda or unsure** how to create isolated environments from
32+
files above, please follow the instructions below where we do this with the help
33+
of Miniforge.
34+
35+
If you already use **Anaconda** to manage your software environments, please
36+
continue using it. In this case you can skip {ref}`miniforge` and go directly to
37+
{ref}`conda-environment`.
38+
:::
39+
40+
41+
:::{admonition} Why do we recommend Miniforge and how does it relate to Conda?
42+
:class: dropdown
43+
44+
There are many choices and we try to suggest a good compromise
45+
There are very many ways to install packages with pros and cons and
46+
in addition there are several operating systems with their own quirks. This
47+
can be a huge challenge for beginners to navigate. It can also difficult for
48+
instructors to give recommendations for something which will work everywhere
49+
and which everybody will like.
50+
51+
Below we will recommend **Miniforge** since it is free, open source, general,
52+
available on all operating systems, and provides a good basis for reproducible
53+
environments. However, it does not provide a graphical user interface during
54+
installation.
55+
56+
But Miniforge is only one option. Unfortunately there are many options and a
57+
lot of jargon. Here is a crash course:
58+
59+
- **Conda** is a package manager: it allows distributing and
60+
installing packages, and is designed for complex scientific
61+
code.
62+
- **Mamba** is a re-implementation of Conda to be much faster with
63+
resolving dependencies and installing things.
64+
- An **environment** is a self-contained collections of packages
65+
which can be installed separately from others. They are used so
66+
each project can install what it needs without affecting others.
67+
- **Anaconda** is a commercial distribution of Python+Conda+many
68+
packages that all work together. It used to be freely usable for
69+
research, but since ~2023-2024 it's more limited. Thus, we don't
70+
recommend it (even though it has a nice graphical user interface).
71+
- **conda-forge** is another channel of distributing packages that
72+
is maintained by the community, and thus can be used by anyone.
73+
(Anaconda's parent company also hosts conda-forge packages)
74+
- **Miniforge** is the installer recommended by the conda-forge community. It operates via the command line.
75+
- **Miniconda** is a distribution of conda pre-configured to use
76+
the Anaconda channels.
77+
:::
78+
79+
80+
(miniforge)=
81+
82+
## Installing Miniforge
83+
84+
Download the latest release from the [Miniforge download
85+
overview](https://conda-forge.org/download/). This installs the base, and from
86+
here other packages can be installed.
87+
88+
Unsure what to download and what to do with it?
89+
::::{tabs}
90+
:::{group-tab} Windows
91+
You want to download and run `Miniforge3-Windows-x86_64.exe`.
92+
93+
When viewing the "Advanced installation options" step of the installer,
94+
leave the "Create shortcuts (supported packages only)." option **checked**,
95+
otherwise it will be difficult to launch the Miniforge prompt later.
96+
:::
97+
98+
:::{group-tab} MacOS
99+
You probably want to download the `Miniforge3-MacOSX-arm64.sh` file (unless
100+
you don't have an Arm processor) and then run it in the terminal with:
101+
```console
102+
$ bash Miniforge3-MacOSX-arm64.sh
103+
```
104+
:::
105+
106+
:::{group-tab} Linux
107+
You probably want to download the `Miniforge3-Linux-x86_64.sh` file (unless
108+
you don't have an x86_64 processor) and then run it in the terminal with:
109+
```console
110+
$ bash Miniforge3-Linux-x86_64.sh
111+
```
112+
:::
113+
::::
114+
115+
116+
(conda-environment)=
117+
118+
## Installing the software environment
119+
120+
First we will start a command line environment in a way that activates
121+
conda/mamba. Then we will install the software environment from [this
122+
environment.yml
123+
file](https://raw.githubusercontent.com/coderefinery/software/main/environment.yml)
124+
(this is the same file as on top of this page).
125+
126+
An **environment** is a self-contained set of extra libraries - different
127+
projects can use different environments to not interfere with each other. This
128+
environment will have all of the software needed for this particular course.
129+
130+
We will call the environment `coderefinery`.
131+
132+
::::{tabs}
133+
:::{group-tab} Windows
134+
Use the "Miniforge Prompt" to start Miniforge. This
135+
will set up everything so that ``conda`` and ``mamba`` are
136+
available.
137+
Then type
138+
(without the `$`):
139+
```console
140+
$ curl "https://raw.githubusercontent.com/coderefinery/software/main/environment.yml" -o environment.yml
141+
$ mamba env create -n coderefinery -f environment.yml
142+
```
143+
:::
144+
145+
:::{group-tab} Linux / MacOS
146+
Each time you start a new command line terminal,
147+
you can activate Miniforge by running
148+
(without the `$`):
149+
```console
150+
$ source ~/miniforge3/bin/activate
151+
```
152+
153+
This is needed so that
154+
Miniforge is usable wherever you need, but doesn't affect any
155+
other software on your computer (this is not needed if you
156+
choose "Do you wish to update your shell profile to
157+
automatically initialize conda?", but then it will always be
158+
active).
159+
160+
In the second step, we will install the software environment by first copying the definition file:
161+
```console
162+
$ curl "https://raw.githubusercontent.com/coderefinery/software/main/environment.yml" -o environment.yml
163+
$ mamba env create -n coderefinery -f environment.yml
164+
```
165+
:::
166+
::::
167+
168+
169+
(activating-environment)=
170+
171+
## Activating the software environment
172+
173+
::::{tabs}
174+
:::{group-tab} Windows
175+
Start the Miniforge Prompt. Then type
176+
(without the `$`):
177+
```console
178+
$ conda activate coderefinery
179+
$ jupyter-lab
180+
```
181+
:::
182+
183+
:::{group-tab} Linux / MacOS
184+
Start the terminal and in the terminal, type
185+
(without the `$`):
186+
```console
187+
$ source ~/miniforge3/bin/activate
188+
$ conda activate coderefinery
189+
$ jupyter-lab
190+
```
191+
:::
192+
::::
193+
194+
195+
## How to verify the environment
196+
197+
Make sure you are in the Miniforge prompt (Windows) or in a terminal (Linux/MacOS).
198+
199+
The following command should return a version number and not an error message:
200+
```console
201+
$ conda --version
202+
```
203+
204+
Is the coderefinery environment installed?
205+
```console
206+
$ conda env list
207+
```
208+
209+
Make sure it's activated ({ref}`activating-environment`).
210+
Once activated, try the following commands.
211+
212+
You should see versions printed and not see errors (exact version numbers are not too important):
213+
```console
214+
$ jupyter-lab --version
215+
216+
4.1.2
217+
218+
```
219+
```console
220+
$ pytest --version
221+
222+
8.0.2
223+
```
224+
225+
```console
226+
$ sphinx-build --version
227+
228+
sphinx-build 7.2.6
229+
```
230+
231+
```console
232+
$ snakemake --version
233+
234+
8.5.3
235+
```
236+
237+
238+
## Removing the software environment
239+
240+
::::{tabs}
241+
:::{group-tab} Windows
242+
In the Miniforge Prompt, type
243+
(without the `$`):
244+
```console
245+
$ conda env list
246+
$ conda env remove --name coderefinery
247+
$ conda env list
248+
```
249+
:::
250+
251+
:::{group-tab} Linux / MacOS
252+
In the terminal, type
253+
(without the `$`):
254+
```console
255+
$ source ~/miniforge3/bin/activate
256+
$ conda env list
257+
$ conda env remove --name coderefinery
258+
$ conda env list
259+
```
260+
:::
261+
::::

_sources/difftools.md.txt

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Visual diff tools (optional)
2+
3+
Visual diff tools allow to visualize differences between files side by side.
4+
They can be used independently of version control but when coupled with Git,
5+
they can provide a nice alternative to command line output to show differences
6+
between file versions or branches.
7+
8+
`````{tabs}
9+
````{tab} Windows
10+
11+
On Windows we recommend the program [meld](https://meldmerge.org).
12+
Please follow installation instructions from [http://meldmerge.org](http://meldmerge.org).
13+
14+
This is how you can configure Git to open Meld when doing `git difftool`:
15+
```console
16+
$ git config --global diff.tool meld
17+
$ git config --global mergetool.meld.path "C:\Program Files (x86)\Meld\Meld.exe"
18+
```
19+
For meld version 3.20.3, because of reasons discussed [here](https://gitlab.gnome.org/GNOME/meld/-/issues/559), you can have multiple "Could not create key" errors that you can get around by clicking 'Ignore'.
20+
Then, to open Meld when doing `git difftool`:
21+
```console
22+
$ git config --global diff.tool meld
23+
$ git config --global mergetool.meld.path "$LOCALAPPDATA\Programs\Meld\Meld.exe"
24+
```
25+
````
26+
27+
````{tab} macOS
28+
29+
For macOS we recommend to use Opendiff. You can install it following [this blog
30+
post](https://borgs.cybrilla.com/tils/opendiff-as-difftool/).
31+
````
32+
33+
````{tab} Linux
34+
35+
On Linux we recommend the program [meld](https://meldmerge.org).
36+
Install meld via your distribution package manager. For Debian/Ubuntu run:
37+
```console
38+
$ sudo apt-get install meld
39+
```
40+
41+
For Fedora:
42+
```console
43+
$ sudo dnf install meld
44+
```
45+
46+
This is how you can configure Git to open Meld when doing `git difftool`:
47+
```console
48+
$ git config --global diff.tool meld
49+
```
50+
````
51+
52+
``````
53+
54+
## How to verify the installation
55+
56+
To test it create two text files which are similar and then compare them
57+
with Meld or Diffuse or Opendiff (or the tool which you have chosen above for visual
58+
differences):
59+
```console
60+
$ meld file1 file2
61+
```
62+
or:
63+
```console
64+
$ diffuse file1 file2
65+
```
66+
or:
67+
```console
68+
$ opendiff file1 file2
69+
```
70+
71+
You should now see both versions side by side.
72+
73+
To test launching Meld through Git, move into a folder that contains two or more files and instruct Git to compare files.
74+
For example, to see the difference between `file1.txt` and `file2.txt`:
75+
```console
76+
$ git difftool --no-index file1.txt file2.txt
77+
```

0 commit comments

Comments
 (0)