b05a625d3ae287d6fb3397a8e53b4f5d626c4611
[alexxy/gromacs.git] / admin / ci-scripts / build-and-test-py-gmxapi-0.3.sh
1 #!/usr/bin/env bash
2 #
3 # Build, install, and test the gmxapi 0.3 Python package developed with
4 # GROMACS 2022.
5 #
6 # This script assumes an activated Python venv with the
7 # gmxapi dependencies already installed, with `python` resolvable by the shell
8 # to the appropriate Python interpreter.
9 #
10 # This script is intended to support automated GROMACS testing infrastructure,
11 # and may be removed without notice.
12 #
13 # WARNING: This script assumes OpenMPI mpiexec. Syntax for launch wrappers from
14 # other implementations will need different syntax, and we should get a
15 # MPIRUNNER from the environment, or something.
16
17 # Make sure the script errors if any commands error.
18 set -e
19
20 pushd python_packaging/src
21   # Make sure to delete any accidentally lingering build artifacts.
22   rm -rf build dist
23   # Build and install the gmxapi Python package.
24 # TODO(#4092): Revert to using --no-deps and --no-index once Docker images updated.
25   GMXTOOLCHAINDIR=$INSTALL_DIR/share/cmake/gromacs \
26       python -m pip install \
27           --no-cache-dir \
28           .
29 #  # TODO(#3273): Reduce requirements for `setup.py` `sdist` command and provide build artifact.
30 #  GMXTOOLCHAINDIR=$INSTALL_DIR/share/cmake/gromacs \
31 #      python -m pip install \
32 #          --no-cache-dir \
33 #          --no-deps \
34 #          --no-index \
35 #          .
36 popd
37
38 # Run Python unit tests.
39 python -m pytest python_packaging/src/test --junitxml=$PY_UNIT_TEST_XML --threads=2
40
41 # Note: Multiple pytest processes getting --junitxml output file argument
42 # may cause problems, so we set the option on only one of the launched processes.
43 # See also Multiple Instruction Multiple Data Model for OpenMPI mpirun:
44 # https://www.open-mpi.org/doc/v3.0/man1/mpiexec.1.php
45 PROGRAM=(`which python` -m mpi4py -m pytest \
46         -p no:cacheprovider \
47         $PWD/python_packaging/src/test \
48         --threads=1)
49 # shellcheck disable=SC2068
50 if [ -x `which mpiexec` ]; then
51     PYTHONDONTWRITEBYTECODE=1 \
52     mpiexec --allow-run-as-root \
53       -x OMP_NUM_THREADS=1 \
54       --mca opal_warn_on_missing_libcuda 0 \
55       --mca orte_base_help_aggregate 0 \
56       -n 1 ${PROGRAM[@]} --junitxml=$PLUGIN_MPI_TEST_XML : \
57       -n 1 ${PROGRAM[@]}
58 fi