summaryrefslogtreecommitdiff
path: root/.github/how_to_compile_gudhi_in_a_conda_env.md
blob: 4acfca2e6e4e4d7eb95b45a3ecba3c5d49065cb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# Install a conda development environment to compile GUDHI

## Install miniconda

Download the [installer](https://docs.conda.io/en/latest/miniconda.html) required by your system and follow the [instructions](https://conda.io/projects/conda/en/latest/user-guide/install/index.html).

## Create a dedicated environment

```bash
conda install -c conda-forge mamba  # installation with mamba is faster
conda create --name gudhi
conda activate gudhi
mamba install -c conda-forge python cmake doxygen eigen cgal-cpp
```

Some of the requirements are in the gudhi-devel repository (please refer to
[how to use github to contribute to gudhi](how_to_use_github_to_contribute_to_gudhi.md)).
Once the gudhi-devel repository is cloned on your machine (`git clone...`) - let's call it `/workdir/gudhi-devel` i.e. -
and once the submodules are initialised (`git submodule update --init`):

```bash
pip install -r ext/gudhi-deploy/build-requirements.txt 
pip install -r ext/gudhi-deploy/test-requirements.txt  # pytorch can be painful to install - not mandatory
```

## Compilation

In order to compile all c++ utilities, examples, benchmarks, unitary tests, and python module:
```bash
cd /workdir/gudhi-devel
rm -rf build; mkdir build  # /!\ any existing build folder will be removed
cd build
# To build all even examples and benchmarks
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=$CONDA_PREFIX -DWITH_GUDHI_EXAMPLE=ON -DWITH_GUDHI_BENCHMARK=ON ..
```

### Specific python compilation

In order to compile only python module
```bash
cd /workdir/gudhi-devel
rm -rf build; mkdir build  # /!\ any existing build folder will be removed
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=$CONDA_PREFIX ..
cd src/python
# To build python module in parallel
python setup.py build_ext -j 16 --inplace  # 16 is the number of CPU that are used to compile the python module. Can be any other value.
# to clean the build
# python setup.py clean --all
```

In order to use freshly compiled gudhi python module:
```bash
PYTHONPATH=/workdir/gudhi-devel/build/src/python python # or ipython, jupyter, ...
```

### Specific C++ documentation generation

```bash
cd /workdir/gudhi-devel
rm -rf build; mkdir build  # /!\ any existing build folder will be removed
cd build
# python OFF to prevent python modules search makes cmake faster
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=$CONDA_PREFIX -DWITH_GUDHI_PYTHON=OFF -DUSER_VERSION_DIR=version ..
make user_version;
cd version
mkdir build
cd build
# python OFF to prevent python modules search makes cmake faster
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=$CONDA_PREFIX -DWITH_GUDHI_PYTHON=OFF  ..
make doxygen 2>&1 | tee dox.log
grep warning dox.log # Warnings can be lost with parallel doxygen
firefox html/index.html # [optional] To display the c++ documentation. Anything else than firefox can be used.
```

### Specific python documentation generation

```bash
cd /workdir/gudhi-devel
rm -rf build; mkdir build  # /!\ any existing build folder will be removed
cd build
# python OFF to prevent python modules search makes cmake faster - it is the next cmake call in user version that matters
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=$CONDA_PREFIX -DWITH_GUDHI_PYTHON=OFF -DUSER_VERSION_DIR=version ..
make user_version;
cd version
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=$CONDA_PREFIX ..
cd python
# To build python module in parallel
python setup.py build_ext -j 16 --inplace  # 16 is the number of CPU that are used to compile the python module. Can be any other value.
firefox sphinx/index.html # [optional] To display the python documentation. Anything else than firefox can be used.
```