Skip to content

Commit 55ca9a3

Browse files
namirouesorbeckst
andauthored
Sdg23 update user guide installation instructions (#404)
* Redesign installation guide in User Guide * fixes #402 * fixes #405 * see also MDAnalysis/mdanalysis#4927 --------- Co-authored-by: Oliver Beckstein <[email protected]>
1 parent 07961c1 commit 55ca9a3

File tree

1 file changed

+182
-67
lines changed

1 file changed

+182
-67
lines changed

doc/source/installation.rst

Lines changed: 182 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,140 +1,227 @@
11
.. -*- coding: utf-8 -*-
22
33
====================
4-
Installation
4+
Installation Guide
55
====================
66

7-
The latest versions of **MDAnalysis** can be installed using `conda` or `pip`.
8-
Currently, the conda releases only support serial calculations.
9-
If you plan to use the parallel OpenMP algorithms, you need to
10-
install MDAnalysis with pip and have a working OpenMP installation.
7+
The latest version of **MDAnalysis** can be installed using :ref:`mamba-installation` (recommended),
8+
or :ref:`pip-installation`. If you need to install MDAnalysis from source, follow :ref:`source-installation`
9+
for stable releases. If you are a contributor or developer working on MDAnalysis, follow the
10+
:ref:`development-installation` for editable installation and code modifications.
1111

12-
MDAnalysis has a separate :ref:`test suite <mdanalysistests>` **MDAnalysisTests** that is required to run the test cases and examples.
13-
The test files change less frequently, take up around 90 MB of space,
14-
and are not needed for daily use of MDAnalysis. However, they are often used in examples,
15-
including many in this User Guide. If you are not interested in developing
16-
MDAnalysis or using the example files, you most likely don't need the tests. If you want to
17-
run examples in the User Guide, install the tests.
18-
The tests are distributed separately from the main package.
12+
Currently, the :ref:`mamba-installation` installs a version of MDAnalysis that does **not** include `OpenMP`_
13+
acceleration due to limitations in precompiled conda packages. If you need `OpenMP`_-enabled features,
14+
consider installing via :ref:`pip-installation` and compiling from source with a compatible compiler and
15+
OpenMP support.
16+
17+
**MDAnalysisTests** is optional and is a separate :ref:`test suite <mdanalysistests>` used
18+
for verifying MDAnalysis installations and running User Guide examples. It is not required for
19+
daily use, but some tutorials rely on it. The package is approximately 90 MB and is not updated frequently.
20+
If you plan to use tutorial examples or contribute to MDAnalysis, installing it is recommended.
21+
22+
MDAnalysis supports specific Python versions. For the latest supported versions, please refer to the
23+
`CHANGELOG`_ or the `PyPI`_. Ensure you have a compatible Python version installed before proceeding.
1924

2025
.. note::
26+
MDAnalysis supports **Linux**, **macOS**, and **Windows**.
2127

22-
If you are installing on Windows, you must have
23-
Microsoft Visual C++ 14.0 installed. If your installation
24-
fails with the error message:
28+
- If you encounter errors on **Windows** related to **Microsoft Visual C++ 14.0**, install the required **Build Tools for Visual Studio** from: `Microsoft Visual Studio Downloads`_.
29+
- If you encounter any other issues following these instructions, seek help on `GitHub Discussions (Installation)`_.
2530

26-
error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/
31+
.. _mamba-installation:
2732

28-
Try installing Build Tools for Visual Studio from
29-
https://visualstudio.microsoft.com/downloads/ (scroll
30-
down to the Tools for Visual Studio section).
33+
mamba/conda
34+
===========
3135

36+
For most users, `mamba`_ is the **recommended** way to install MDAnalysis. It is a faster drop-in
37+
replacement for `conda`_ and efficiently handles dependencies. We also recommend creating a new
38+
environment for MDAnalysis to ensure a clean and isolated installation.
3239

33-
If you encounter any issues following these instructions, please
34-
ask for help on `GitHub Discussions (Installation)`_.
40+
MDAnalysis supports two common ways to install with `mamba`_:
3541

