diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 45d9d024..2161688f 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -74,12 +74,18 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v2 - - name: Install & upgrade pip3 and install OpenMPI + - name: Install & upgrade pip3 run: | sudo apt-get -yy update - sudo apt-get install -y python3-pip libopenmpi-dev + sudo apt-get install -y python3-pip sudo rm -rf /var/lib/apt/lists/* pip3 install --upgrade --user pip + - name: Install OpenMPI and mpi4py + run: | + sudo apt-get -yy update + sudo apt-get install -y libopenmpi-dev + sudo rm -rf /var/lib/apt/lists/* + pip3 install --user mpi4py - name: Checkout precice and make required files discoverable run: | git clone https://github.com/precice/precice.git precice-core @@ -93,7 +99,33 @@ jobs: run: | export CFLAGS=-I$GITHUB_WORKSPACE python3 setup.py test - + + setup_test_no_mpi: + name: Run setup test (without MPI based tests) + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + - name: Install & upgrade pip3 + run: | + sudo apt-get -yy update + sudo apt-get install -y python3-pip + sudo rm -rf /var/lib/apt/lists/* + pip3 install --upgrade --user pip + - name: Checkout precice and make required files discoverable + run: | + git clone https://github.com/precice/precice.git precice-core + mkdir -p precice + cp precice-core/src/precice/SolverInterface.hpp precice/SolverInterface.hpp + - name: Install dependencies + run: | + pip3 install --user toml + python3 -c 'import toml; c = toml.load("pyproject.toml"); print("\n".join(c["build-system"]["requires"]))' | pip3 install -r /dev/stdin + - name: Run setup test + run: | + export CFLAGS=-I$GITHUB_WORKSPACE + python3 setup.py test + pip_install: name: Run pip install needs: [setup_test] diff --git a/.github/workflows/build-spack.yml b/.github/workflows/build-spack.yml index 1d734b7c..a40dbd2f 100644 --- a/.github/workflows/build-spack.yml +++ b/.github/workflows/build-spack.yml @@ -22,4 +22,4 @@ jobs: cp spack/repo/packages/py-pyprecice/*.patch /py-pyprecice-repo/packages/py-pyprecice/ - name: Try to build py-pyprecice with spack and test it run: | - . /opt/spack/share/spack/setup-env.sh && spack env activate ci && spack arch && spack find && spack dev-build py-pyprecice@develop target=x86_64 && spack load precice py-numpy py-mpi4py py-cython openssh openmpi && mkdir runner && cd runner && python3 -c "import precice; print(precice.__version__)" + . /opt/spack/share/spack/setup-env.sh && spack env activate ci && spack arch && spack find && spack dev-build py-pyprecice@develop target=x86_64 && spack load precice py-numpy py-cython openssh openmpi && mkdir runner && cd runner && python3 -c "import precice; print(precice.__version__)" diff --git a/README.md b/README.md index a1f1f112..ea9e326b 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,6 @@ Please refer to [precice.org](https://www.precice.org/installation-bindings-pyth **preCICE**: Refer to [the preCICE wiki](https://github.com/precice/precice/wiki#1-get-precice) for information on building and installation. -**MPI**: `mpi4py` requires MPI to be installed on your system. - # Installing the package We recommend using pip3 (version 19.0.0 or newer required) for the sake of simplicity. You can check your pip3 version via `pip3 --version`. To update pip3, use the following line: diff --git a/cyprecice/cyprecice.pyx b/cyprecice/cyprecice.pyx index 3b858988..c5479421 100644 --- a/cyprecice/cyprecice.pyx +++ b/cyprecice/cyprecice.pyx @@ -7,7 +7,6 @@ The python module precice offers python language bindings to the C++ coupling li cimport cyprecice import numpy as np -from mpi4py import MPI from cpython.version cimport PY_MAJOR_VERSION # important for determining python version in order to properly normalize string input. See http://docs.cython.org/en/latest/src/tutorial/strings.html#general-notes-about-c-strings and https://github.com/precice/precice/issues/68 . diff --git a/pyproject.toml b/pyproject.toml index 0e050577..a9064dd0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,3 @@ [build-system] # PEP 518 - minimum build system requirements -requires = ["setuptools", "wheel", "Cython>=0.29", "packaging", "pip>=19.0.0", "numpy", "mpi4py"] +requires = ["setuptools", "wheel", "Cython>=0.29", "pip>=19.0.0", "numpy"] diff --git a/setup.py b/setup.py index b6efc9ff..536ea142 100644 --- a/setup.py +++ b/setup.py @@ -145,9 +145,7 @@ def initialize_options(self): author_email='info@precice.org', license='LGPL-3.0', python_requires='>=3', - install_requires=['numpy', 'mpi4py'], - # mpi4py is only needed, if preCICE was compiled with MPI - # see https://github.com/precice/python-bindings/issues/8 + install_requires=['numpy'], packages=['precice'], zip_safe=False # needed because setuptools are used ) diff --git a/spack/repo/packages/py-pyprecice/package.py b/spack/repo/packages/py-pyprecice/package.py index 65817306..ca9d96a9 100644 --- a/spack/repo/packages/py-pyprecice/package.py +++ b/spack/repo/packages/py-pyprecice/package.py @@ -44,7 +44,6 @@ class PyPyprecice(PythonPackage): depends_on("python@3:", type=("build", "run")) depends_on("py-setuptools", type="build") depends_on("py-numpy", type=("build", "run")) - depends_on("py-mpi4py", type=("build", "run")) depends_on("py-cython@0.29:", type=("build")) phases = ['install_lib', 'build_ext', 'install'] diff --git a/test/test_bindings_module.py b/test/test_bindings_module.py index e5d174d0..d82b79ad 100644 --- a/test/test_bindings_module.py +++ b/test/test_bindings_module.py @@ -1,7 +1,13 @@ import precice from unittest import TestCase import numpy as np -from mpi4py import MPI +import warnings +try: + from mpi4py import MPI + has_mpi = True +except ModuleNotFoundError: + warnings.warn("No MPI detected. Some tests will not be run.") + has_mpi = False class TestBindings(TestCase): @@ -13,10 +19,11 @@ def test_constructor(self): solver_interface = precice.Interface("test", "dummy.xml", 0, 1) self.assertTrue(True) - def test_constructor_custom_mpi_comm(self): - solver_interface = precice.Interface( - "test", "dummy.xml", 0, 1, MPI.COMM_WORLD) - self.assertTrue(True) + if has_mpi: + def test_constructor_custom_mpi_comm(self): + solver_interface = precice.Interface( + "test", "dummy.xml", 0, 1, MPI.COMM_WORLD) + self.assertTrue(True) def test_version(self): precice.__version__