Skip to content

Commit f5ff282

Browse files
authored
Merge pull request #988 from haddocking/dev-docs
add development instructions
2 parents a94f9f9 + fc17537 commit f5ff282

File tree

4 files changed

+139
-30
lines changed

4 files changed

+139
-30
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,16 @@ jobs:
2626
sudo apt-get update
2727
sudo apt-get install -y openmpi-bin libopenmpi3 libopenmpi-dev
2828
29+
- name: install python dependencies
30+
run: pip install -r requirements.txt
31+
2932
- name: install test dependencies
3033
run: >-
3134
pip install coverage pytest pytest-cov hypothesis pytest-mock mypy
3235
fastapi==0.110.1 httpx==0.27.0 mpi4py==3.1.6
3336
3437
- name: install haddock3
35-
run: pip install -v .
38+
run: python setup.py -v develop
3639

3740
## Disabled for now until we figure out a good configuration ##
3841
# - name: check types
@@ -63,3 +66,8 @@ jobs:
6366
with:
6467
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
6568
coverage-reports: ./coverage.xml
69+
70+
- name: check if docs are buildable
71+
# this step can fail
72+
continue-on-error: true
73+
run: tox -e docs

.github/workflows/docs.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

DEVELOPMENT.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# Developing HADDOCK3
2+
3+
This file provides information on how to setup a development environment for HADDOCK3.
4+
5+
- [System requirements](#system-requirements)
6+
- [Setting up the development environment](#setting-up-the-development-environment)
7+
- [Clone the repository](#clone-the-repository)
8+
- [Python environment](#python-environment)
9+
- [Install Python dependencies](#install-python-dependencies)
10+
- [Running tests](#running-tests)
11+
12+
## System requirements
13+
14+
- Python 3.9
15+
- OpenMPI
16+
17+
### Installing system dependencies
18+
19+
Below the instructions are provided for a Ubuntu system using `apt-get`. If you are using a different system, please refer to the respective package manager - `yum`, `dnf`, `pacman`, `homebrew`, `port`, etc.
20+
21+
```bash
22+
sudo apt-get update &&
23+
# Needed for building Python
24+
sudo apt-get install build-essential python-setuptools python-pip &&
25+
sudo apt-get install libncursesw5-dev libgdbm-dev libc6-dev &&
26+
sudo apt-get install zlib1g-dev libsqlite3-dev tk-dev &&
27+
sudo apt-get install libssl-dev openssl &&
28+
sudo apt-get install libffi-dev &&
29+
# Needed for haddock3 installation
30+
sudo apt-get install git gcc &&
31+
# Needed to run the MPI related tests
32+
sudo apt-get install openmpi-bin libopenmpi3 libopenmpi-dev
33+
```
34+
35+
After all the system-dependencies are in place, download and compile python.
36+
37+
**Conda is NOT recommended for development**
38+
39+
```bash
40+
wget https://www.python.org/ftp/python/3.9.6/Python-3.9.6.tgz
41+
tar -xf Python-3.9.6.tgz
42+
cd Python-3.9.6
43+
./configure --enable-optimizations
44+
sudo make altinstall -j 8
45+
```
46+
47+
Then `python3.9` should be available on your system at `/usr/local/bin/python3.9`
48+
49+
On **OSX**, you can use a package-manager such as [brew](https://brew.sh) to install Python 3.9.
50+
51+
> Please keep in mind installing python with a package manager can mask system dependencies that your development might add. That's why we recommended you install it from source.
52+
53+
```bash
54+
brew install [email protected]
55+
```
56+
57+
## Setting up the development environment
58+
59+
### Clone the repository
60+
61+
```bash
62+
git clone https://github.com/haddocking/haddock3.git
63+
cd haddock3
64+
```
65+
66+
### Python environment
67+
68+
We recommend you use Python's native virtual environment to manage the dependencies.
69+
70+
```bash
71+
python3.9 -m venv .venv
72+
source .venv/bin/activate
73+
```
74+
75+
### Install python dependencies
76+
77+
Install both project dependencies and test dependencies using pip.
78+
79+
```bash
80+
pip install -r requirements.txt &&
81+
pip install \
82+
coverage==7.2.5 \
83+
pytest==7.3.1 \
84+
pytest-cov==4.0.0 \
85+
hypothesis==6.75.1 \
86+
pytest-mock==3.12.0 \
87+
fastapi==0.110.1 \
88+
httpx==0.27.0 \
89+
mpi4py==3.1.6
90+
```
91+
92+
> If you are using a Mac, if the installation of mpi4py fails, run first `brew install mpi4py`
93+
94+
### Install haddock3 in development mode.
95+
96+
In this mode the files are linked to the appropriate paths inside the python environment;
97+
98+
```bash
99+
python setup.py develop
100+
```
101+
102+
## Running tests
103+
104+
In `haddock3` we use the pytest framework, the tests are located in `tests/` (unit) and `integration_tests/` directories.
105+
106+
```bash
107+
pytest
108+
```
109+
110+
## Installation in an HPC environment
111+
112+
**Please get in contact with the system administrator before doing development in a shared HPC environment.**
113+
114+
For installation in an HPC environment we recommend to check the installed Python versions on the system and also importantly if an `openmpi` (or other custom MPI) installation is available on the system.
115+
Those are often offered via the `module` command.
116+
If you only intend to develop haddock3 using the multiprocessing scheduler, the above instructions should be fine. But to harvest the MPI capabilities of an HPC system it is best to build haddock3 using the installed MPI version on the HPC system.

setup.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
from setuptools import Extension, find_packages, setup
1313
from setuptools.command.build_ext import build_ext
14+
from setuptools.command.develop import develop
1415
from setuptools.command.install import install
1516

1617

@@ -144,6 +145,14 @@ def get_arch():
144145
return f"{machine}-{system}"
145146

146147

148+
class CustomDevelop(develop):
149+
150+
def run(self):
151+
"""Wrapper class to run the installation also when using `python setup.py develop`"""
152+
self.run_command("install")
153+
develop.run(self)
154+
155+
147156
with open("requirements.txt", "r", encoding="utf-8") as f:
148157
requirements = f.read().splitlines()
149158

@@ -226,6 +235,10 @@ def read_description(*names, **kwargs) -> str:
226235
"haddock3-restraints = haddock.clis.cli_restraints:maincli",
227236
]
228237
},
229-
cmdclass={"build_ext": CustomBuild, "install": CustomInstall},
238+
cmdclass={
239+
"build_ext": CustomBuild,
240+
"install": CustomInstall,
241+
"develop": CustomDevelop,
242+
},
230243
ext_modules=cpp_extensions,
231244
)

0 commit comments

Comments
 (0)