36-
.. _`GitHub Discussions (Installation)`: https://github.com/MDAnalysis/mdanalysis/discussions/categories/installation
42+
**1. Recommended: Use Mambaforge**
3743

38-
conda
39-
=====
44+
`Mambaforge`_ is a minimal `conda`_ distribution that includes `mamba`_ by default, uses the `conda-forge`_ channel
45+
(preferred for MDAnalysis) and avoids clutter from `Anaconda`_ base packages.
4046

41-
If you use ``conda`` to manage your Python environment, we highly recommend creating a new environment for MDAnalysis.
42-
This will ensure that you have a clean installation of MDAnalysis and its dependencies, and will not interfere with other packages you may have installed.
43-
We further recommend that you install and use ``mamba``, a faster drop-in replacement for ``conda``.
47+
To install MDAnalysis with `Mambaforge`_, follow the `mambaforge installation instructions`_ and then
48+
run the following commands to install MDAnalysis:
4449

4550
.. code-block:: bash
4651
47-
conda create --name mdanalysis
48-
conda activate mdanalysis
49-
conda install -c conda-forge mamba
52+
mamba create -n mdanalysis -c conda-forge mdanalysis
53+
mamba activate mdanalysis
5054
51-
To install the latest stable version of MDAnalysis via ``conda``, use the following command. This installs all dependencies needed for full analysis functionality (excluding external programs such as `HOLE`_):
55+
To install the :ref:`test suite <mdanalysistests>` (optional, ~90 MB):
5256

5357
.. code-block:: bash
5458
55-
mamba install -c conda-forge mdanalysis
59+
mamba install -c conda-forge MDAnalysisTests
5660
57-
To upgrade:
61+
To upgrade, use:
5862

5963
.. code-block:: bash
6064
6165
mamba update mdanalysis
6266
63-
To install the tests:
67+
If you're using MDAnalysis in **JupyterLab**, install `ipywidgets`_ for progress bar support:
6468

6569
.. code-block:: bash
6670
67-
mamba install -c conda-forge MDAnalysisTests
71+
mamba install -c conda-forge ipywidgets
72+
73+
**2. Alternative: Use conda with conda-forge**
6874

69-
If you intend to use MDAnalysis in JupyterLab, you will have to install
70-
an extra package for the progress bar in analysis classes:
75+
If you prefer using `conda`_ directly (e.g., installed via `Anaconda installer`_), create a new environment with packages from the `conda-forge`_ channel:
7176

7277
.. code-block:: bash
7378
74-
conda install -c conda-forge nodejs
75-
jupyter labextension install @jupyter-widgets/jupyterlab-manager
79+
conda create -n mdanalysis -c conda-forge mdanalysis
80+
conda activate mdanalysis
81+
82+
To install optional packages:
83+
84+
.. code-block:: bash
85+
86+
conda install -c conda-forge MDAnalysisTests ipywidgets
87+
88+
.. _pip-installation:
7689

7790
pip
78-
=====
79-
The following command will install or upgrade the latest stable version of MDAnalysis via ``pip``, with core dependencies. This means that some packages required by specific analysis modules will not be installed.
91+
===
92+
93+
The following command will install or upgrade the latest stable version of MDAnalysis via `pip`_ with core dependencies.
94+
This means that some packages required by specific analysis modules will not be installed.
8095

8196
.. code-block:: bash
8297
8398
pip install --upgrade MDAnalysis
8499
85-
If you need to install a fully-featured MDAnalysis, add the ``analysis`` tag. As with ``conda``, this will not install external programs such as `HOLE`_.
100+
MDAnalysis offers several optional dependency groups (“extra tags”) that you can install with pip to enable additional features:
101+
102+
- ``analysis``: optional dependencies for various analysis modules.
103+
- ``extra_formats``: support for additional file formats.
104+
- ``parallel``: install dask to enable parallel analysis across multiple cores or machines.
105+
- ``doc``: install documentation build dependencies (e.g. Sphinx, themes).
106+
107+
To see the full list of available extras, check the `pyproject.toml file`_.
108+
109+
To install with optional features, use pip with one or more extras:
86110

