Skip to content

Commit 8d3fb9a

Browse files
committed
deploy: d35a790
0 parents  commit 8d3fb9a

File tree

1,173 files changed

+151402
-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.

1,173 files changed

+151402
-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: 259 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,259 @@
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+
$ mamba env create -n coderefinery -f https://raw.githubusercontent.com/coderefinery/software/main/environment.yml
141+
```
142+
:::
143+
144+
:::{group-tab} Linux / MacOS
145+
Each time you start a new command line terminal,
146+
you can activate Miniforge by running
147+
(without the `$`):
148+
```console
149+
$ source ~/miniforge3/bin/activate
150+
```
151+
152+
This is needed so that
153+
Miniforge is usable wherever you need, but doesn't affect any
154+
other software on your computer (this is not needed if you
155+
choose "Do you wish to update your shell profile to
156+
automatically initialize conda?", but then it will always be
157+
active).
158+
159+
In the second step, we will install the software environment:
160+
```console
161+
$ mamba env create -n coderefinery -f https://raw.githubusercontent.com/coderefinery/software/main/environment.yml
162+
```
163+
:::
164+
::::
165+
166+
167+
(activating-environment)=
168+
169+
## Activating the software environment
170+
171+
::::{tabs}
172+
:::{group-tab} Windows
173+
Start the Miniforge Prompt. Then type
174+
(without the `$`):
175+
```console
176+
$ conda activate coderefinery
177+
$ jupyter-lab
178+
```
179+
:::
180+
181+
:::{group-tab} Linux / MacOS
182+
Start the terminal and in the terminal, type
183+
(without the `$`):
184+
```console
185+
$ source ~/miniforge3/bin/activate
186+
$ conda activate coderefinery
187+
$ jupyter-lab
188+
```
189+
:::
190+
::::
191+
192+
193+
## How to verify the environment
194+
195+
Make sure you are in the Miniforge prompt (Windows) or in a terminal (Linux/MacOS).
196+
197+
The following command should return a version number and not an error message:
198+
```console
199+
$ conda --version
200+
```
201+
202+
Is the coderefinery environment installed?
203+
```console
204+
$ conda env list
205+
```
206+
207+
Make sure it's activated ({ref}`activating-environment`).
208+
Once activated, try the following commands.
209+
210+
You should see versions printed and not see errors (exact version numbers are not too important):
211+
```console
212+
$ jupyter-lab --version
213+
214+
4.1.2
215+
216+
```
217+
```console
218+
$ pytest --version
219+
220+
8.0.2
221+
```
222+
223+
```console
224+
$ sphinx-build --version
225+
226+
sphinx-build 7.2.6
227+
```
228+
229+
```console
230+
$ snakemake --version
231+
232+
8.5.3
233+
```
234+
235+
236+
## Removing the software environment
237+
238+
::::{tabs}
239+
:::{group-tab} Windows
240+
In the Miniforge Prompt, type
241+
(without the `$`):
242+
```console
243+
$ conda env list
244+
$ conda env remove --name coderefinery
245+
$ conda env list
246+
```
247+
:::
248+
249+
:::{group-tab} Linux / MacOS
250+
In the terminal, type
251+
(without the `$`):
252+
```console
253+
$ source ~/miniforge3/bin/activate
254+
$ conda env list
255+
$ conda env remove --name coderefinery
256+
$ conda env list
257+
```
258+
:::
259+
::::

_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)