Specify OMP_NUM_THREADS for Pyhon CI scripts.
[gromacs.git] / admin / ci-scripts / build-and-test-sample_restraint-2021.sh
blob8de02b527024b95a3bab59b4c2587e3fea35943a
1 #!/usr/bin/env bash
3 # Build and test the sample_restraint package distributed with GROMACS 2021.
5 # This script is intended to support automated GROMACS testing infrastructure,
6 # and may be removed without notice.
8 # WARNING: This script assumes OpenMPI mpiexec. Syntax for launch wrappers from
9 # other implementations will need different syntax, and we should get a
10 # MPIRUNNER from the environment, or something.
12 # Make sure the script errors if any commands error.
13 set -e
15 # Create "sdist" source distribution archive.
16 pushd python_packaging/src
17 # TODO: Remove extraneous environment variable with resolution of #3273
18 # Ref: https://redmine.gromacs.org/issues/3273
19 GMXTOOLCHAINDIR=$INSTALL_DIR/share/cmake/gromacs \
20 python setup.py sdist
21 # TODO: Identify SDIST
23 # Build and install from sdist.
24 # Note that tool chain may be provided differently in GROMACS 2020 and 2021.
25 # TODO: How should we distinguish the target branch?
26 # if [ "2020" -eq "$GROMACS_VERSION" ]; then
27 if [ 1 ]; then
28 GMXTOOLCHAINDIR=$INSTALL_DIR/share/cmake/gromacs \
29 python -m pip install \
30 --no-cache-dir \
31 --no-deps \
32 --no-index \
33 --no-build-isolation \
34 dist/gmxapi*
35 # TODO: Build and install from $SDIST instead of wildcard.
36 # TODO: How should we distinguish the target branch?
37 # elif [ "2021" -eq "$GROMACS_VERSION" ]; then
38 # GMXTOOLCHAINDIR=$INSTALL_DIR/share/cmake/gromacs \
39 # python -m pip install \
40 # --no-cache-dir \
41 # --no-deps \
42 # --no-index \
43 # --no-build-isolation \
44 # dist/gmxapi*
45 # TODO: Build and install from $SDIST instead of wildcard.
46 else
47 echo "Logic error in GROMACS version handling."
48 exit 1
50 popd
52 . $INSTALL_DIR/bin/GMXRC
53 pushd python_packaging/sample_restraint
54 mkdir build
55 pushd build
56 # TODO: Update with respect to https://redmine.gromacs.org/issues/3133
57 cmake .. \
58 -DDOWNLOAD_GOOGLETEST=ON \
59 -DGMXAPI_EXTENSION_DOWNLOAD_PYBIND=ON
60 make
62 make test
63 #TODO: Can we get ctest JUnitXML output here?
65 make install
66 popd
68 python -m pytest $PWD/tests --junitxml=$PLUGIN_TEST_XML
70 # Note: Multiple pytest processes getting --junitxml output file argument
71 # may cause problems, so we set the option on only one of the launched processes.
72 # See also Multiple Instruction Multiple Data Model for OpenMPI mpirun:
73 # https://www.open-mpi.org/doc/v3.0/man1/mpiexec.1.php
74 PROGRAM=(`which python` -m mpi4py -m pytest \
75 -p no:cacheprovider \
76 $PWD/tests)
77 # shellcheck disable=SC2068
78 if [ -x `which mpiexec` ]; then
79 PYTHONDONTWRITEBYTECODE=1 \
80 mpiexec --allow-run-as-root \
81 -x OMP_NUM_THREADS=1 \
82 --mca opal_warn_on_missing_libcuda 0 \
83 --mca orte_base_help_aggregate 0 \
84 -n 1 ${PROGRAM[@]} --junitxml=$PLUGIN_MPI_TEST_XML : \
85 -n 1 ${PROGRAM[@]}
87 popd