87111
.. code-block:: bash
88112
89-
pip install --upgrade MDAnalysis[analysis]
113+
pip install --upgrade MDAnalysis[analysis,extra_formats,parallel]
90114
91-
To install/upgrade tests:
115+
To install or upgrade the :ref:`test suite <mdanalysistests>` (optional, ~90 MB):
92116

93117
.. code-block:: bash
94118
95119
pip install --upgrade MDAnalysisTests
96120
97-
If you intend to use MDAnalysis in JupyterLab, you will have to install
98-
an extra package for the progress bar in analysis classes:
121+
If you're using MDAnalysis in **JupyterLab**, install `ipywidgets`_ for progress bar support:
99122

100123
.. code-block:: bash
101124
102-
pip install nodejs
103-
jupyter labextension install @jupyter-widgets/jupyterlab-manager
125+
pip install ipywidgets
104126
127+
.. _source-installation:
105128

106-
Development versions
107-
====================
108-
To install development versions of MDAnalysis, you can compile it from source. In order to install from source, you will need ``numpy`` and ``cython``. See :ref:`create-virtual-environment` for instructions on how to create a full development environment.
129+
Install from source
130+
===================
131+
132+
This section is for **users** who want to install a **specific stable version** of MDAnalysis
133+
(e.g., for reproducibility or to debug a release). This is **not** intended for development or code contributions.
134+
If you're a developer, see :ref:`development-installation`.
135+
136+
To install from source, you must first ensure that your environment already contains all necessary dependencies.
137+
We recommend you check the :ref:`create-virtual-environment` to set up a clean development environment
138+
with all required dependencies. We recommend using `mamba`_ or `conda`_ to manage this setup.
139+
140+
Follow the steps in:
141+
142+
- `Set up with conda-forge`_
143+
- `Set up with mamba`_
144+
145+
MDAnalysis uses different Git branches for different purposes:
146+
147+
- **package-X.Y.Z**: These are tags, not branches, and represent stable release versions (e.g., package-2.9.0). These tags are ideal if you need reproducibility, debugging, or version locking. You can browse all tags on the GitHub `Branches page`_.
148+
- **develop**: The `develop`_ branch is the default and active development branch. If you're contributing to MDAnalysis or want the latest unreleased features, base your work on this branch (see :ref:`development-installation`).
149+
150+
Clone the repository and check out the tag corresponding to the desired version:
109151

110152
.. code-block:: bash
111153
112154
git clone https://github.com/MDAnalysis/mdanalysis
113155
cd mdanalysis
114-
# assuming you have already installed required dependencies
156+
git checkout package-<version>
157+
158+
You will now be in a detached HEAD state, which is expected when checking out a tag. This allows you to explore or install that version without affecting branches.
159+
If you plan to make changes, you can create a new branch based on the tag:
160+
161+
.. code-block:: bash
162+
163+
git switch -c my-fix-based-on-2.9.0
164+
165+
To install MDAnalysis from this version:
166+
167+
.. code-block:: bash
168+
169+
pip install package/.
170+
171+
To run tests:
172+
173+
.. code-block:: bash
174+
175+
pip install MDAnalysisTests
176+
177+
.. _development-installation:
178+
179+
Install for development
180+
==========================
181+
182+
This section is for **contributors and developers** who want to modify MDAnalysis
183+
or contribute to its development. You’ll install MDAnalysis in **editable mode**, which allows you to make code changes
184+
without reinstalling the package each time.
185+
186+
Before installing, follow the steps described in the :ref:`source-installation` to set up a clean environment
187+
with all dependencies.
188+
189+
Once your environment is ready, install MDAnalysis in editable mode:
190+
191+
.. code-block:: bash
192+
193+
git clone https://github.com/MDAnalysis/mdanalysis
194+
cd mdanalysis
195+
git switch develop # work on the develop branch
196+
git checkout -b my-feature-branch # Create a new branch for your changes
115197
pip install -e package/
116198
117-
And to install the test suite:
199+
Installing in editable mode (`-e`) means that any changes you make to the MDAnalysis source code are immediately
200+
available without needing to reinstall.
201+
202+
If you plan to run tests you can install the test suite:
118203

