Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove mpi4py as dependency #101

Draft
wants to merge 17 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 35 additions & 3 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-spack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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__)"
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion cyprecice/cyprecice.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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 .

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"]
4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,7 @@ def initialize_options(self):
author_email='[email protected]',
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
)
1 change: 0 additions & 1 deletion spack/repo/packages/py-pyprecice/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("[email protected]:", type=("build"))

phases = ['install_lib', 'build_ext', 'install']
Expand Down
17 changes: 12 additions & 5 deletions test/test_bindings_module.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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__
Expand Down