119204
.. code-block:: bash
120205
206+
# Install the test suite (optional but recommended for contributors)
121207
pip install -e testsuite/
122208
209+
For more on how to set up and contribute, refer to the :ref:`contributing` guide.
123210

124211
Testing
125212
-------
126213

127-
The tests rely on the `pytest` and `numpy` packages, which must also be installed. Run tests with:
214+
The tests rely on the `pytest`_ and `numpy`_ packages, which must also be installed. Run tests with:
128215

129216
.. code-block:: bash
130217
131218
pytest --disable-pytest-warnings --pyargs MDAnalysisTests
132219
133220
All tests should pass (i.e. no FAIL, ERROR); SKIPPED or XFAIL are ok. If anything fails or gives an error,
134-
`ask on GitHub Discussions <https://github.com/MDAnalysis/mdanalysis/discussions>`_ or `raise an issue <https://github.com/MDAnalysis/mdanalysis/issues>`_.
221+
ask on `GitHub Discussions`_ or `raise an issue`_.
135222

136-
Testing MDAnalysis can take a while, as there are quite a few tests.
137-
The plugin `pytest-xdist <https://github.com/pytest-dev/pytest-xdist>`_ can be used to run tests in parallel.
223+
Running MDAnalysis tests can take some time, as there are many test cases.
224+
The plugin `pytest-xdist`_ can be used to run tests in parallel.
138225

139226
.. code-block:: bash
140227
@@ -148,7 +235,7 @@ You can pass any additional compiler flags for the C/C++ compiler using the ``ex
148235
This allows you to add any additional compiler options required for your architecture.
149236

150237
For example, ``extra_cflags`` can be used to tune your MDAnalysis installation for your current architecture using the `-march`, `-mtune`, `-mcpu` and related compiler flags.
151-
*Which* particular compiler flags to use depends on your CPU architecture. An example for an x86_64 machine would be to change the line in `setup.cfg` as follows:
238+
The optimal compiler flags depend on your CPU architecture. Commonly recommended settings are:
152239

153240
.. code-block:: diff
154241
@@ -157,22 +244,24 @@ For example, ``extra_cflags`` can be used to tune your MDAnalysis installation f
157244
158245
Use of these flags can give a significant performance boost where the compiler can effectively autovectorise.
159246

160-
Be sure to use the recommended flags for your target architecture. For example, ARM platforms recommend using ``-mcpu`` *instead* of ``-mcpu``, while
161-
PowerPC platforms prefer *both* ``-mcpu`` and ``-mtune``.
247+
Be sure to use the recommended flags for your target architecture. In many cases,
248+
``-march`` and ``-mcpu`` can be used together or separately, and their behavior depends
249+
on your platform and compiler version. For example, ARM platforms often prefer ``-mcpu``,
250+
while PowerPC may use both ``-mcpu`` and ``-mtune``. Refer to the `GCC documentation on -march`_
251+
and `-mcpu`_ for platform-specific guidance.
162252

163-
Full dicussion of the these flags is available elsewhere (such as here in this wiki_ or in this ARM_ blog post) and a list of supported options should be provided by your compiler. The list for GCC_ is provided here.
253+
Full discussion of these flags is available elsewhere (such as here in this `wiki`_ or in this `ARM`_ blog post) and a list of supported options should be provided by your compiler. The list for GCC_ is provided here.
164254

165255
.. warning::
166-
Use of these compiler options is considered **advanced** and may reduce the binary compatibility of MDAnalysis significantly, especially if using `-march`,
167-
making it usable only on a matching CPU architecture to the one it is compiled on. We **strongly** recommend that you run the test suite on your intended platform
168-
before proceeding with analysis.
256+
These compiler options are **advanced** and may reduce binary compatibility. In particular, using `-march` may restrict MDAnalysis to the exact CPU architecture it was compiled on.
257+
We **strongly recommend** that you run the test suite on your intended platform before proceeding with analysis.
169258

170259
In cases where you might encounter multiple CPU architectures (e.g. on a supercomputer where the login node and compute node have different architectures), you should avoid changing these options unless you are experienced with compiling software in these situations.
171260

172261
Additional datasets
173262
===================
174263

175-
MDAnalysisData_ is an additional package with datasets that can be used in example tutorials. You can install it with ``conda`` or ``pip``:
264+
MDAnalysisData_ is an additional package with datasets that can be used in example tutorials. You can install it with `mamba`_ / `conda`_ or `pip`_:
176265

177266
.. code-block:: bash
178267
@@ -183,9 +272,35 @@ MDAnalysisData_ is an additional package with datasets that can be used in examp
183272
184273
This installation does not download all the datasets; instead, the datasets are cached when they are first downloaded using a Python command.
185274

186-
187-
.. _`HOLE`: http://www.holeprogram.org
188275
.. _GCC: https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html
189276
.. _MDAnalysisData: https://www.mdanalysis.org/MDAnalysisData/
190277
.. _wiki: https://wiki.gentoo.org/wiki/GCC_optimization#-march
191278
.. _ARM: https://community.arm.com/arm-community-blogs/b/tools-software-ides-blog/posts/compiler-flags-across-architectures-march-mtune-and-mcpu
279+
.. _pip: https://pip.pypa.io/en/latest/index.html
280+
.. _mamba: https://anaconda.org/conda-forge/mamba
281+
.. _conda: https://docs.conda.io/projects/conda/en/latest/
282+
.. _source: https://github.com/MDAnalysis/mdanalysis/
283+
.. _GitHub Discussions (Installation): https://github.com/MDAnalysis/mdanalysis/discussions/categories/installation
284+
.. _Microsoft Visual Studio Downloads: https://visualstudio.microsoft.com/downloads/
285+
.. _pytest: https://docs.pytest.org/en/stable/
286+
.. _numpy: https://numpy.org/
287+
.. _Github discussions: https://github.com/MDAnalysis/mdanalysis/discussions
288+
.. _raise an issue: https://github.com/MDAnalysis/mdanalysis/issues
289+
.. _pytest-xdist: https://github.com/pytest-dev/pytest-xdist
290+
.. _OpenMP: https://www.openmp.org/
291+
.. _mambaforge installation instructions: https://mamba.readthedocs.io/en/latest/installation/mamba-installation.html
292+
.. _Mambaforge: https://github.com/conda-forge/miniforge#mambaforge
293+
.. _conda-forge: https://conda-forge.org/
294+
.. _Anaconda: https://www.anaconda.com/products/distribution
295+
.. _ipywidgets: https://ipywidgets.readthedocs.io/en/stable/
296+
.. _Releases page: https://github.com/MDAnalysis/mdanalysis/releases
297+
.. _Set up with conda-forge: https://userguide.mdanalysis.org/stable/contributing_code.html#with-conda-forge-packages
298+
.. _Set up with mamba: https://userguide.mdanalysis.org/stable/contributing_code.html#with-mamba-conda
299+
.. _develop: https://github.com/MDAnalysis/mdanalysis/tree/develop
300+
.. _Branches page: https://github.com/MDAnalysis/mdanalysis/branches/all
301+
.. _CHANGELOG: https://github.com/MDAnalysis/mdanalysis/blob/develop/package/CHANGELOG
302+
.. _PyPI: https://pypi.org/project/MDAnalysis/
303+
.. _pyproject.toml file: https://github.com/MDAnalysis/mdanalysis/blob/develop/package/pyproject.toml#L69
304+
.. _GCC documentation on -march: https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html
305+
.. _-mcpu: https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html
306+
.. _Anaconda installer: https://docs.anaconda.com/free/anaconda/install/

0 commit comments

Comments
 (0)